Skip to content

ci: cancel outdated PR workflow runs on newer commits - #15309

Merged
lqiu96 merged 2 commits into
googleapis:mainfrom
lqiu96:ci/cancel-in-progress-workflows
Dec 1, 2026
Merged

lqiu96 merged 2 commits into
googleapis:mainfrom
lqiu96:ci/cancel-in-progress-workflows

Conversation

@lqiu96

@lqiu96 lqiu96 commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Configure PR-scoped concurrency across PR workflows so superseded GitHub Actions runs are cancelled immediately when new commits are pushed, freeing up runner capacity.

Summary of changes

  • Add workflow-level concurrency to 33 PR workflows (excluding changelog_generation.yaml, which commits back to Release Please PRs):
    concurrency:
      group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
      cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  • Update ci.yaml and formatter-version-check.yaml to use the same concurrency block:
    • Key groups on github.event.pull_request.number || github.run_id instead of github.head_ref so fork PRs with identical branch names (such as main or fix) do not cancel each other.
    • Scope cancel-in-progress strictly to pull_request events so push to main, schedule, and workflow_dispatch runs each get a unique github.run_id group and are never cancelled or blocked.
  • Update conditional-required-check (required job) in 7 workflows (ci.yaml, google-auth-library-java-ci.yaml, java-bigquery-jdbc-ci.yaml, java-spanner-jdbc-ci.yaml, java-storage-nio-ci.yaml, sdk-platform-java-downstream.yaml, and showcase.yaml):
    • Replace if: ${{ always() }} with if: ${{ !cancelled() }} so cancelled runs stop without provisioning a new ubuntu-22.04 runner and conclude as cancelled instead of success.
    • Include contains(needs.*.result, 'cancelled') in the failure check step so a timed-out or cancelled upstream job cannot report a green check.

Intentionally excluded

  • changelog_generation.yaml is left unchanged because its changelog-generation job only runs when github.event.sender.login == 'release-please[bot]'. Enabling cancel-in-progress: true there could allow a subsequent non-bot push to cancel an in-flight Release Please run while skipping changelog generation.
  • Non-PR workflows (release, push to main, schedule, and workflow_dispatch-only workflows) are untouched.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@lqiu96
lqiu96 marked this pull request as ready for review December 1, 2026 17:34
@lqiu96
lqiu96 requested review from a team as code owners December 1, 2026 17:34
@lqiu96
lqiu96 merged commit 4a6c9af into googleapis:main Dec 1, 2026
221 of 222 checks passed
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.

2 participants