mirror of
https://github.com/zhaofengli/attic.git
synced 2025-03-05 08:17:05 +00:00
Merge pull request #190 from zhaofengli/gha-integration-tests
Move integration tests to GitHub Actions
This commit is contained in:
commit
0fe1b1cd34
4 changed files with 176 additions and 2 deletions
146
.github/workflows/build.yml
vendored
146
.github/workflows/build.yml
vendored
|
@ -6,6 +6,64 @@ env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ghcr.io/${{ github.repository }}
|
IMAGE_NAME: ghcr.io/${{ github.repository }}
|
||||||
jobs:
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.1.7
|
||||||
|
|
||||||
|
- name: Install current Bash on macOS
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: |
|
||||||
|
command -v brew && brew install bash || true
|
||||||
|
|
||||||
|
- uses: DeterminateSystems/nix-installer-action@v14
|
||||||
|
continue-on-error: true # Self-hosted runners already have Nix installed
|
||||||
|
|
||||||
|
- name: Install Attic
|
||||||
|
run: |
|
||||||
|
if ! command -v attic &> /dev/null; then
|
||||||
|
./.github/install-attic-ci.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Configure Attic
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
: "${ATTIC_SERVER:=https://staging.attic.rs/}"
|
||||||
|
: "${ATTIC_CACHE:=attic-ci}"
|
||||||
|
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
|
||||||
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
|
||||||
|
attic use "$ATTIC_CACHE"
|
||||||
|
env:
|
||||||
|
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
|
||||||
|
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
|
||||||
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
||||||
|
|
||||||
|
- name: Cache dev shell
|
||||||
|
run: |
|
||||||
|
.ci/cache-shell.sh
|
||||||
|
system=$(nix-instantiate --eval -E 'builtins.currentSystem')
|
||||||
|
echo system=$system >>$GITHUB_ENV
|
||||||
|
|
||||||
|
# TODO: Abstract all of this out, and use `attic push --stdin` (requires #232)
|
||||||
|
- name: Build packages
|
||||||
|
run: |
|
||||||
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
|
nix build --no-link --print-out-paths -L \
|
||||||
|
.#attic \
|
||||||
|
.#attic-client \
|
||||||
|
.#attic-server \
|
||||||
|
| if [ -n "$ATTIC_CACHE" ]; then
|
||||||
|
xargs attic push "ci:$ATTIC_CACHE"
|
||||||
|
else
|
||||||
|
cat
|
||||||
|
fi
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -67,17 +125,101 @@ jobs:
|
||||||
- name: Push build artifacts
|
- name: Push build artifacts
|
||||||
run: |
|
run: |
|
||||||
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
if [ -n "$ATTIC_TOKEN" ]; then
|
if [ -n "$ATTIC_CACHE" ]; then
|
||||||
nix build --no-link --print-out-paths -L \
|
nix build --no-link --print-out-paths -L \
|
||||||
.#internalMatrix."$system".\"${{ matrix.nix }}\".attic-tests \
|
.#internalMatrix."$system".\"${{ matrix.nix }}\".attic-tests \
|
||||||
.#internalMatrix."$system".\"${{ matrix.nix }}\".cargoArtifacts \
|
.#internalMatrix."$system".\"${{ matrix.nix }}\".cargoArtifacts \
|
||||||
| xargs attic push "ci:$ATTIC_CACHE"
|
| xargs attic push "ci:$ATTIC_CACHE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
nix-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.1.7
|
||||||
|
- uses: DeterminateSystems/nix-installer-action@v14
|
||||||
|
continue-on-error: true # Self-hosted runners already have Nix installed
|
||||||
|
|
||||||
|
- name: Install Attic
|
||||||
|
run: |
|
||||||
|
if ! command -v attic &> /dev/null; then
|
||||||
|
./.github/install-attic-ci.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Configure Attic
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
: "${ATTIC_SERVER:=https://staging.attic.rs/}"
|
||||||
|
: "${ATTIC_CACHE:=attic-ci}"
|
||||||
|
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
|
||||||
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
|
||||||
|
attic use "$ATTIC_CACHE"
|
||||||
|
env:
|
||||||
|
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
|
||||||
|
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
|
||||||
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
||||||
|
- id: set-matrix
|
||||||
|
name: Generate Nix Matrix
|
||||||
|
run: |
|
||||||
|
set -Eeu
|
||||||
|
matrix="$(nix eval --json '.#githubActions.matrix')"
|
||||||
|
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
nix-matrix-job:
|
||||||
|
name: ${{ matrix.name }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
- nix-matrix
|
||||||
|
strategy:
|
||||||
|
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.1.7
|
||||||
|
|
||||||
|
- name: Install current Bash on macOS
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: |
|
||||||
|
command -v brew && brew install bash || true
|
||||||
|
|
||||||
|
- uses: DeterminateSystems/nix-installer-action@v14
|
||||||
|
continue-on-error: true # Self-hosted runners already have Nix installed
|
||||||
|
|
||||||
|
- name: Install Attic
|
||||||
|
run: |
|
||||||
|
if ! command -v attic &> /dev/null; then
|
||||||
|
./.github/install-attic-ci.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Configure Attic
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
: "${ATTIC_SERVER:=https://staging.attic.rs/}"
|
||||||
|
: "${ATTIC_CACHE:=attic-ci}"
|
||||||
|
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
|
||||||
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
|
||||||
|
attic use "$ATTIC_CACHE"
|
||||||
|
env:
|
||||||
|
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
|
||||||
|
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
|
||||||
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build ${{ matrix.attr }}
|
||||||
|
run: |
|
||||||
|
nix build --no-link --print-out-paths -L '.#${{ matrix.attr }}' \
|
||||||
|
| if [ -n "$ATTIC_CACHE" ]; then
|
||||||
|
xargs attic push "ci:$ATTIC_CACHE"
|
||||||
|
else
|
||||||
|
cat
|
||||||
|
fi
|
||||||
|
|
||||||
image:
|
image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
needs:
|
needs:
|
||||||
|
- build
|
||||||
- tests
|
- tests
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -152,7 +294,7 @@ jobs:
|
||||||
- name: Push build artifacts
|
- name: Push build artifacts
|
||||||
run: |
|
run: |
|
||||||
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
||||||
if [ -n "$ATTIC_TOKEN" ]; then
|
if [ -n "$ATTIC_CACHE" ]; then
|
||||||
nix build --no-link --print-out-paths -L \
|
nix build --no-link --print-out-paths -L \
|
||||||
.#attic-server-image \
|
.#attic-server-image \
|
||||||
.#attic-server-image-aarch64 \
|
.#attic-server-image-aarch64 \
|
||||||
|
|
21
flake.lock
generated
21
flake.lock
generated
|
@ -56,6 +56,26 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nix-github-actions": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729742964,
|
||||||
|
"narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nix-github-actions",
|
||||||
|
"rev": "e04df33f62cdcf93d73e9a04142464753a16db67",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nix-github-actions",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726042813,
|
"lastModified": 1726042813,
|
||||||
|
@ -93,6 +113,7 @@
|
||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
|
"nix-github-actions": "nix-github-actions",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nix-github-actions = {
|
||||||
|
url = "github:nix-community/nix-github-actions";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
url = "github:edolstra/flake-compat";
|
url = "github:edolstra/flake-compat";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
|
@ -29,6 +29,12 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
|
||||||
|
checks = {
|
||||||
|
inherit (self.checks) x86_64-linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
perSystem = { self', pkgs, config, system, ... }: let
|
perSystem = { self', pkgs, config, system, ... }: let
|
||||||
cfg = config.attic.integration-tests;
|
cfg = config.attic.integration-tests;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue