Skip to content

Commit 8c44dac

Browse files
authored
test kit and CI: a command has the time its case has left; the pr tier's gate judges what it runs; the unit shards follow the longest shard (#998)
1 parent db4d82e commit 8c44dac

10 files changed

Lines changed: 108 additions & 28 deletions

File tree

‎.agents/docs/2026-11-20-test-architecture-upgrade-design.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,27 @@ doctest 适配器(5.14)、依赖的调试信息(5.15)。boost-m 自己
985985
给出(`take_refused`),`other` 同时记入面的记录。拒绝 `system`、工具链命令的参数错误、`self config` 与
986986
`doctor` 的提示写死 gcc 16.1.0;改为读取内建表中本机的首次运行,`doctor` 的提示改为
987987
`mcpp toolchain install --target <triple>`。
988+
17. **发布之后:命令的时限与 `pr` 档的门禁(运行 44937152470,`pr` 档的两个分片)。** `sets/985` 为每个系统打包的一步在第 10 分钟被
989+
结束,所在套件陈述 45 分钟而远未用尽;同一分片的 `sets`、`images`、`stack` 同时运行,`sets` 用时 2140 s,三个分片
990+
的运行中为 1162 s。原因是 5.8 的一项没有实现:mtest 0.11.1 使命令不超过用例余下的时间,kit 却仍以十分钟为每条命令
991+
的缺省,两者取小。此前 1033 与 955 各自把一条命令提高到 30 分钟,是同一缺口的两次绕行。kit 改为:命令不陈述时限时取
992+
用例余下的时间(`time_left()`),没有任何作用域陈述时限时取十分钟;两处提高删除,`images` 按测量陈述套件的时间
993+
(30 分钟;两个分片中 1102 s,三个分片中 707 s,运行的缺省为 1200 s)。
994+
同一运行的门禁另有一项与改动无关的失败:面的账本列出 14 项没有通过的用例,均只由 `full` 档的作业或用例用到(Windows
995+
的 `coff-def`、构建图内部调用的 `dyndep --split-module` 与 `link-output --aside`、只在某些行上到达的原因标记)。需求
996+
由运行组中通过的用例满足,`pr` 档只运行改动影响的作业与用例,于是每次 `pr` 运行的门禁都失败。账本是全部用例的性质,
997+
改由运行全部用例的集合判定:mtest 0.11.3 的门禁只在这样的集合中判定账本,其他集合判定失败与预算并注明未判定账本;
998+
`ci.yml` 以运行的集合调用门禁(`gate --set`)。新增面的项的拉取请求以 `ci:full` 确认它有通过的用例(贡献规程)。
999+
18. **发布之后:单元分片的数目(main 的运行 44945453323,`full` 档的两个分片)。** 单元分片的数目此前取 main 上一次
1000+
运行中各程序用时之和,除以一个分片的四个工作进程在 30 分钟内的工作量。三个分片的运行 44930053323(三个分片分别用时
1001+
1236、834、1438 s)由此得出两个分片;两个分片分别用时 2544 与 2432 s,`trees` 用尽它陈述的 40 分钟(三个分片中为
1002+
1369 s),`sets`、`images`、`stack` 在同一分片中同时运行;本拉取请求的 `pr` 运行同为两个分片,用时 2099 与
1003+
1429 s,`trees` 为 1981 s,两次之差在 runner 的处理器之间(5.9)。用时之和除以工作进程数,假定四个工作进程始终各有程序
1004+
可运行,且程序的用时不随同时运行的程序变化;openkal 的程序在机器的一份预算中并行构建,分片越少,同时运行的越多,
1005+
各自越慢,一个分片的时间由其中最长的程序与同时运行的程序决定。分片数改为取 main 上一次运行的分片数 N 与其中最长
1006+
分片的用时 W,N × W 按每片 30 分钟折算(`ci-unit.yml`;两次运行都得出三个分片)。N 与 W 从各分片作业保存的存储
1007+
读出:作业的存储经导入保存为 mtest 的运行记录,其中没有分片;历史中另有子系统作业的运行。套件陈述的时间不变:它们界定
1008+
挂起,在三个分片中留有余量。
9881009

