This repository has no description
0

Configure Feed

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

.github: only master pushes cancel farm runs, update-pkgs retries cancelled verifications

+55 -38
+6 -3
.github/workflows/farm.yml
··· 22 22 id-token: write # niks3 push 23 23 actions: read # workers watch the farm job 24 24 25 - # The farm's iroh endpoint id is fixed, so only one run at a time; a newer 26 - # push replaces a running build. 25 + # The farm's iroh endpoint id is fixed, so only one run at a time. A push to 26 + # master replaces a running build (an older master state or an update-pkgs 27 + # verification, which retries). Dispatched runs (update-pkgs verifying a PR, 28 + # manual runs) never cancel a running build; they wait as the group's pending 29 + # run. 27 30 concurrency: 28 31 group: farm 29 - cancel-in-progress: true 32 + cancel-in-progress: ${{ github.event_name == 'push' }} 30 33 31 34 env: 32 35 # must match the worker matrix below
+49 -35
.github/workflows/update-pkgs.yml
··· 208 208 git config user.name "github-actions[bot]" 209 209 git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 210 210 211 - # farm run for a head commit: "<id> <status> <conclusion>" or empty 211 + # Farm run for a head commit: "<id> <status> <conclusion>" or empty. 212 + # Cancelled runs don't count: a push to master replaced them. 212 213 farm_run() { 213 214 gh run list -R "$repo" -w farm.yml -b "$1" -e workflow_dispatch -L 20 \ 214 215 --json databaseId,headSha,status,conclusion \ 215 - --jq "[.[] | select(.headSha == \"$2\")][0] // empty | \"\(.databaseId) \(.status) \(.conclusion)\"" 216 + --jq "[.[] | select(.headSha == \"$2\" and .conclusion != \"cancelled\")][0] // empty 217 + | \"\(.databaseId) \(.status) \(.conclusion)\"" 218 + } 219 + 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". 223 + verify_pr() { 224 + local pr=$1 branch=$2 sha run id 225 + git fetch -q origin master "$branch" 226 + git switch -q -C "$branch" "origin/$branch" 227 + if ! git rebase -q origin/master >&2; then 228 + git rebase --abort 229 + echo "conflict -" 230 + return 231 + fi 232 + sha=$(git rev-parse HEAD) 233 + if [ "$sha" != "$(git rev-parse "origin/$branch")" ]; then 234 + git push -q --force-with-lease="$branch:origin/$branch" origin "$branch" >&2 235 + 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 244 + 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" 216 253 } 217 254 218 255 # flake.lock first: every package PR is rebased onto the master it ··· 225 262 | sort_by(.headRefName != "update/flake-lock") | .[] 226 263 | "\(.number) \(.headRefName)"') 227 264 228 - while read -r pr branch; do 265 + while read -r pr branch <&3; do 229 266 [ -n "$pr" ] || continue 230 267 echo "::group::#$pr $branch" 231 - git fetch -q origin master "$branch" 232 - git switch -q -C "$branch" "origin/$branch" 233 - if ! git rebase -q origin/master; then 234 - git rebase --abort 235 - echo "#$pr: conflicts with master, left for the next run" 236 - echo "::endgroup::" 237 - continue 238 - fi 239 - sha=$(git rev-parse HEAD) 240 - if [ "$sha" != "$(git rev-parse "origin/$branch")" ]; then 241 - git push -q --force-with-lease="$branch:origin/$branch" origin "$branch" 242 - fi 243 - 244 - run=$(farm_run "$branch" "$sha") 245 - if [ -z "$run" ]; then 246 - gh workflow run farm.yml -R "$repo" --ref "$branch" 247 - for _ in $(seq 60); do 248 - sleep 10 249 - run=$(farm_run "$branch" "$sha") 250 - [ -n "$run" ] && break 251 - done 252 - fi 253 - id=${run%% *} 254 - if [ -z "$id" ]; then 255 - echo "#$pr: farm run did not start" 256 - echo "::endgroup::" 257 - continue 258 - fi 259 - gh run watch "$id" -R "$repo" --interval 60 >/dev/null || true 260 - conclusion=$(gh run view "$id" -R "$repo" --json conclusion --jq .conclusion) 261 - echo "#$pr: farm run $id on $sha: $conclusion" 268 + # A push to master cancels a running verification; master has 269 + # moved then, so rebase and build again. 270 + for attempt in 1 2 3; do 271 + read -r conclusion sha < <(verify_pr "$pr" "$branch") 272 + [ "$conclusion" = cancelled ] || break 273 + echo "#$pr: farm run cancelled by a push to master (attempt $attempt)" 274 + done 275 + echo "#$pr: $conclusion" 262 276 if [ "$conclusion" = success ] && [ "$AUTOMERGE" = true ]; then 263 277 gh pr merge "$pr" -R "$repo" --squash --delete-branch --match-head-commit "$sha" 264 278 merged=$((merged + 1)) 265 279 fi 266 280 echo "::endgroup::" 267 - done <<<"$prs" 281 + done 3<<<"$prs" 268 282 269 283 echo "merged update PRs: $merged" 270 284 if [ "$merged" -gt 0 ]; then