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 # lists the machines whose toplevel is in neither cache and the 75 # derivations needed by more than one of them (.github/ci-shared.sh). 76 # - shared: builds those once, so the machine jobs substitute them instead 77 # of each building them; skipped when there are none. 78 # - one job per listed machine, builds its toplevel by drv path on a lazy 79 # /nix/store (.github/lazy-store.sh): the paths it would substitute are 80 # only downloaded once a file in them is opened. 81 # 82 # Every job pushes what it added to the store to cache.lassul.us 83 # (.github/ci-build.sh), for deploys. 84 eval: 85 runs-on: ubuntu-latest 86 permissions: 87 contents: read 88 actions: read # hestia: detect evicted cache entries upfront 89 id-token: write # niks3 push 90 outputs: 91 matrix: ${{ steps.matrix.outputs.matrix }} 92 any-jobs: ${{ steps.matrix.outputs.any-jobs }} 93 manifest-version: ${{ steps.matrix.outputs.manifest-version }} 94 shared: ${{ steps.plan.outputs.shared }} 95 niks3: ${{ steps.tools.outputs.niks3 }} 96 lazy-store: ${{ steps.tools.outputs.lazy-store }} 97 steps: 98 - uses: actions/checkout@v4 99 - uses: cachix/install-nix-action@v31 100 with: 101 extra_nix_config: | 102 trusted-users = root runner 103 extra-substituters = https://cache.lassul.us 104 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 105 - uses: Mic92/hestia@v3 106 with: 107 upstream-cache-filter: true 108 upstream-cache-key-names: cache.nixos.org-1 cache.lassul.us-1 109 filter-drv-closures: true 110 # the niks3 client of all jobs and the lazy store of the machine jobs, 111 # the others substitute them; nix-eval-jobs from the flake's nixpkgs, 112 # which the flake evaluation fetches anyway 113 - id: tools 114 run: | 115 niks3=$(nix build --no-link --print-out-paths .#niks3) 116 lazy=$(nix build --no-link --print-out-paths .#lazy-store) 117 nej=$(nix build --no-link --print-out-paths --inputs-from . nixpkgs#nix-eval-jobs) 118 { 119 echo "niks3=$niks3" 120 echo "lazy-store=$lazy" 121 echo "nix-eval-jobs=$nej/bin/nix-eval-jobs" 122 } >> "$GITHUB_OUTPUT" 123 PATH=$niks3/bin:$PATH .github/niks3-push.sh "$niks3" "$lazy" 124 - id: matrix 125 uses: Mic92/hestia/matrix@v3 126 with: 127 flake: ".#ciToplevels" 128 nix-eval-jobs: "${{ steps.tools.outputs.nix-eval-jobs }} --workers 4 --max-memory-size 3072" 129 - env: 130 MATRIX: ${{ steps.matrix.outputs.matrix }} 131 run: | 132 echo "not cached: $(jq -r '[.include[].name] | join(" ")' <<<"$MATRIX")" | 133 tee -a "$GITHUB_STEP_SUMMARY" 134 # the derivations the shared job builds, none for a single machine 135 - id: plan 136 if: steps.matrix.outputs.any-jobs == 'true' 137 env: 138 MATRIX: ${{ steps.matrix.outputs.matrix }} 139 run: | 140 matrix=$RUNNER_TEMP/matrix.json 141 plans=$RUNNER_TEMP/plans 142 printf '%s' "$MATRIX" > "$matrix" 143 mkdir -p "$plans" 144 : > "$plans/shared.drvs" 145 if [ "$(jq '.include | length' "$matrix")" -ge 2 ]; then 146 .github/ci-shared.sh "$matrix" "$plans" 147 { 148 for name in $(jq -r '.include[].name' "$matrix"); do 149 echo "- $name: $(wc -l < "$plans/$name.drvs") derivations to build" 150 done 151 echo "- shared (needed by >= 2 machines): $(wc -l < "$plans/shared.drvs")" 152 sed -E 's|^/nix/store/[^-]+-(.*)\.drv$| \1|' "$plans/shared.drvs" 153 } | tee -a "$GITHUB_STEP_SUMMARY" 154 fi 155 if [ -s "$plans/shared.drvs" ]; then 156 echo "shared=true" >> "$GITHUB_OUTPUT" 157 fi 158 - if: steps.plan.outputs.shared == 'true' 159 uses: actions/upload-artifact@v4 160 with: 161 name: plans 162 path: ${{ runner.temp }}/plans/shared.drvs 163 164 shared: 165 needs: eval 166 if: needs.eval.outputs.shared == 'true' 167 runs-on: ubuntu-latest 168 permissions: 169 contents: read 170 actions: read # hestia: detect evicted cache entries upfront 171 id-token: write # niks3 push 172 outputs: 173 manifest-version: ${{ steps.build.outputs.manifest-version }} 174 steps: 175 - uses: actions/checkout@v4 176 - uses: cachix/install-nix-action@v31 177 with: 178 extra_nix_config: | 179 trusted-users = root runner 180 extra-substituters = https://cache.lassul.us 181 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 182 - uses: Mic92/hestia@v3 183 with: 184 upstream-cache-filter: true 185 upstream-cache-key-names: cache.nixos.org-1 cache.lassul.us-1 186 wait-manifest-version: ${{ needs.eval.outputs.manifest-version }} 187 - env: 188 NIKS3: ${{ needs.eval.outputs.niks3 }} 189 run: | 190 nix-store --realise "$NIKS3" 191 echo "$NIKS3/bin" >> "$GITHUB_PATH" 192 - uses: actions/download-artifact@v4 193 with: 194 name: plans 195 path: ${{ runner.temp }}/plans 196 - id: build 197 env: 198 EVAL_MANIFEST_VERSION: ${{ needs.eval.outputs.manifest-version }} 199 run: | 200 mapfile -t shared < "$RUNNER_TEMP/plans/shared.drvs" 201 "$HESTIA_BIN" prefetch "${shared[@]/%/^*}" 202 # a failed one fails the jobs of the machines that need it 203 .github/ci-build.sh "${shared[@]/%/^*}" || 204 echo "::warning::some shared derivations failed to build" 205 # upload now instead of in the post step, so the machine jobs can 206 # wait for the manifest version that contains the shared outputs 207 "$HESTIA_BIN" drain --socket "$HESTIA_SOCKET" 2>&1 | tee "$RUNNER_TEMP/drain.txt" 208 drained=$(sed -nE 's/.*; manifest m[0-9]+#([0-9]+)$/\1/p' "$RUNNER_TEMP/drain.txt") 209 echo "manifest-version=${drained:-$EVAL_MANIFEST_VERSION}" >> "$GITHUB_OUTPUT" 210 211 build: 212 needs: [eval, shared] 213 # also when the shared job was skipped: nothing to share 214 if: >- 215 !cancelled() && needs.eval.result == 'success' && needs.eval.outputs.any-jobs == 'true' 216 && (needs.shared.result == 'success' || needs.shared.result == 'skipped') 217 name: ${{ matrix.name }} 218 runs-on: ${{ matrix.os }} 219 permissions: 220 contents: read 221 actions: read # hestia: detect evicted cache entries upfront 222 id-token: write # niks3 push 223 strategy: 224 fail-fast: false 225 matrix: ${{ fromJSON(needs.eval.outputs.matrix) }} 226 steps: 227 - uses: actions/checkout@v4 228 - uses: cachix/install-nix-action@v31 229 with: 230 extra_nix_config: | 231 trusted-users = root runner 232 extra-substituters = https://cache.lassul.us 233 extra-trusted-public-keys = cache.lassul.us-1:aOMEO5TU6eLvhyPi0jmgjR2sVlGjMq3rK0MeACjTcQ0= 234 - uses: Mic92/hestia@v3 235 with: 236 upstream-cache-filter: true 237 upstream-cache-key-names: cache.nixos.org-1 cache.lassul.us-1 238 wait-manifest-version: ${{ needs.shared.outputs.manifest-version || needs.eval.outputs.manifest-version }} 239 - env: 240 NIKS3: ${{ needs.eval.outputs.niks3 }} 241 run: | 242 nix-store --realise "$NIKS3" 243 echo "$NIKS3/bin" >> "$GITHUB_PATH" 244 - name: build ${{ matrix.name }} 245 env: 246 INSTALLABLES: ${{ matrix.installables }} 247 LAZY_STORE: ${{ needs.eval.outputs.lazy-store }} 248 run: | 249 read -ra installables <<<"$INSTALLABLES" 250 "$HESTIA_BIN" prefetch "${installables[@]}" 251 .github/lazy-store.sh "${installables[@]}" 252 .github/ci-build.sh "${installables[@]}" 253 - name: lazy store log 254 if: always() 255 run: | 256 dir=$RUNNER_TEMP/lazy-store 257 if [ -s "$dir/stats.json" ]; then 258 jq -r '"\(.nar_count // 0) NARs fetched, \((.nar_bytes // 0) / 1048576 | floor) MiB"' "$dir/stats.json" 259 fi 260 cat "$dir/fuse.log" 2>/dev/null || true 261 262 # Fixed-name summary of the jobs above, the required status check for 263 # merging into master (the matrix job names change with the hosts). 264 # Skipped: no machine to build, or a job it needs failed. 265 ci: 266 needs: [list, check, outputs, eval, shared, build] 267 if: always() 268 runs-on: ubuntu-latest 269 steps: 270 - env: 271 RESULTS: ${{ join(needs.*.result, ' ') }} 272 run: | 273 echo "results: $RESULTS" 274 for r in $RESULTS; do 275 [ "$r" = success ] || [ "$r" = skipped ] || exit 1 276 done