This repository has no description
0

Configure Feed

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

1name: CI 2 3on: 4 push: 5 branches: [master] 6 pull_request: 7 workflow_dispatch: 8 9# A newer run for the same ref replaces a running one. 10concurrency: 11 group: ci-${{ github.ref }} 12 cancel-in-progress: true 13 14# One job per check shows failing checks in the run overview, the same for 15# the NixOS machines, see the eval job. 16jobs: 17 list: 18 runs-on: ubuntu-latest 19 outputs: 20 checks: ${{ steps.list.outputs.checks }} 21 steps: 22 - uses: actions/checkout@v4 23 with: 24 # Fetch all history for git-based operations 25 fetch-depth: 0 26 27 - uses: cachix/install-nix-action@v31 28 29 - id: list 30 run: | 31 checks=$(nix eval --json .#checks.x86_64-linux --apply builtins.attrNames) 32 echo "checks=$checks" >> "$GITHUB_OUTPUT" 33 34 check: 35 needs: list 36 name: ${{ matrix.check }} 37 runs-on: ubuntu-latest 38 strategy: 39 fail-fast: false 40 matrix: 41 check: ${{ fromJSON(needs.list.outputs.checks) }} 42 steps: 43 - uses: actions/checkout@v4 44 with: 45 # Fetch all history for git-based operations 46 fetch-depth: 0 47 48 - uses: cachix/install-nix-action@v31 49 50 - run: nix build -L --no-link '.#checks.x86_64-linux.${{ matrix.check }}' 51 52 outputs: 53 name: packages and devShells 54 runs-on: ubuntu-latest 55 steps: 56 - uses: actions/checkout@v4 57 with: 58 # Fetch all history for git-based operations 59 fetch-depth: 0 60 61 - uses: cachix/install-nix-action@v31 62 63 - run: | 64 for output in packages devShells; do 65 echo "$output:" 66 # shellcheck disable=SC2016 # ${...} is Nix interpolation 67 nix eval --raw ".#$output.x86_64-linux" --apply 'xs: builtins.deepSeq (builtins.mapAttrs (_: x: x.drvPath) xs) "${toString (builtins.length (builtins.attrNames xs))} evaluated\n"' 68 done 69 70 # The NixOS machines, built on plain runners with hestia (the GitHub Actions 71 # cache) as binary cache next to cache.lassul.us: 72 # 73 # - eval: evaluates ciToplevels once, uploads the drv closures to hestia 74 # and lists the machines whose toplevel is in neither cache. 75 # - shared: builds the derivations needed by more than one of them once, 76 # so the machine jobs substitute them instead of each building them. 77 # - one job per listed machine, builds its toplevel by drv path. 78 # 79 # Every job pushes what it added to the store to cache.lassul.us 80 # (.github/ci-build.sh), for deploys. 81 eval: 82 runs-on: ubuntu-latest 83 permissions: 84 contents: read 85 actions: read # hestia: detect evicted cache entries upfront 86 id-token: write # niks3 push 87 outputs: 88 matrix: ${{ steps.matrix.outputs.matrix }} 89 any-jobs: ${{ steps.matrix.outputs.any-jobs }} 90 manifest-version: ${{ steps.matrix.outputs.manifest-version }} 91 niks3: ${{ steps.niks3.outputs.path }} 92 steps: 93 - uses: actions/checkout@v4 94 - uses: cachix/install-nix-action@v31 95 with: 96 extra_nix_config: | 97 trusted-users = root runner 98 extra-substituters = https://cache.lassul.us 99 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 100 - uses: Mic92/hestia@v3 101 with: 102 upstream-cache-filter: true 103 filter-drv-closures: true 104 # the niks3 client of all jobs, the others substitute it 105 - id: niks3 106 run: | 107 niks3=$(nix build --no-link --print-out-paths .#niks3) 108 echo "path=$niks3" >> "$GITHUB_OUTPUT" 109 PATH=$niks3/bin:$PATH .github/niks3-push.sh "$niks3" 110 - id: matrix 111 uses: Mic92/hestia/matrix@v3 112 with: 113 flake: ".#ciToplevels" 114 nix-eval-jobs: "nix run nixpkgs#nix-eval-jobs -- --workers 4 --max-memory-size 3072" 115 - env: 116 MATRIX: ${{ steps.matrix.outputs.matrix }} 117 run: | 118 echo "not cached: $(jq -r '[.include[].name] | join(" ")' <<<"$MATRIX")" | 119 tee -a "$GITHUB_STEP_SUMMARY" 120 121 shared: 122 needs: eval 123 if: needs.eval.outputs.any-jobs == 'true' 124 runs-on: ubuntu-latest 125 permissions: 126 contents: read 127 actions: read # hestia: detect evicted cache entries upfront 128 id-token: write # niks3 push 129 outputs: 130 manifest-version: ${{ steps.build.outputs.manifest-version }} 131 steps: 132 - uses: actions/checkout@v4 133 - uses: cachix/install-nix-action@v31 134 with: 135 extra_nix_config: | 136 trusted-users = root runner 137 extra-substituters = https://cache.lassul.us 138 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 139 - uses: Mic92/hestia@v3 140 with: 141 upstream-cache-filter: true 142 wait-manifest-version: ${{ needs.eval.outputs.manifest-version }} 143 - env: 144 NIKS3: ${{ needs.eval.outputs.niks3 }} 145 run: | 146 nix-store --realise "$NIKS3" 147 echo "$NIKS3/bin" >> "$GITHUB_PATH" 148 - id: build 149 env: 150 MATRIX: ${{ needs.eval.outputs.matrix }} 151 EVAL_MANIFEST_VERSION: ${{ needs.eval.outputs.manifest-version }} 152 run: | 153 matrix=$RUNNER_TEMP/matrix.json 154 plans=$RUNNER_TEMP/plans 155 printf '%s' "$MATRIX" > "$matrix" 156 read -ra installables <<<"$(jq -r '[.include[].installables] | join(" ")' "$matrix")" 157 "$HESTIA_BIN" prefetch "${installables[@]}" 158 .github/ci-shared.sh "$matrix" "$plans" 159 mapfile -t shared < "$plans/shared.drvs" 160 version=$EVAL_MANIFEST_VERSION 161 if [ "${#shared[@]}" -gt 0 ]; then 162 # a failed one fails the jobs of the machines that need it 163 .github/ci-build.sh "${shared[@]/%/^*}" || 164 echo "::warning::some shared derivations failed to build" 165 # upload now instead of in the post step, so the machine jobs can 166 # wait for the manifest version that contains the shared outputs 167 "$HESTIA_BIN" drain --socket "$HESTIA_SOCKET" 2>&1 | tee "$RUNNER_TEMP/drain.txt" 168 drained=$(sed -nE 's/.*; manifest m[0-9]+#([0-9]+)$/\1/p' "$RUNNER_TEMP/drain.txt") 169 version=${drained:-$version} 170 fi 171 echo "manifest-version=$version" >> "$GITHUB_OUTPUT" 172 { 173 for name in $(jq -r '.include[].name' "$matrix"); do 174 echo "- $name: $(wc -l < "$plans/$name.drvs") derivations to build" 175 done 176 echo "- shared (needed by >= 2 machines): ${#shared[@]}" 177 printf '%s\n' "${shared[@]}" | sed -E 's|^/nix/store/[^-]+-(.*)\.drv$| \1|' 178 } | tee -a "$GITHUB_STEP_SUMMARY" 179 180 build: 181 needs: [eval, shared] 182 if: needs.eval.outputs.any-jobs == 'true' 183 name: ${{ matrix.name }} 184 runs-on: ${{ matrix.os }} 185 permissions: 186 contents: read 187 actions: read # hestia: detect evicted cache entries upfront 188 id-token: write # niks3 push 189 strategy: 190 fail-fast: false 191 matrix: ${{ fromJSON(needs.eval.outputs.matrix) }} 192 steps: 193 - uses: actions/checkout@v4 194 - uses: cachix/install-nix-action@v31 195 with: 196 extra_nix_config: | 197 trusted-users = root runner 198 extra-substituters = https://cache.lassul.us 199 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 200 - uses: Mic92/hestia@v3 201 with: 202 upstream-cache-filter: true 203 wait-manifest-version: ${{ needs.shared.outputs.manifest-version }} 204 - env: 205 NIKS3: ${{ needs.eval.outputs.niks3 }} 206 run: | 207 nix-store --realise "$NIKS3" 208 echo "$NIKS3/bin" >> "$GITHUB_PATH" 209 - name: build ${{ matrix.name }} 210 env: 211 INSTALLABLES: ${{ matrix.installables }} 212 run: | 213 read -ra installables <<<"$INSTALLABLES" 214 "$HESTIA_BIN" prefetch "${installables[@]}" 215 .github/ci-build.sh "${installables[@]}" 216 217 # Fixed-name summary of the jobs above, the required status check for 218 # merging into master (the matrix job names change with the hosts). 219 # Skipped: no machine to build, or a job it needs failed. 220 ci: 221 needs: [list, check, outputs, eval, shared, build] 222 if: always() 223 runs-on: ubuntu-latest 224 steps: 225 - env: 226 RESULTS: ${{ join(needs.*.result, ' ') }} 227 run: | 228 echo "results: $RESULTS" 229 for r in $RESULTS; do 230 [ "$r" = success ] || [ "$r" = skipped ] || exit 1 231 done