A fork of attic a self-hostable Nix Binary Cache server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #190 from zhaofengli/gha-integration-tests

Move integration tests to GitHub Actions

authored by

Zhaofeng Li and committed by
GitHub
0fe1b1cd 2b05b7d9

+176 -2
+144 -2
.github/workflows/build.yml
··· 6 6 REGISTRY: ghcr.io 7 7 IMAGE_NAME: ghcr.io/${{ github.repository }} 8 8 jobs: 9 + build: 10 + strategy: 11 + matrix: 12 + os: 13 + - ubuntu-latest 14 + - macos-latest 15 + runs-on: ${{ matrix.os }} 16 + steps: 17 + - uses: actions/checkout@v4.1.7 18 + 19 + - name: Install current Bash on macOS 20 + if: runner.os == 'macOS' 21 + run: | 22 + command -v brew && brew install bash || true 23 + 24 + - uses: DeterminateSystems/nix-installer-action@v14 25 + continue-on-error: true # Self-hosted runners already have Nix installed 26 + 27 + - name: Install Attic 28 + run: | 29 + if ! command -v attic &> /dev/null; then 30 + ./.github/install-attic-ci.sh 31 + fi 32 + 33 + - name: Configure Attic 34 + continue-on-error: true 35 + run: | 36 + : "${ATTIC_SERVER:=https://staging.attic.rs/}" 37 + : "${ATTIC_CACHE:=attic-ci}" 38 + echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV 39 + export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 40 + attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN" 41 + attic use "$ATTIC_CACHE" 42 + env: 43 + ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }} 44 + ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} 45 + ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} 46 + 47 + - name: Cache dev shell 48 + run: | 49 + .ci/cache-shell.sh 50 + system=$(nix-instantiate --eval -E 'builtins.currentSystem') 51 + echo system=$system >>$GITHUB_ENV 52 + 53 + # TODO: Abstract all of this out, and use `attic push --stdin` (requires #232) 54 + - name: Build packages 55 + run: | 56 + export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 57 + nix build --no-link --print-out-paths -L \ 58 + .#attic \ 59 + .#attic-client \ 60 + .#attic-server \ 61 + | if [ -n "$ATTIC_CACHE" ]; then 62 + xargs attic push "ci:$ATTIC_CACHE" 63 + else 64 + cat 65 + fi 66 + 9 67 tests: 10 68 strategy: 11 69 matrix: ··· 67 125 - name: Push build artifacts 68 126 run: | 69 127 export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 70 - if [ -n "$ATTIC_TOKEN" ]; then 128 + if [ -n "$ATTIC_CACHE" ]; then 71 129 nix build --no-link --print-out-paths -L \ 72 130 .#internalMatrix."$system".\"${{ matrix.nix }}\".attic-tests \ 73 131 .#internalMatrix."$system".\"${{ matrix.nix }}\".cargoArtifacts \ 74 132 | xargs attic push "ci:$ATTIC_CACHE" 75 133 fi 76 134 135 + nix-matrix: 136 + runs-on: ubuntu-latest 137 + outputs: 138 + matrix: ${{ steps.set-matrix.outputs.matrix }} 139 + steps: 140 + - uses: actions/checkout@v4.1.7 141 + - uses: DeterminateSystems/nix-installer-action@v14 142 + continue-on-error: true # Self-hosted runners already have Nix installed 143 + 144 + - name: Install Attic 145 + run: | 146 + if ! command -v attic &> /dev/null; then 147 + ./.github/install-attic-ci.sh 148 + fi 149 + 150 + - name: Configure Attic 151 + continue-on-error: true 152 + run: | 153 + : "${ATTIC_SERVER:=https://staging.attic.rs/}" 154 + : "${ATTIC_CACHE:=attic-ci}" 155 + echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV 156 + export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 157 + attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN" 158 + attic use "$ATTIC_CACHE" 159 + env: 160 + ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }} 161 + ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} 162 + ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} 163 + - id: set-matrix 164 + name: Generate Nix Matrix 165 + run: | 166 + set -Eeu 167 + matrix="$(nix eval --json '.#githubActions.matrix')" 168 + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" 169 + 170 + nix-matrix-job: 171 + name: ${{ matrix.name }} 172 + runs-on: ${{ matrix.os }} 173 + needs: 174 + - build 175 + - nix-matrix 176 + strategy: 177 + matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} 178 + steps: 179 + - uses: actions/checkout@v4.1.7 180 + 181 + - name: Install current Bash on macOS 182 + if: runner.os == 'macOS' 183 + run: | 184 + command -v brew && brew install bash || true 185 + 186 + - uses: DeterminateSystems/nix-installer-action@v14 187 + continue-on-error: true # Self-hosted runners already have Nix installed 188 + 189 + - name: Install Attic 190 + run: | 191 + if ! command -v attic &> /dev/null; then 192 + ./.github/install-attic-ci.sh 193 + fi 194 + 195 + - name: Configure Attic 196 + continue-on-error: true 197 + run: | 198 + : "${ATTIC_SERVER:=https://staging.attic.rs/}" 199 + : "${ATTIC_CACHE:=attic-ci}" 200 + echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV 201 + export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 202 + attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN" 203 + attic use "$ATTIC_CACHE" 204 + env: 205 + ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }} 206 + ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} 207 + ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} 208 + 209 + - name: Build ${{ matrix.attr }} 210 + run: | 211 + nix build --no-link --print-out-paths -L '.#${{ matrix.attr }}' \ 212 + | if [ -n "$ATTIC_CACHE" ]; then 213 + xargs attic push "ci:$ATTIC_CACHE" 214 + else 215 + cat 216 + fi 217 + 77 218 image: 78 219 runs-on: ubuntu-latest 79 220 if: github.event_name == 'push' 80 221 needs: 222 + - build 81 223 - tests 82 224 permissions: 83 225 contents: read ··· 152 294 - name: Push build artifacts 153 295 run: | 154 296 export PATH=$HOME/.nix-profile/bin:$PATH # FIXME 155 - if [ -n "$ATTIC_TOKEN" ]; then 297 + if [ -n "$ATTIC_CACHE" ]; then 156 298 nix build --no-link --print-out-paths -L \ 157 299 .#attic-server-image \ 158 300 .#attic-server-image-aarch64 \
+21
flake.lock
··· 56 56 "type": "github" 57 57 } 58 58 }, 59 + "nix-github-actions": { 60 + "inputs": { 61 + "nixpkgs": [ 62 + "nixpkgs" 63 + ] 64 + }, 65 + "locked": { 66 + "lastModified": 1729742964, 67 + "narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=", 68 + "owner": "nix-community", 69 + "repo": "nix-github-actions", 70 + "rev": "e04df33f62cdcf93d73e9a04142464753a16db67", 71 + "type": "github" 72 + }, 73 + "original": { 74 + "owner": "nix-community", 75 + "repo": "nix-github-actions", 76 + "type": "github" 77 + } 78 + }, 59 79 "nixpkgs": { 60 80 "locked": { 61 81 "lastModified": 1726042813, ··· 93 113 "crane": "crane", 94 114 "flake-compat": "flake-compat", 95 115 "flake-parts": "flake-parts", 116 + "nix-github-actions": "nix-github-actions", 96 117 "nixpkgs": "nixpkgs", 97 118 "nixpkgs-stable": "nixpkgs-stable" 98 119 }
+5
flake.nix
··· 15 15 inputs.nixpkgs.follows = "nixpkgs"; 16 16 }; 17 17 18 + nix-github-actions = { 19 + url = "github:nix-community/nix-github-actions"; 20 + inputs.nixpkgs.follows = "nixpkgs"; 21 + }; 22 + 18 23 flake-compat = { 19 24 url = "github:edolstra/flake-compat"; 20 25 flake = false;
+6
flake/integration-tests.nix
··· 29 29 }; 30 30 31 31 config = { 32 + flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix { 33 + checks = { 34 + inherit (self.checks) x86_64-linux; 35 + }; 36 + }; 37 + 32 38 perSystem = { self', pkgs, config, system, ... }: let 33 39 cfg = config.attic.integration-tests; 34 40