Skip to content

fix(ci): 只在 PR 与 main 上运行矩阵,避免重复触发导致 macOS job 排队被取消 - #45

Merged
m9rco merged 1 commit into
mainfrom
fix/ci-duplicate-matrix-20261201
Nov 30, 2026
Merged

m9rco merged 1 commit into
mainfrom
fix/ci-duplicate-matrix-20261201

Conversation

@m9rco

@m9rco m9rco commented Nov 30, 2026

Copy link
Copy Markdown
Owner

修复 CI 偶发失败(macOS job 排队被取消)

现象:2026-11-30 的每日扫描中,分支 push(46456160907)与 main push(46456304324)两个 CI run 标为 failure,但同一 commit 的 pull_request run(46456252462)全绿。

根因:不是代码错误。失败 run 里被取消的两个 job(Test (macos-latest, Python 3.13)、npm shell (macos-latest, Node 22))runner_id: 0、steps 为空、无日志——从未分配到 runner,排队 16-20 分钟后被系统取消,job cancelled 使整个 run 判为 failure。on.push 没有分支限制,扫描流程在 45 秒内连续产生「功能分支 push → PR → 合并后 main push」三次 CI run,每次 3 个 macOS job,共 9 个并发 macOS job 挤占账户并发额度。

已用 gh run rerun --failed 复验:main push run 的第 2 次 attempt 在 52 秒内 11/11 job 全绿,确认为瞬时 runner 容量问题。

改动:on.push 增加 branches: [main]。功能分支的 push 不再触发整套矩阵,pull_request 仍完整验证分支,合并后的 main push 仍验证最终状态。同一 commit 的 CI 从 2 次降为 1 次,三连跑降为 2 次且互不重叠,消除 macOS 排队拥堵。concurrency、timeout-minutes、矩阵覆盖(3 OS × 2 Python、4 个 npm job)均不变,测试强度不降低。

验证:YAML 解析通过;本 PR 的 pull_request 事件应当只产生 1 个 CI run(无功能分支 push run),合并后的 main push 再产生 1 个,两者均需全绿。

A feature-branch push and the PR opened from the same commit ran the 11-job matrix twice; combined with the merge push this queued nine macOS jobs inside a minute and two queued jobs per push run were cancelled for lack of a runner (runner_id 0, zero steps), marking otherwise-green runs as failure. PR events still validate the branch and a push to main still validates the merged result.
@m9rco
m9rco merged commit 8148d58 into main Nov 30, 2026
13 checks passed
@m9rco
m9rco deleted the fix/ci-duplicate-matrix-20261201 branch November 30, 2026 23:44
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