Skip to content

ci: cancel superseded runs and trim the PR wheel matrix - #419

Open
kanavsetia wants to merge 1 commit into
mainfrom
ci/trim-wheel-matrix-on-prs
Open

ci: cancel superseded runs and trim the PR wheel matrix#419
kanavsetia wants to merge 1 commit into
mainfrom
ci/trim-wheel-matrix-on-prs

Conversation

@kanavsetia

Copy link
Copy Markdown

Why

pyqasm is the largest single contributor to the org's GitHub Actions bill. In the August billing period it accounted for ~$219 of ~$407 gross Actions spend — and almost all of it is macOS:

$196.29   3,166 min @ $0.062/min   Actions macOS 3-core    (~10x the Linux rate)
$ 22.65   2,265 min @ $0.010/min   Actions Windows

The effect shows up clearly in the org-wide effective rate — August used 36% fewer Actions minutes than July but cost more, because the per-minute rate nearly doubled:

Month Minutes Gross $/min
June 38,530 $247.52 $0.00642
July 55,083 $371.60 $0.00675
Aug (MTD) 34,998 $407.32 $0.01164

macOS minutes went from 658 in July to 3,309 in August.

Two causes:

  1. No concurrency guard. synchronize fires on every push to an open PR, so each push started another full 20-entry wheel matrix while the previous one kept running to completion.
  2. Every PR built the complete matrix — 5 Python versions × Windows / Linux / macOS x86_64 / macOS arm64, i.e. 10 macOS jobs per run — even for a one-line docs change.

What this changes

1. Concurrency guard

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

Superseded PR runs are cancelled. Pushes to main are never cancelled.

2. Per-event matrix selection

Event Entries Composition
pull_request 7 Linux × 3.10–3.14, macOS arm64 × 3.11, Windows × 3.11
push to main / workflow_dispatch 20 unchanged — the full original matrix

macOS jobs per PR run drop from 10 → 1.

Invariants preserved

  • The full 20-entry matrix is byte-for-byte the same set as the previous inline list (verified by diffing the parsed entries), so main and manual runs behave exactly as before.
  • macOS arm64 / 3.11 is retained in the PR set on purpose — the code-coverage job consumes the artifact that specific entry uploads (if: matrix.os == 'macos-14' && matrix.python == 311). Dropping it would silently break coverage.
  • Published wheels are unaffected. PyPI wheels are built by release.yml and pre-release.yml, which each carry their own complete matrix. main.yml is CI validation only.

Tradeoff

PRs no longer validate wheel builds on Windows 3.10/3.12/3.13/3.14, macOS x86_64 at all, or macOS arm64 outside 3.11. A platform-specific build break in those combinations would surface on merge to main rather than on the PR — and still before any release, since release.yml builds the full matrix independently.

If that feels too loose, the natural middle ground is adding macos-14 / 3.14 to the PR set to cover the newest Python on arm64; that's one extra macOS job instead of nine.

CI is the largest single line in the org's GitHub Actions bill. In the
August billing period pyqasm accounted for ~$219 of ~$407 gross Actions
spend, almost all of it macOS: 3,166 macOS minutes at $0.062/min (about
10x the Linux rate) plus 2,265 Windows minutes at $0.010/min.

Two things drove that:

1. No concurrency guard. `synchronize` fires on every push to an open
   PR, so each push started another full 20-entry wheel matrix while the
   previous one ran to completion.

2. Every PR built the complete matrix -- 5 Python versions across
   Windows, Linux, macOS x86_64 and macOS arm64, i.e. 10 macOS jobs per
   run -- even for a one-line change.

This adds a concurrency group that cancels superseded pull_request runs
(pushes to main are never cancelled), and selects the matrix per event.
Pull requests build 7 entries: Linux on all five supported Pythons,
macOS arm64 on 3.11, and Windows on 3.11. Pushes to main and manual
workflow_dispatch runs still build all 20.

Two invariants are preserved deliberately:

- The full 20-entry matrix is unchanged from the previous inline list,
  so main and manual runs behave exactly as before.
- macOS arm64 / 3.11 stays in the PR set because the code-coverage job
  consumes the artifact that entry uploads.

Wheels published to PyPI are built by release.yml and pre-release.yml,
which each carry their own complete matrix, so this job is CI validation
only and the reduction does not change what ships.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@argus-eye

argus-eye Bot commented Aug 26, 2026

Copy link
Copy Markdown

Argus review

Auto-review is off for this repo. Tick the box below to run a review on this PR.

  • Trigger Argus review

Estimated cost

  • Files changed: 1
  • Diff lines (±): 156
  • Historical avg: ~243.6k tokens · ~$0.95 · across last 10 review(s)

Tip: you can also comment @argus-eye review at any time.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 97a19a6b-efad-48c5-86d3-a5c02b755e34

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey there! It looks like the changelog might need an update.

Please take a moment to edit the CHANGELOG.md with:

  • A brief, one-to-two sentence summary of your changes.
  • A link back to this PR for reference.
  • (Optional) A small working example if you've added new features.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

{"os":"ubuntu-latest","python":312,"platform_id":"manylinux_x86_64","manylinux_image":"manylinux_2_28"},
{"os":"ubuntu-latest","python":313,"platform_id":"manylinux_x86_64","manylinux_image":"manylinux_2_28"},
{"os":"ubuntu-latest","python":314,"platform_id":"manylinux_x86_64","manylinux_image":"manylinux_2_28"},
{"os":"macos-14","python":311,"platform_id":"macosx_arm64"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should at least keep the macos-15-intel image in the tests. Currently, x86 arch is not being tested for MacOS.

@TheGupta2012

Copy link
Copy Markdown
Member

Thanks for catching this @kanavsetia . However, embedding the choice matrix in a string might not be the best path from a maintenance standpoint. Can you figure out if there's a better approach to cleanly switch the python and os matrix based on whether we are running in a PR or from main?

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