This repository has no description
0

Configure Feed

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

tools.ci-farm: build all machines on every push to master

+41 -19
+13 -9
.github/workflows/farm.yml
··· 12 12 workflow_dispatch: 13 13 inputs: 14 14 machines: 15 - description: NixOS machines to build, space separated 16 - default: ignavia neoprism green 15 + description: NixOS machines to build, space separated (empty for all) 16 + default: "" 17 17 push: 18 - paths: 19 - - .github/workflows/farm.yml 20 - - tools/ci-farm/** 18 + branches: [master] 21 19 22 20 permissions: 23 21 contents: read 24 22 id-token: write # niks3 push 25 23 actions: read # workers watch the farm job 26 24 27 - # The farm's iroh endpoint id is fixed, so only one run at a time. 25 + # The farm's iroh endpoint id is fixed, so only one run at a time; a newer 26 + # push replaces a running build. 28 27 concurrency: 29 28 group: farm 29 + cancel-in-progress: true 30 30 31 31 env: 32 32 # must match the worker matrix below 33 33 FARM_WORKERS: 2 34 - MACHINES: ${{ inputs.machines || 'ignavia neoprism green' }} 34 + MACHINES: ${{ inputs.machines }} 35 35 36 36 jobs: 37 37 farm: ··· 49 49 # a remembered miss (default: 1 h) fails the build instead. 50 50 narinfo-cache-negative-ttl = 0 51 51 - run: nix build -L .#ci-farm -o ci-farm 52 - - name: build ${{ env.MACHINES }} 52 + - name: build ${{ env.MACHINES || 'all machines' }} 53 53 env: 54 54 FARM_KEY: ${{ secrets.FARM_KEY }} 55 55 # MACHINES unquoted: one argument per machine 56 - run: ./ci-farm/bin/ci-farm farm $MACHINES 56 + run: | 57 + if [ -z "$MACHINES" ]; then 58 + MACHINES=$(nix eval --raw .#nixosConfigurations --apply "c: builtins.concatStringsSep \" \" (builtins.attrNames c)") 59 + fi 60 + ./ci-farm/bin/ci-farm farm $MACHINES 57 61 58 62 worker: 59 63 name: worker ${{ matrix.index }}
+28 -10
tools/ci-farm/ci-farm.sh
··· 105 105 wait_workers "$workers" 106 106 107 107 local store="grpc://127.0.0.1:50051?insecure=1&system=x86_64-linux" 108 - declare -A builds 108 + declare -A builds=() evals=() 109 + local failed=() 110 + build() { 111 + echo "ci-farm: $1: $2" 112 + "$NIX_WITH_PLUGIN" build --no-link --print-out-paths --store "$store" --eval-store auto "$2^*" 2>&1 | 113 + sed -u "s|^|[$1] |" & 114 + builds[$1]=$! 115 + } 116 + # Waits for one eval, then starts its build. 117 + eval_done() { 118 + local pid status=0 arg 119 + wait -n -p pid "${!evals[@]}" || status=$? 120 + arg=${evals[$pid]} 121 + unset "evals[$pid]" 122 + if [ "$status" -eq 0 ]; then 123 + build "$arg" "$(<"$state/$arg.drv")" 124 + else 125 + failed+=("$arg") 126 + fi 127 + } 109 128 for arg in "$@"; do 110 129 if [[ $arg == /nix/store/*.drv ]]; then 111 - drv=$arg 112 - else 113 - # One eval process per machine: all hosts at once don't fit in 16 GB. 114 - drv=$(nix eval --raw ".#nixosConfigurations.$arg.config.system.build.toplevel.drvPath") 130 + build "$arg" "$arg" 131 + continue 115 132 fi 116 - echo "ci-farm: $arg: $drv" 117 - "$NIX_WITH_PLUGIN" build --no-link --print-out-paths --store "$store" --eval-store auto "$drv^*" 2>&1 | 118 - sed -u "s|^|[$arg] |" & 119 - builds[$arg]=$! 133 + # One eval process per machine, at most 3 at a time: all hosts at once 134 + # don't fit in 16 GB. 135 + while [ ${#evals[@]} -ge 3 ]; do eval_done; done 136 + nix eval --raw ".#nixosConfigurations.$arg.config.system.build.toplevel.drvPath" >"$state/$arg.drv" & 137 + evals[$!]=$arg 120 138 done 139 + while [ ${#evals[@]} -gt 0 ]; do eval_done; done 121 140 122 - local failed=() 123 141 for arg in "${!builds[@]}"; do 124 142 wait "${builds[$arg]}" || failed+=("$arg") 125 143 done