ci: cancel superseded runs and trim the PR wheel matrix - #419
Conversation
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 reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
👋 Hey there! It looks like the changelog might need an update. Please take a moment to edit the
|
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"}, |
There was a problem hiding this comment.
We should at least keep the macos-15-intel image in the tests. Currently, x86 arch is not being tested for MacOS.
|
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 |
Why
pyqasmis 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: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:
macOS minutes went from 658 in July to 3,309 in August.
Two causes:
synchronizefires 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.What this changes
1. Concurrency guard
Superseded PR runs are cancelled. Pushes to
mainare never cancelled.2. Per-event matrix selection
pull_requestpushto main /workflow_dispatchmacOS jobs per PR run drop from 10 → 1.
Invariants preserved
mainand manual runs behave exactly as before.code-coveragejob consumes the artifact that specific entry uploads (if: matrix.os == 'macos-14' && matrix.python == 311). Dropping it would silently break coverage.release.ymlandpre-release.yml, which each carry their own complete matrix.main.ymlis 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
mainrather than on the PR — and still before any release, sincerelease.ymlbuilds the full matrix independently.If that feels too loose, the natural middle ground is adding
macos-14 / 3.14to the PR set to cover the newest Python on arm64; that's one extra macOS job instead of nine.