9891010
## 15. 子方案
9901011

‎.agents/skills/mcpp-contributing/SKILL.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ gh run view <run-id> --log-failed # 查看失败日志
214214
直接显示在 PR 的检查中。不要另外以 `gh workflow run ci.yml --ref <分支>` 启动一次运行,也不要取消 PR 的运行:
215215
分支上的运行不出现在 PR 的检查中,两次运行还会同时占用 runner。
216216

217+
面的账本(`mcpp emit surface` 的每一项由通过的用例用到或豁免)是全部用例的性质,只由 `full` 的门禁判定;`pr` 的门禁
218+
判定失败与预算,并注明没有判定账本(mtest 0.11.3)。新增命令、选项、清单键或原因标记的 PR 以 `ci:full` 确认它有
219+
通过的用例。
220+
217221
```bash
218222
gh pr edit <pr-number> --add-label ci:full # 先打标签
219223
git push # 再推送:这次运行跑 full

‎.github/versions.env‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The engines CI pins, read by the composite actions (.github/actions/mtest).
22
# mtest: an xlings package (xim:mtest) whose sha256 the index states; the release
33
# bundle's sha256 checks the fallback download.
4-
MTEST_VERSION=0.11.2
5-
MTEST_SHA256=88144bacd76ff3af3957b29560e55af813906db2f682f8cefae1869a2be74de9
4+
MTEST_VERSION=0.11.3
5+
MTEST_SHA256=29e597e2177589dc06f0f9064f86b71198200b425acfa168b8dffa0c259885db

‎.github/workflows/ci-unit.yml‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ on:
8585
description: the number of tests the archive holds
8686
value: ${{ jobs.archive.outputs.archived }}
8787
shards:
88-
description: the run stage's shards, from the measured work of main's last run
88+
description: the run stage's shards, from the shards of main's last run and the longest of them
8989
value: ${{ jobs.archive.outputs.shards }}
9090

9191
env:
@@ -198,27 +198,46 @@ jobs:
198198
fi
199199
python3 .github/tools/test_history.py take "$RUNNER_TEMP/unit/history" "$d" "$d"/*/
200200
201-
# THE SHARDS FROM THE PLAN (design 2026-11-20 §5.17, CI4): the measured work of main's last
202-
# run, its shards' programs' durations summed (the history holds that run's shards alone,
203-
# test_history.py), over what one shard does in 30 minutes with its four workers; at least
204-
# one, at most eight. With no history, four, as before.
201+
# THE SHARDS FROM THE PLAN (design 2026-11-20 §5.17, CI4): main's last run took N shards and
202+
# the longest of them W, so the run is N × W of shard time; this one takes as many shards as
203+
# that is in 30 minutes each, at least one, at most eight. N and W are read from the stores
204+
# the shard jobs kept (`mtest-unit-<name>-<shard>-a<attempt>`, each holding that shard's
205+
# runs, test_history.py): the store's import (test-report) keeps a run in the form of
206+
# mtest's records, which state no shard, and the subsystems' store beside them is another
207+
# job's. A shard's time is that of its longest programs and of those that
208+
# run beside one another, not its programs' durations over four workers: the openkal
209+
# programs build in parallel within the machine's one budget, and in fewer shards they run
210+
# beside one another and each takes longer. A run of three shards (1236, 834 and 1438 s)
211+
# gave two by its durations summed, and the two took 2544 and 2432 s, `trees` 1369 s in the
212+
# first run and past the 40 minutes it states in the second (CI, 2026-11-21). With no
213+
# history of shards, four.
205214
- name: The run stage's shards
206215
id: shards
207216
shell: bash
217+
env:
218+
KEY: ${{ inputs.name }}
208219
run: |
209220
set -uo pipefail
210-
work=$(find "$RUNNER_TEMP/unit/history" -name programs.ndjson -print0 2>/dev/null \
211-
| xargs -0 -r cat | jq -s 'map(.ms // 0) | add // 0')
212-
if [ -z "$work" ] || [ "${work%.*}" = 0 ]; then
213-
echo 'shards=[1,2,3,4]' >> "$GITHUB_OUTPUT"; echo "no measured work: four shards"; exit 0
221+
# A re-run's store (`-a2`) holds the attempt before it and its `--failed` run: the
222+
# shards are counted by number, and the longest run is the whole shard's.
223+
was=0; longest=0
224+
for s in "$RUNNER_TEMP"/unit-stores/mtest-unit-"$KEY"-*-a*/; do
225+
[[ "$(basename "$s")" =~ ^mtest-unit-"$KEY"-([0-9]+)-a[0-9]+$ ]] || continue
226+
[ -f "$s/index.ndjson" ] || continue
227+
[ "${BASH_REMATCH[1]}" -le "$was" ] || was=${BASH_REMATCH[1]}
228+
ms=$(jq -s 'map(.ms // 0) | max // 0 | floor' "$s/index.ndjson" 2>/dev/null || echo 0)
229+
[ "${ms:-0}" -le "$longest" ] || longest=$ms
230+
done
231+
if [ "$was" -le 0 ] || [ "$longest" -le 0 ]; then
232+
echo 'shards=[1,2,3,4]' >> "$GITHUB_OUTPUT"; echo "no measured shards: four shards"; exit 0
214233
fi
215-
per=$((30 * 60 * 1000 * 4))
216-
n=$(( (${work%.*} + per - 1) / per ))
234+
per=$((30 * 60 * 1000))
235+
n=$(( (was * longest + per - 1) / per ))
217236
[ "$n" -ge 1 ] || n=1
218237
[ "$n" -le 8 ] || n=8
219238
list=$(seq -s, 1 "$n")
220239
echo "shards=[$list]" >> "$GITHUB_OUTPUT"
221-
echo "measured work ${work%.*} ms: $n shard(s)"
240+
echo "main's last run: $was shard(s), the longest $((longest / 1000)) s: $n shard(s)"
222241
223242
- name: Upload the tests and their history
224243
if: steps.archive.outputs.archived != '0'

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ jobs:
400400
name: linux
401401
runs-on: ubuntu-24.04
402402
archived: ${{ needs.unit-linux-archive.outputs.archived }}
403-
# The shards the archive stage planned from main's measured work (four
404-
# without a history): the measured run of 2026-11-13 reached 65 of its
405-
# programs, 3970 s of work, in the 45 minutes of one job of four workers.
403+
# The shards the archive stage planned from main's last run, its shards and
404+
# the longest of them (four without a history): the measured run of
405+
# 2026-11-13 reached 65 of its programs, 3970 s of work, in the 45 minutes
406+
# of one job of four workers.
406407
shards: ${{ needs.unit-linux-archive.outputs.shards || '[1,2,3,4]' }}
407408
form: ${{ needs.release-form.result == 'success' && 'release' || 'host' }}
408409
# The toolchains whose capabilities the cases probe: build-linux's `prewarm`.
@@ -577,13 +578,17 @@ jobs:
577578
--sections summary,failures,slowest,builds,steps,margin,budget,ledgers,flaky,path
578579
# THE GATE OVER THE RUN'S GROUP (design 2026-11-20 §5.16, §5.17): no case over the budget
579580
# without a waiver, every item of the surface used by a passing case or waived, and no waiver
580-
# that excuses nothing.
581+
# that excuses nothing. The run's set is the gate's: the surface is a ledger of every case, and
582+
# `pr` runs the jobs and cases a change affects, so its gate judges the budget and notes that
583+
# it did not judge the ledger (mtest 0.11.3); a `full` run judges both.
581584
- name: The gate over the run's group
582585
shell: bash
586+
env:
587+
SET: ${{ needs.changes.outputs.set }}
583588
run: |
584589
set -euo pipefail
585590
cd tests/e2e
586-
"$MTEST" gate
591+
"$MTEST" gate --set "$SET"
587592
- uses: actions/upload-artifact@v4
588593
if: always()
589594
with:

‎tests/e2e/openkal/images.cpp‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ __attribute__((no_stack_protector)) int ok_main(void) {
163163
constexpr std::string_view caught_main = "import std;\nint main(int argc, char** argv) {\n try { throw std::runtime_error(\"caught\"); }\n catch (const std::exception& e) { std::println(\"image: {} ({} args)\", e.what(), argc); }\n return 0;\n}\n";
164164
constexpr std::string_view smoke_test = "import std;\nint main() { std::vector<int> v{2, 1}; std::ranges::sort(v); return v.front() == 1 ? 0 : 1; }\n";
165165

166-
E2E images{"images", s::home_fixture, [] {
166+
// The ok images of this architecture and the runtime each first run builds: 707 s in a Linux shard
167+
// of three, 1102 s in a shard of two, of the run's 1200 (CI, 2026-11-21); stated, so the run's
168+
// limit is not raised for every test.
169+
E2E images{"images", s::home_fixture, timeout{std::chrono::minutes{30}}, [] {
167170
"942 an ok image is built once and run by okrun"_test[s::llvm][s::python3] = [] {
168171
// A both rows publish bin/app.oke, an ET_DYN of their architecture, and no unchecked
169172
// image; B okrun runs this machine's image with its arguments, environment, a callback,
@@ -512,9 +515,9 @@ int main(int argc, char** argv) {
512515
{"tests/smoke.cpp", "import std;\nint main() { return std::format(\"{}-{}\", 1, 2) == \"1-2\" ? 0 : 1; }\n"}});
513516
const std::string ht = std::string(host_arch) + "-openkal";
514517
// The first run builds the platform's runtime (1,636 edges): beyond ten minutes on a
515-
// four-processor Windows runner whose other tests share the run's budget (CI, 2026-11-21).
516-
auto r = app.mcpp({"run", "--target", ht, "--", "one", "two words"},
517-
{.env = {{"MCPP_E2E_1033", "here"}}, .timeout = std::chrono::minutes{30}});
518+
// four-processor Windows runner whose other tests share the run's budget (CI, 2026-11-21),
519+
// within the suite's time.
520+
auto r = app.mcpp({"run", "--target", ht, "--", "one", "two words"}, {.env = {{"MCPP_E2E_1033", "here"}}});
518521
expect(fatal(e2e::succeeded(r))) << "A: mcpp run --target " << ht << ": " << s::text(r);
519522
expect(fatal(e2e::contains(s::text(r), "args=[one][two words] env=here sum=55"))) << "A: the image's output: " << s::text(r);
520523
r = app.mcpp({"test", "--target", ht});

‎tests/e2e/openkal/trees.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ E2E trees{"trees", s::home_fixture, timeout{std::chrono::minutes{40}}, [] {
117117
s::project app({{"mcpp.toml", "[package]\nname = \"uni\"\nversion = \"0.1.0\"\n"},
118118
{"src/main.cpp", "import std;\nint main(int argc, char** argv) {\n try { throw std::runtime_error(\"universal\"); }\n catch (const std::exception& e) { std::println(\"{} {} args\", e.what(), argc); }\n return 0;\n}\n"}});
119119
// A. The first pack builds the openkal set for both architectures: beyond ten minutes on a
120-
// four-processor Linux runner whose other tests share the run's budget (CI, 2026-11-21).
121-
auto r = app.mcpp({"pack", "--target", "openkal", "--pkg-format", "dir"}, {.timeout = std::chrono::minutes{30}});
120+
// four-processor Linux runner whose other tests share the run's budget (CI, 2026-11-21),
121+
// within the suite's time.
122+
auto r = app.mcpp({"pack", "--target", "openkal", "--pkg-format", "dir"});
122123
expect(fatal(e2e::succeeded(r))) << "A: pack: " << s::text(r);
123124
const auto p = app.at("target/dist/uni-0.1.0-openkal");
124125
for (std::string_view f : {"lib/x86_64/uni.oke", "lib/aarch64/uni.oke", "bin/uni", "bin/uni.exe", "mcpp-package.json"})

‎tests/e2e/test/protocol.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Test programs that speak mtest's test protocol: their cases, live case records, the spec's
2-
// launch, capabilities, checks and output (formerly tests/e2e/1035, 1065 and 1070).
2+
// launch, capabilities, checks and output (formerly tests/e2e/1035, 1065 and 1070); run fixtures;
3+
// the time the kit gives a command within its case.
34
import std;
45
import mcpplibs.mtest;
56
import mcpp.test.support;
@@ -452,6 +453,23 @@ int main() {{
452453
infra = infra || (p.value("status", "") == "infra" && p["fixtures"] == json::parse(R"(["home"])"));
453454
expect(infra) << "no program's record says infra";
454455
};
456+
457+
"1141 a command of the kit has the time its case has left"_test[timeout{std::chrono::minutes{45}}] = [] {
458+
// Design 2026-11-20 §5.8 (K1): a command that states no time takes what its case has left
459+
// of the time its scopes state, not ten minutes below it; a command that states one keeps
460+
// it. The case states 45 minutes, so a command composed at its start has more than 44.
461+
const auto cwd = s::case_dir();
462+
const auto left = s::mcpp_command({"--version"}, cwd).timeout;
463+
expect(fatal(left > std::chrono::minutes{44} && left <= std::chrono::minutes{45})) << "the command's time is " << left.count() << " ms";
464+
expect(fatal(s::mcpp_command({"--version"}, cwd, {.timeout = std::chrono::seconds{60}}).timeout == std::chrono::seconds{60}));
465+
expect(fatal(e2e::succeeded(s::mcpp({"--version"}, cwd))));
466+
};
467+
468+
"1142 a command of the kit takes ten minutes where no scope states a time"_test = [] {
469+
// Where neither the case nor a scope around it states a time, the runner's limit would end
470+
// the program without the case's report of a hung command: ten minutes bound it.
471+
expect(fatal(s::mcpp_command({"--version"}, s::case_dir()).timeout == std::chrono::minutes{10}));
472+
};
455473
}};
456474

457475
} // namespace

‎tests/support/src/support.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,14 @@ e2e::command mcpp_command(std::vector<std::string> args, const fs::path& cwd, co
389389
c.env.emplace_back("MCPP_VERBOSE", std::nullopt);
390390
for (const auto& kv : o.env) c.env.push_back(kv);
391391
c.input = o.input;
392-
c.timeout = o.timeout;
392+
// A COMMAND HAS THE TIME ITS CASE HAS LEFT (design 2026-11-20 §5.8, K1). The kit also held each
393+
// command to ten minutes, below the time a suite states: a pack of every system in `sets/985`
394+
// ran past ten minutes beside three other openkal programs on a four-processor runner, its
395+
// suite well within the 45 minutes it states, and failed as a hang (CI, 2026-11-21). A time limit
396+
// bounds a hang; how long work takes is a measure of the run's records, not a verdict. Where no
397+
// scope states a time, ten minutes bounds a command, since the runner's limit would end the
398+
// program without the case's report of it.
399+
c.timeout = o.timeout.value_or(mcpplibs::mtest::time_left().value_or(std::chrono::minutes{10}));
393400
return c;
394401
}
395402

‎tests/support/src/support.cppm‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ struct options {
186186
// Set (a value) or removed (nothing) for the run, after the home.
187187
std::vector<std::pair<std::string, std::optional<std::string>>> env;
188188
std::string input;
189-
std::chrono::milliseconds timeout{std::chrono::minutes{10}};
189+
// Nothing: what the case has left of the time its scopes state, or ten minutes where none
190+
// states one (mcpp_command).
191+
std::optional<std::chrono::milliseconds> timeout;
190192
// A program and its arguments mcpp runs under (`unshare -rn`, a network namespace of its own),
191193
// so that a command run so is the case's like any other: its use of the surface is recorded.
192194
std::vector<std::string> wrap;

0 commit comments

Comments
 (0)