From 50da77abc4b2d2b0c218525b01fee085c7fff8df Mon Sep 17 00:00:00 2001 From: Irakli Kourtis Date: Tue, 20 Oct 2026 14:09:49 +0000 Subject: [PATCH] CI: a run another label starts reports the commit's real result as ci (#3596) The merge queue reads the required ci check from the newest run of a commit. Adding any label but approved-for-ci starts a run whose jobs all skip, and its ci job was skipped too (as 'ci (ignored label)'), so a pull request that had passed could not enter the queue (#1850, #3182, #3252). On such a run the ci job now waits for the commit's other runs to finish and passes only when the newest one that ran its checks passed. Claude-Session: https://claude.ai/code/session_01QWhMwdqJYQKQq8RCLSL1LT Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ec8a8b4a..8d6d2f3f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,9 @@ # result and runs the repository checks. Merge groups, the nightly run and Run workflow are not # pull requests and always run the full suite. # GitHub cannot filter `labeled` events by label name, so any other label starts a run whose jobs -# are all skipped; it gets its own concurrency group (below) so it never cancels the real run. +# are all skipped; it gets its own concurrency group (below) so it never cancels the real run. Its +# `ci` job still runs and reports the commit's real result (see the `ci` job): the merge queue +# reads `ci` from the newest run of a commit, so a run without it would block a PR that passed. # Cross-compilation is opt-in through Run workflow; release builds remain in release.yml. # Every Linux job runs on Blacksmith's Ubuntu 24.04 runners (blacksmith-vcpu-ubuntu-2404), sized # per job: 16 vCPU for Build tests, Clippy and the merge queue's test shards, 8 for compiles, the @@ -694,14 +696,45 @@ jobs: # Preserve the existing check name for branch protection, including docs-only PRs. ci: - # On the skipped run another label starts, this job is named differently, so that skipped job - # can never stand in for the required `ci` check of the pull request's real run. - name: ${{ github.event.action == 'labeled' && github.event.label.name != 'approved-for-ci' && 'ci (ignored label)' || 'ci' }} + # On a run another label starts (every other job skipped), this job reports the result of the + # commit's real run instead: the merge queue reads `ci` from the newest run of a commit, so a + # run without a passing `ci` would block a pull request that passed (#1850, #3182, #3252). + name: ci needs: [changes, checks, quick-compile, clippy, build-tests, tests, doc-tests, oracle, windows-fxc, windows-startup] - if: always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci') + if: always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) runs-on: blacksmith-2vcpu-ubuntu-2404 + permissions: + contents: read + # To read the commit's other runs of this workflow. + actions: read steps: + - name: Report the commit's real result (a run another label started) + if: github.event.action == 'labeled' && github.event.label.name != 'approved-for-ci' + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + SHA: ${{ github.event.pull_request.head.sha }} + RUN_ID: ${{ github.run_id }} + run: | + # The other runs of ci.yml for this commit. While one is still going, wait for it (at + # most 90 minutes); then pass only when the newest one that ran its checks passed. + deadline=$((SECONDS + 5400)) + while :; do + runs=$(gh api "repos/$REPO/actions/workflows/ci.yml/runs?head_sha=$SHA&event=pull_request&per_page=100" \ + --jq "[.workflow_runs[] | select(.id != $RUN_ID)]") + pending=$(jq '[.[] | select(.status != "completed")] | length' <<<"$runs") + if [ "$pending" -eq 0 ] || [ "$SECONDS" -ge "$deadline" ]; then break; fi + echo "Waiting for $pending run(s) of this commit to finish." + sleep 30 + done + # Runs with every job skipped (labels, before this job reported) are not a result. + latest=$(jq -r '[.[] | select(.status == "completed" and .conclusion != "skipped")] + | sort_by(.created_at) | last | "\(.conclusion) \(.html_url)"' <<<"$runs") + echo "The commit's latest run: $latest" + echo "A label started this run: \`ci\` repeats the commit's latest result ($latest)." >> "$GITHUB_STEP_SUMMARY" + test "${latest%% *}" = success - name: Verify required checks + if: github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' env: CHANGES: ${{ needs.changes.result }} CHECKS: ${{ needs.checks.result }}