Skip to content

Commit 8b2012c

Browse files
authored
fix(ci): 分片数要数腿,不是数 job —— #184 把 65 个成员跑成了 29 个 (#186)
`Plan the shards` 用平台的矩阵条目数当分片数: linux:$(jq -r '[.include[]|select(.platform=="linux")]|length' ...) 在 #184 之前这两个数恰好相等,所以一直是对的。#184 给 linux 加了第二条工具链 腿之后不再相等:平台发 2 x 3 = 6 个条目,而切分仍然是 3 路,每个条目带的 shard 是 0..2。于是 plan 按 6 路切,job 只消费 0/1/2 —— 分到 3/4/5 的成员 一个都没跑。 65 个成员实际只跑了 29 个,而且是**静默**的:一个从未被分配的成员,和一个跑 过并通过的成员,在 CI 界面上长得一模一样。丢掉的里面有 ffmpeg、opencv-module 及其两个 feature 成员、catch2-v2、catch2-main、openssl —— 正是那条新腿被加进 来要测的东西。#184 全绿,但它想验证的路径一次都没执行。 改成读 `.shards`,也就是 emit() 已经写进每个条目、job 自己也在用 (matrix.shards)的那个值。plan 和消费方从此读同一个数,而不是两个碰巧相等 的数。 macos / windows 不受影响也不需要改:它们仍是单腿,条目数正好等于分片数 —— 这正是这个 bug 只咬 linux 的原因,也是它能在 review 里活下来的原因。 验证:拿 #184 那次运行的真实 matrix.json 跑 jq,linux 6 → 3,macos / windows 维持 2;plan_shards 三片合计从 29 回到 65/65,上面点名的成员全部归位。
1 parent 798a524 commit 8b2012c

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/validate.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,24 @@ jobs:
519519
{
520520
printf '{'
521521
first=1
522-
for spec in linux:$(jq -r '[.include[]|select(.platform=="linux")]|length' /tmp/matrix.json) \
523-
macos:$(jq -r '[.include[]|select(.platform=="macos")]|length' /tmp/matrix.json) \
524-
windows:$(jq -r '[.include[]|select(.platform=="windows")]|length' /tmp/matrix.json); do
522+
# `.shards`, NOT the number of matrix entries.
523+
#
524+
# These stopped being the same number the moment linux grew a
525+
# second toolchain leg: the platform emits 2 x 3 = 6 entries while
526+
# the split is still 3 ways, and every entry carries shard 0..2.
527+
# Planning 6 ways and consuming three of them dropped 36 of 65
528+
# members on the floor — silently, because a member that is never
529+
# assigned is indistinguishable from one that passed. `ffmpeg`,
530+
# `opencv-module*`, `catch2-v2` and `openssl` were among them, on
531+
# the very run that added the leg meant to test them.
532+
#
533+
# `.shards` is the value emit() already wrote per entry and the
534+
# same one the job reads for its own `matrix.shards`, so plan and
535+
# consumer now read one number instead of two that agreed by
536+
# accident.
537+
for spec in linux:$(jq -r 'first(.include[]|select(.platform=="linux")).shards' /tmp/matrix.json) \
538+
macos:$(jq -r 'first(.include[]|select(.platform=="macos")).shards' /tmp/matrix.json) \
539+
windows:$(jq -r 'first(.include[]|select(.platform=="windows")).shards' /tmp/matrix.json); do
525540
p=${spec%%:*}; n=${spec##*:}
526541
[ "$first" = 1 ] || printf ','
527542
first=0

0 commit comments

Comments
 (0)