mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-21 11:22:17 +01:00
Two pre-commit hooks and one pre-push extension, plus the _glyph_art split that had to land first — the cap gate cannot be wired while any file is over it, and the lyricanki note-ascender glyph had taken _glyph_art.py to 253. file-length-cap runs check_file_length.sh --all repo-wide rather than on staged files, so a file that grows past the cap in some other commit is still caught. Proven to block, not assumed: with a deliberate 261-line file staged the hook exits 1 and names it; with the file removed it passes. ci-baseline-green is the user's option (a): refuse to build on a main that is already red. It fails closed on a definitively failing baseline and warns-and- passes on anything it cannot determine — offline, no gh, unauthenticated, no settled runs — each call capped at 5s. Blocking every commit on network reachability buys nothing when (b) is the real per-change guarantee. CI_GREEN_SKIP=1 is the escape for a fix-forward commit. python-tests.yml is excluded on purpose: it is path-filtered, so a shell-only commit never triggers it and its "latest run" would produce false reds. This hook already earned its place. Run against a red main earlier in this session it refused with "Shell tests (failure)", which is how the broken SETUP_SOURCES was found instead of being pushed over. ci_mirror gains the shell-tests workflow's side-effect-free half — every lib/tests/run_all.sh plus the workflow's own test list, the user's option (b). That list is parsed out of shell-tests.yml rather than copied: a hardcoded duplicate drifts the moment someone adds a test, and a mirror that quietly checks less than CI is worse than no mirror because it reports safe. The Arch-container half stays unmirrored — it wants root and an Arch userland. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3PzGc75gBcdxP3PkHXGcV
48 lines
4.5 KiB
JSON
48 lines
4.5 KiB
JSON
{
|
|
"intent": "Phase 2 of the cap campaign: make the 250-line cap enforceable, and stop shell changes going red on push. Both halves of the user's answer to the CI-green fork — (a) a pre-commit check that main is not already red, and (b) a pre-push mirror of the Shell tests workflow.",
|
|
"scope": [
|
|
".pre-commit-config.yaml: two new local hooks, file-length-cap and ci-baseline-green",
|
|
"meta/scripts/check_ci_green.sh: new",
|
|
"meta/scripts/ci_mirror.sh: mirrors the shell-tests workflow's side-effect-free half",
|
|
"Bundled with the _glyph_art split because the gate cannot be wired while any file is over the cap"
|
|
],
|
|
"changes": [
|
|
"file-length-cap runs check_file_length.sh --all repo-wide, not per-file: a file that grows past the cap without being staged in this commit must still be caught. Wiring it earlier in the campaign would have blocked every unrelated commit in the repo, which is why it lands last.",
|
|
"ci-baseline-green (option a) checks the last COMPLETED run of 'Pre-commit checks' and 'Shell tests' on main. It fails CLOSED on a definitively red baseline and warns-and-passes on anything undeterminable — offline, no gh, unauthenticated, no runs yet — with a 5s timeout on every call. Blocking every commit on network reachability is a cost that buys nothing, because (b) is the real per-change guarantee. CI_GREEN_SKIP=1 bypasses it for a deliberate fix-forward commit, and it skips itself inside GitHub Actions.",
|
|
"python-tests.yml is deliberately NOT in the required list: it is path-filtered, so a shell-only commit never triggers it and its 'latest run' can legitimately be old. Including it would produce false reds.",
|
|
"ci_mirror.sh (option b) now runs every */lib/tests/run_all.sh plus the workflow's side-effect-free test list. That list is PARSED out of shell-tests.yml rather than duplicated: a hardcoded copy drifts the moment a test is added, and a mirror that silently checks less than CI is worse than none because it reports safe. It fails if the parse yields nothing.",
|
|
"The Arch-container half of shell-tests is not mirrored: it needs an Arch userland running as root to touch /etc, which is what a disposable container is for and a developer machine is not."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "pre-commit run file-length-cap --all-files, with a deliberate 261-line file staged",
|
|
"result": "pass",
|
|
"evidence": "The required Phase 2 check. The hook exits 1 and names the offender: '261 linux_configuration/scripts/toolong_probe.sh (+11)'. After removing the probe it passes. So the gate demonstrably blocks, rather than being assumed to."
|
|
},
|
|
{
|
|
"command": "pre-commit run ci-baseline-green --all-files",
|
|
"result": "pass",
|
|
"evidence": "Passes against the current green main. Its fail-closed path was also exercised for real earlier in this session: while Shell tests was red it correctly refused with 'main is RED on GitHub Actions: - Shell tests (failure)', which is what led to finding and fixing that breakage. Both skip paths (CI_GREEN_SKIP=1, GITHUB_ACTIONS=true) verified to exit 0."
|
|
},
|
|
{
|
|
"command": "awk parse of the test list out of shell-tests.yml",
|
|
"result": "pass",
|
|
"evidence": "Extracts exactly the six side-effect-free tests, and all six pass locally. The Arch job's second tests=( ) array is correctly not picked up."
|
|
},
|
|
{
|
|
"command": "shellcheck on both scripts",
|
|
"result": "pass",
|
|
"evidence": "rc=0 for check_ci_green.sh and ci_mirror.sh, no suppression added."
|
|
}
|
|
],
|
|
"risks": [
|
|
"ci-baseline-green blocks on a red main that someone else broke. That is the intended behaviour of option (a) — the alternative is silently building on a broken baseline — and CI_GREEN_SKIP=1 is the documented escape for a fix-forward commit.",
|
|
"The extended ci_mirror makes pre-push slower. It is the price of the failure it prevents: three separate test files asserted on code a split had moved during this campaign, and every one was caught only after the push.",
|
|
"ci_mirror parses YAML with awk rather than a YAML parser. It is anchored to the literal `tests=(` array shape in this one workflow and fails loudly if that shape changes, rather than silently mirroring nothing."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; both hooks disappear and ci_mirror returns to covering only pre-commit and pytest.",
|
|
"After rollback, confirm `pre-commit run --all-files` still passes and that check_file_length.sh --all is unaffected — it remains runnable by hand either way."
|
|
]
|
|
}
|