Skip to content

ci: split lint jobs and cut motd into thirteen segments - #63

Merged
LucaLin233 merged 2 commits into
mainfrom
luno/ci-lint-split-motd13
Oct 24, 2026
Merged

LucaLin233 merged 2 commits into
mainfrom
luno/ci-lint-split-motd13

Conversation

@LucaLin233

Copy link
Copy Markdown
Owner

Summary

main 的 Shell tests 墙钟 92 s 的两个剩余长尾——ShellCheck 单作业 73 s、Debian motd-a 段 0–3 的 55/75 s——各切一刀:lint 拆成生产组与测试组两个作业,motd 由 11 段重切成 13 段(仍 3 个作业,5/4/4)。前置作业从 19 增到正好 20,用满 Free 的 20 并发,仍不排队。

预期收益:ShellCheck 75 s → 约 60 s(取两组较慢者);Debian motd-a 由 ~75 s 降到 ~50–55 s;总墙钟目标 ~75 s 量级。

Scope

包含:

  • .github/workflows/shell-tests.yml:lint 作业只跑生产组(--severity=warning,保留步骤名 Run ShellCheck);新增 lint-tests(name ShellCheck (tests),步骤 Run ShellCheck tests)只跑 tests/*.sh(--severity=error)。两个作业各自保留 -n1 -P4 逐文件四路并行、set -o pipefail 与 status 语义,枚举失败同样 rc=1。聚合作业 ubuntu 改为 needs: [lint, lint-tests, ubuntu-tests],三个 result 都必须 success。
  • motd 矩阵(Ubuntu 与 Debian 两处):segments: 13,segment_set 为 0 1 2 3 4 / 5 6 7 8 / 9 10 11 12。
  • tests/test-motd.sh:11 → 13 段,只在顶层语句边界切,测试逻辑与循环体不动。旧段 2 在 pending_phase 与 pending_kind 之间切成「信号 + pending_phase」和「pending_kind + journal/tamper/symlink-target/native_id」;旧段 3 在 SIGKILL 矩阵与后续子 shell 之间切开。其余守卫整体后移两位,最终 0..12 各一次。
  • tests/run.sh:[test-motd.sh]=13;TEST_SEGMENTS 词法上限到 13,单段下标上限到 12。
  • tests/test-shards.sh:矩阵 token 词法、motd 13 段的子集/拒绝/非法 token 用例同步;保留双位数段按自身执行的用例(9 10 11 12)。
  • tests/test-lint-coverage.sh:从「一个 step 内两组」改写为双 step 契约——两个 step 各自被完整提取、各自恰好一次 -n1 -P4、severity 分别为 warning/error、互不选对方文件;每个 step 独立运行并跟随自身组的退出码与文件集合;枚举失败各自 rc=1 且不产生该组记录;新增门禁断言 ubuntu 的 needs 覆盖两个 lint 作业并要求每个依赖结果都被断言,同时锁住两个必需检查名。
  • README.md:段数(13 段 5/4/4)、TEST_SEGMENTS/TEST_SEGMENT_SET 语义、lint 拆作业后的实际语义与失败面订正。

明确不做:不动 push / push-worker / cloudflare / other 的分段;不改两个必需检查名 Ubuntu 24.04 lint and tests、Debian 13 tests;不新增第三个必需检查。

Validation

  • 双 OS CI:20 个前置作业无排队,motd 13 段逐段执行,PASS 多重集与基线一致(motd 648/653、cloudflare 312、push-worker 303),两个必需检查通过。
  • 契约测试:bash tests/test-shards.sh、bash tests/test-lint-coverage.sh 均 rc=0(见下方 CI 与本地记录)。
  • 改动脚本 bash -n 通过;测试组 shellcheck -x --severity=error 对改动文件无告警。
  • 分段冒烟:TEST_SEGMENTS=13 TEST_SEGMENT_SET="2" / "3" 各自独立跑完。
  • 具体耗时与 PASS 汇总见本 PR 评论。

Risks

  • 并发正好 20,无余量:再加任何前置作业就会排队、墙钟反升(上一批 21 作业时实测 109 s)。后续扩项必须先减。
  • lint 拆成两个作业意味着每个作业各自下载一次 pinned ShellCheck(约 2.6 MB),多一次固定开销;换来的是一组失败不再拖累另一组的诊断与墙钟。
  • 分段点仍是文本契约测试保护(守卫计数与矩阵一一对应),矩阵结构改写会 fail-closed。
  • 性能数字随 runner 负载波动,单次实测不构成承诺。

Rollback

git revert 本 PR 即可整体回退到 11 段 / 单 lint 作业(无数据迁移、无外部状态);回退后前置作业回到 19。

Run ShellCheck as two jobs (production warning, tests error) so one group cannot hide the other, and re-cut motd into thirteen segments over the same three shards. With nine test shards per OS plus the two lint jobs the plan is exactly the twenty-job concurrency.
@LucaLin233

Copy link
Copy Markdown
Owner Author

CI run 40128915551,结论全绿。

总墙钟 83 s(上一批 main 92 s)。20 个前置作业全部在 +2/+3 s 启动,无排队。

作业 墙钟
ShellCheck 14 s
ShellCheck (tests) 69 s
Ubuntu motd-a / motd-b / motd-c 55 / 52 / 60 s
Debian motd-a / motd-b / motd-c 71 / 59 / 55 s
Ubuntu cloudflare-a / cloudflare-b 57 / 53 s
Debian cloudflare-a / cloudflare-b 73 / 54 s
Ubuntu push-worker-a / push-worker-b 55 / 53 s
Debian push-worker-a / push-worker-b 59 / 58 s
Ubuntu push / Debian push 75 / 72 s
Ubuntu other / Debian other 48 / 57 s
Ubuntu 24.04 lint and tests / Debian 13 tests 3 / 3 s

Debian motd 13 段([segment N/13] elapsed):

段 0 1 2 3 4 5 6 7 8 9 10 11 12
秒 50 51 34 44 36 30 32 41 36 40 29 24 31

两个新切出来的段(旧段 2 的两半)为 34 s 与 44 s;旧段 3 的两半为 36 s 与 30 s。均未达 45 s,切分两半比值 1.29:1,未触发调整重推。仍 ≥ 45 s 的是未被本 PR 触碰的旧段 0/1(50/51 s,基线 46/48 s;每作业并发段数由 4 增到 5,单段略慢)。

PASS 多重集与基线一致:motd 648(Ubuntu)/ 653(Debian),cloudflare 312,push-worker 303(两个 OS 各自求和)。

两个必需检查 Ubuntu 24.04 lint and tests、Debian 13 tests 均为 success;聚合门禁日志显示三个 result 都被断言(LINT_RESULT / LINT_TESTS_RESULT / TEST_RESULT)。

待观察:lint 拆作业只把 73 s 降到 69 s(预期约 60 s 未达到)。瓶颈是测试组里的 tests/test-motd.sh,生产组本身只需 14 s;若要继续压缩,需要单独处理这个大文件的 ShellCheck 成本(例如按文件再分作业),但那会打破 20 并发的零余量。

The ubuntu gate assertion only counted `= success` lines against the needs
entries, so a swapped binding (LINT_TESTS_RESULT reading needs.lint.result)
or a relaxed `&&` still passed while the gate could go green on a failed job.
Require the exact literal env and assertion block with grep -Fxq: every
variable must read its own needs entry and all three tests must be chained.

Existing needs-set and line-count checks are unchanged.
@LucaLin233
LucaLin233 merged commit bca1a67 into main Oct 24, 2026
22 checks passed
@LucaLin233
LucaLin233 deleted the luno/ci-lint-split-motd13 branch October 24, 2026 20:54
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