This repository has no description
0

Configure Feed

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

update-pkgs: run ci.yml on PRs before merging, for the master ruleset

+43 -29
+43 -29
.github/workflows/update-pkgs.yml
··· 9 9 # lock: `nix flake update`, pushed as update/flake-lock with its own PR. 10 10 # 2. verify: for every open update/* PR, one after another (flake.lock 11 11 # first), rebase it onto the current master, build all machines with the 12 - # farm (farm.yml) on that commit and squash-merge the PR only if the run 13 - # succeeded. A commit that already has a finished farm run is not built 14 - # again, so a failing PR stays open until its branch or master changes. 12 + # farm (farm.yml) and run ci.yml on that commit, and squash-merge the PR 13 + # only if both succeeded (master's ruleset requires the ci check). A 14 + # commit that already has finished runs is not checked again, so a 15 + # failing PR stays open until its branch or master changes. 15 16 # 16 17 # One PR at a time because the farm has a fixed endpoint and runs in a single 17 18 # concurrency group, where GitHub keeps only one pending run. ··· 208 209 git config user.name "github-actions[bot]" 209 210 git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 210 211 211 - # Farm run for a head commit: "<id> <status> <conclusion>" or empty. 212 - # Cancelled runs don't count: a push to master replaced them. 213 - farm_run() { 214 - gh run list -R "$repo" -w farm.yml -b "$1" -e workflow_dispatch -L 20 \ 212 + # Dispatched run of a workflow for a head commit: "<id> <status> 213 + # <conclusion>" or empty. Cancelled runs don't count: a push to 214 + # master replaced them. 215 + dispatched_run() { 216 + gh run list -R "$repo" -w "$1" -b "$2" -e workflow_dispatch -L 20 \ 215 217 --json databaseId,headSha,status,conclusion \ 216 - --jq "[.[] | select(.headSha == \"$2\" and .conclusion != \"cancelled\")][0] // empty 218 + --jq "[.[] | select(.headSha == \"$3\" and .conclusion != \"cancelled\")][0] // empty 217 219 | \"\(.databaseId) \(.status) \(.conclusion)\"" 218 220 } 219 221 220 - # Rebase a PR onto master, farm-build that commit and wait for the 221 - # result. Prints "<conclusion> <sha>"; conclusion is the farm run's, 222 - # or "conflict" / "nostart". 222 + # Dispatch a workflow on a branch unless its head commit already 223 + # has a run, wait for it and print its conclusion, or "nostart". 224 + run_workflow() { 225 + local workflow=$1 branch=$2 sha=$3 run id 226 + run=$(dispatched_run "$workflow" "$branch" "$sha") 227 + if [ -z "$run" ]; then 228 + gh workflow run "$workflow" -R "$repo" --ref "$branch" >&2 229 + for _ in $(seq 60); do 230 + sleep 10 231 + run=$(dispatched_run "$workflow" "$branch" "$sha") 232 + [ -n "$run" ] && break 233 + done 234 + fi 235 + id=${run%% *} 236 + if [ -z "$id" ]; then 237 + echo nostart 238 + return 239 + fi 240 + echo "$workflow run $id on $sha" >&2 241 + gh run watch "$id" -R "$repo" --interval 60 >/dev/null 2>&1 </dev/null || true 242 + gh run view "$id" -R "$repo" --json conclusion --jq .conclusion 243 + } 244 + 245 + # Rebase a PR branch onto master, farm-build that commit and run 246 + # ci.yml on it. Prints "<conclusion> <sha>"; conclusion is the farm 247 + # run's, then ci's as "ci-<conclusion>", or "conflict" / "nostart". 223 248 verify_pr() { 224 - local pr=$1 branch=$2 sha run id 249 + local branch=$1 sha conclusion 225 250 git fetch -q origin master "$branch" 226 251 git switch -q -C "$branch" "origin/$branch" 227 252 if ! git rebase -q origin/master >&2; then ··· 233 258 if [ "$sha" != "$(git rev-parse "origin/$branch")" ]; then 234 259 git push -q --force-with-lease="$branch:origin/$branch" origin "$branch" >&2 235 260 fi 236 - run=$(farm_run "$branch" "$sha") 237 - if [ -z "$run" ]; then 238 - gh workflow run farm.yml -R "$repo" --ref "$branch" >&2 239 - for _ in $(seq 60); do 240 - sleep 10 241 - run=$(farm_run "$branch" "$sha") 242 - [ -n "$run" ] && break 243 - done 261 + conclusion=$(run_workflow farm.yml "$branch" "$sha") 262 + if [ "$conclusion" = success ]; then 263 + conclusion=$(run_workflow ci.yml "$branch" "$sha") 264 + [ "$conclusion" = success ] || conclusion="ci-$conclusion" 244 265 fi 245 - id=${run%% *} 246 - if [ -z "$id" ]; then 247 - echo "nostart $sha" 248 - return 249 - fi 250 - echo "#$pr: farm run $id on $sha" >&2 251 - gh run watch "$id" -R "$repo" --interval 60 >/dev/null 2>&1 </dev/null || true 252 - echo "$(gh run view "$id" -R "$repo" --json conclusion --jq .conclusion) $sha" 266 + echo "$conclusion $sha" 253 267 } 254 268 255 269 # flake.lock first: every package PR is rebased onto the master it ··· 268 282 # A push to master cancels a running verification; master has 269 283 # moved then, so rebase and build again. 270 284 for attempt in 1 2 3; do 271 - read -r conclusion sha < <(verify_pr "$pr" "$branch") 285 + read -r conclusion sha < <(verify_pr "$branch") 272 286 [ "$conclusion" = cancelled ] || break 273 287 echo "#$pr: farm run cancelled by a push to master (attempt $attempt)" 274 288 done