Skip to content

CI/CD - Cancel superseded PR runs and skip draft/merge jobs - #906

Merged
Hongtao Zhang (polarG) merged 6 commits into
mainfrom
gusui-msft/ci-pr-scheduling-hygiene-20261126
Nov 30, 2026
Merged

Hongtao Zhang (polarG) merged 6 commits into
mainfrom
gusui-msft/ci-pr-scheduling-hygiene-20261126

Conversation

@gusui-msft

@gusui-msft gusui-msft commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description
Reduce avoidable runner contention and wasted CI runs across GitHub Actions and Azure Pipelines without changing any image definitions, build targets, or required check names:

  • Cancel superseded pull-request runs when new commits arrive. Image builds and CodeQL are also cancelled when a pull request is converted to draft, merged or closed. In-progress main and release/* runs always finish publishing images and registry build caches.
  • Skip heavy validation on draft pull requests (image builds, CodeQL, and the Azure unit and integration tests) and run it automatically when a pull request is marked ready for review. The fast required checks Spelling check, CPP code lint and docs-build keep running on drafts.
  • Skip the docker-merge manifest jobs on pull requests, where image push and manifest creation are already skipped.

Major Revision

  • Add the same workflow-level concurrency block to .github/workflows/{build-image,codeql-analysis,gh-pages,lint}.yml. Pull-request runs are grouped per pull request with cancel-in-progress: true. Push, release, schedule and dispatch runs are grouped per event and ref with cancel-in-progress: false: an in-progress run always finishes, a newer run for the same ref waits, and only the latest waiting run is kept. Trade-off: on main, the next image build starts only after the current run finishes, including its slowest job (rocm6.4 has taken about 7.5 h).
  • Give build-image.yml and codeql-analysis.yml the same pull_request.types (opened, synchronize, reopened, ready_for_review, converted_to_draft, closed) and the same job guard, !github.event.pull_request.draft && github.event.action != 'closed'. Their jobs skip draft pull requests, and merging or closing a pull request (both arrive as closed) cancels its in-progress runs; for example, rocm6.4 from Benchmarks: Support compact core ranges in CPU STREAM #894 kept a self-hosted runner for about 4.75 h after merge. lint.yml and gh-pages.yml keep the default types and run on drafts.
  • Add explicit pr triggers to .azure-pipelines/{cpu-unit-test,cuda-unit-test,ansible-integration-test}.yml with drafts: false and autoCancel: true. PR validation targets main and release/*, the same branches as the GitHub workflows; pull requests into other branches, such as stacked pull requests into a feature branch, are no longer validated by Azure Pipelines. To validate a draft on demand, mark it ready for review or queue the pipeline manually against refs/pull/<N>/merge.

Minor Revision

  • Guard docker-merge in .github/workflows/build-image.yml with && github.event_name != 'pull_request' so pull requests no longer queue four self-hosted Buildx setup/teardown jobs whose merge and push steps are all skipped.

Validation

  • actionlint 1.7.12 on the four workflows reports no new findings; its only report (matrix.extra_args is undefined) is also present on main.
  • Parsed all seven files and asserted the intended triggers, job guards, concurrency blocks and Azure pr blocks; verified LF line endings and git diff --check.
  • The job guards rely on pull request fields evaluating to empty strings for push, release, dispatch and schedule events. Enumerating every trigger, action and draft state shows they make the same decisions as the explicit github.event_name != 'pull_request' || (...) form. The concurrency group uses the pull request number rather than github.ref, so the closed run for a merge, whose GITHUB_REF is the target branch, cannot cancel the build on that branch.
  • While in draft (head 6b402e79), Build Image and CodeQL were skipped within seconds, Lint (Spelling check, CPP code lint) and GitHub Pages (docs-build) ran and passed, and no Azure Pipelines run was queued. After syncing main (head 8746188a), marking it ready for review started the full image matrix, CodeQL and the Azure unit tests. The closed path is not exercised before merge.

Cancel superseded pull-request workflow runs while allowing active main/release builds to finish updating registry caches and folding queued commits. Skip PR validation on draft pull requests (re-triggering automatically on ready_for_review) across GitHub Actions and Azure Pipelines, and skip the no-op docker-merge jobs on pull requests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

CI gating depends on external settings unavailable in the checkout, requiring verification that Azure triggers allow ready-for-review validation and branch protection does not require docker-merge checks now skipped on PRs.

No open issues 🎉

What changed in this PR

This PR reduces unnecessary CI work in GitHub Actions and Azure Pipelines while preserving image definitions, build targets, and required check names.

Changes:

  • Adds workflow concurrency to cancel superseded PR runs while allowing active non-PR runs to finish.
  • Skips automatic draft PR validation and enables validation when PRs become ready for review.
  • Skips image manifest merge jobs on PRs and explicitly configures Azure Pipelines PR cancellation and branch filters.
File Description
.github/​workflows/​lint.yml Adds PR lifecycle triggers, concurrency, and draft guards for lint jobs.
.github/​workflows/​gh-pages.yml Adds concurrency and draft-aware documentation validation.
.github/​workflows/​codeql-analysis.yml Adds concurrency and draft guards for both analysis jobs.
.github/​workflows/​build-image.yml Adds concurrency, skips draft builds, and skips PR manifest merge jobs.
.azure-pipelines/​cuda-unit-test.yml Configures automatic PR cancellation, draft exclusion, and target branches.
.azure-pipelines/​cpu-unit-test.yml Configures automatic PR cancellation, draft exclusion, and target branches.
.azure-pipelines/​ansible-integration-test.yml Configures automatic PR cancellation, draft exclusion, and target branches.

Review effort: Balanced

Cancel in-progress Build Image runs when a pull request is merged or closed; otherwise non-required jobs such as rocm6.4 keep a self-hosted runner after merge (about 4.75 h on #894). Keep spelling, C++ lint and docs-build running on drafts: they are fast GitHub-hosted required checks, and catching their failures early avoids restarting image builds after ready_for_review. Restore Azure PR validation for every target branch so stacked pull requests keep unit tests, and document the push-run ordering trade-off next to the concurrency block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The workflow description incorrectly promises commit-order image publication, while GitHub concurrency only serializes runs within each event/ref group without guaranteeing commit order.

1 open issue

Review effort: Balanced

Comment thread .github/workflows/build-image.yml Resolved
GitHub processes runs in a concurrency group first-in-first-out by the time each starts waiting and does not guarantee dispatch order, so describe one-at-a-time execution per event and ref instead of promising commit-order image publication. Addresses Copilot review feedback on #906.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The reported draft checks do not cover ready-for-review queuing or close/merge cancellation of active self-hosted image builds, so GitHub event and Azure pipeline trigger behavior still needs live validation.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Use main and release/* as the pull request target branches for the Azure pipelines, matching every GitHub workflow. Shorten the build-image concurrency comment, and drop the explicit event check from the draft and closed job guards: push, release, dispatch and schedule events have no pull request fields, which evaluate to empty strings, so the shorter conditions make the same decisions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The CI workflow changes have no active review issues.

No open issues 🎉

Review effort: Balanced

Give CodeQL the same pull_request activity types and job guard as the image build, so both workflows that skip drafts also cancel in-progress runs when a pull request is merged or closed. Drop the build-image-only comment so all four concurrency blocks are identical.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Untested PR lifecycle transitions require live GitHub validation to confirm image-build cancellation when all jobs are skipped, isolation from target-branch publishing, and ready-for-review requeuing of Azure required checks.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:10
@gusui-msft
gusui-msft marked this pull request as ready for review November 27, 2026 00:10
@gusui-msft
gusui-msft requested a review from a team as a code owner November 27, 2026 00:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Reported validation covers only initial drafts, leaving closed/merged build cancellation, protection of main/release publishing, and ready_for_review Azure validation unconfirmed in live CI.

No open issues 🎉

Review effort: Balanced

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.58%. Comparing base (db2255c) to head (8746188).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #906   +/-   ##
=======================================
  Coverage   86.58%   86.58%           
=======================================
  Files         107      107           
  Lines        8419     8419           
=======================================
  Hits         7290     7290           
  Misses       1129     1129           
Flag Coverage Δ
cpu-python3.10-unit-test 71.83% <ø> (ø)
cpu-python3.12-unit-test 71.83% <ø> (ø)
cpu-python3.7-unit-test 71.30% <ø> (ø)
cuda-unit-test 84.63% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@polarG
Hongtao Zhang (polarG) merged commit f91ecbc into main Nov 30, 2026
30 of 31 checks passed
@polarG
Hongtao Zhang (polarG) deleted the gusui-msft/ci-pr-scheduling-hygiene-20261126 branch November 30, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants