Skip to content

ci: cancel PR runs only for new commits - #397

Merged
uniqueg merged 2 commits into
devfrom
ci/gate-cancel-new-commits
Nov 11, 2026
Merged

uniqueg merged 2 commits into
devfrom
ci/gate-cancel-new-commits

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Only a new head commit of a pull request now cancels its CI runs in progress: cancel-in-progress of the workflow-level concurrency block in .github/workflows/ci.yml is true only for pull_request with action synchronize on the first attempt, as in "Cancelled runs" of actions/gate/README.md in elixir-cloud-aai/.github (elixir-cloud-aai/.github#71):

cancel-in-progress: >-
  ${{ github.event_name == 'pull_request'
  && github.event.action == 'synchronize'
  && github.run_attempt == 1 }}

Before, a newer run on the same commit (e.g. for editing the description, also by Sourcery, or marking the pull request ready) cancelled the run in progress, and its failed CI passed was then the newest result on the commit, which blocked the merge (elixir-cloud-aai/.github#70). Runs for other actions, and reruns, now wait for the run in progress instead; a waiting run that is replaced starts no job, so it leaves no check. The gate keeps if: always(), so a needed job that failed or was cancelled still fails it. This pull request's own runs already use the new rule.

The concurrency groups are unchanged (runs for pushes and for edits that leave the title unchanged keep groups of their own); the comment above the block now describes the new rule.

tests/test_workflows.py gets test_ci_concurrency, which asserts the new expression and the whole group expression, in which runs for pushes have a group of their own (written first; it failed before the change).

Part of elixir-cloud-aai/.github#73

Verification

  • pre-commit run --files on .github/workflows/ci.yml and the test file (all hooks of the repository): passed.
  • pytest tests/test_workflows.py -k concurrency: failed before the change, passes after it.
  • pytest -W ignore::DeprecationWarning: 753 passed, 1 failed (tests/test_chart.py::test_config_change_restarts_app: the chart tests (tests/test_chart.py, and the chart examples in tests/test_config_examples.py) could not run locally, as Helm isn't installed here; CI runs them).
  • CI: all checks passed, including CI passed, on f816972.
  • Sourcery: 1 thread (the test checked the push part of the group as a substring): fixed in f816972, the test asserts the whole group expression; resolved.

Light lane: changes only the CI workflow's concurrency settings and a test of them (no secrets, permissions or release workflow); I reviewed the diff myself.

Declined review findings

None.

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

A newer run on the same commit (e.g. for an edit of the description)
cancelled the run in progress, and its failed gate then blocked the
merge. Only the first attempt of a run for a pull request's
synchronize action now cancels runs in progress, as in "Cancelled
runs" of actions/gate/README.md in elixir-cloud-aai/.github.

Part of elixir-cloud-aai/.github#73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@uniqueg
uniqueg marked this pull request as ready for review November 10, 2026 20:21
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e499725) to head (f816972).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #397   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         3343      3343           
=========================================
  Hits          3343      3343           

☔ 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.

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Restrict cancellation of in-progress workflow runs to first-attempt pull-request synchronize events while preserving separate concurrency groups for pushes and title-preserving edits.

  • .github/workflows/ci.yml L30-37, L45-48

Tests

Assert the cancellation condition and the complete concurrency-group expression to ensure pushes retain their own groups.

  • tests/test_workflows.py L74-100

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_workflows.py" line_range="92" />
<code_context>
+        " && github.run_attempt == 1 }}"
+    )
+    group = " ".join(concurrency["group"].split())
+    assert "github.event_name == 'push' && github.sha ||" in group
+
+
</code_context>
<issue_to_address>
**Push grouping regression passes**

When the group expression contains a truthy shared-group branch for pushes before the asserted text, `test_ci_concurrency` only checks that the push-and-SHA text appears somewhere in `group`. A preceding truthy push branch that assigns every push the same group would still pass this assertion, even though pushes would no longer get separate groups and queued runs could be dropped.

Assert the complete normalized group expression, or otherwise verify that distinct push SHAs produce distinct concurrency groups.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/test_workflows.py:92


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test_workflows.py Resolved
A substring check of the push branch would pass even if an earlier
branch of the expression gave all pushes one group (Sourcery).

Part of elixir-cloud-aai/.github#73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 9c89950 into dev Nov 11, 2026
44 checks passed
@uniqueg
uniqueg deleted the ci/gate-cancel-new-commits branch November 11, 2026 09:48
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.

1 participant