From 65291344a18c5bbeafc11e6d6243b83cd0e72563 Mon Sep 17 00:00:00 2001 From: Scott McCarty Date: Wed, 4 Nov 2026 09:59:45 -0500 Subject: [PATCH] fix: v0.3.1 one footer per check, not one per step trentina's first lane run printed this: == image-tests passed in 0s == image-tests passed in 56s v0.3.0 added a per-check footer because buffering collapses the timestamps people were reading the `== ` markers for -- and then wrote it per STEP. `pytest-in-image` is two steps, installing the lock's pytest into the cache volume and then running the tests in the image, so the check that takes the longest was the one whose timing came out wrong, twice over. One footer per check now, carrying the time all of its steps took. The host contract test grew a two-step check; it fails against v0.3.0's launcher with "printed 2 footers, want 1" and with the sum reported as the last step alone. Found by reading the output of the thing I had just shipped, which is the only reason it was found at all -- no test had a multi-step check in it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01R7Y1jesjfgxHeqtKJCvay6 --- CHANGELOG.md | 16 +++++++++++++++- Containerfile | 2 +- IMAGE_TAG | 2 +- README.md | 2 +- bin/sdlc | 27 ++++++++++++++++++++------- pyproject.toml | 2 +- tests/test_host_contract.sh | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 72 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 634d3b4..b4911e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ All notable changes to this project are documented here, following ## [Unreleased] +## [0.3.1] - 2026-11-04 + +### Fixed + +- **A check with more than one step ended with two footers, the first reading + "passed in 0s".** The per-check footer v0.3.0 added was written per STEP, and + `pytest-in-image` is two: install the lock's pytest into the cache volume, + then run the tests in the image. trentina's first lane run printed + `== image-tests passed in 0s` and then `== image-tests passed in 56s`, so the + one number people now read timings from was wrong for exactly the check that + takes the longest. There is one footer per check now, carrying the time all + of its steps took, and `tests/test_host_contract.sh` holds a two-step check. + ## [0.3.0] - 2026-11-04 ### Changed @@ -249,7 +262,8 @@ cached tag was never refreshed — that gate had been running a two-week-old reviewer while CI pulled fresh. Local and CI were different reviewers on the same diff. -[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.3.0...HEAD +[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.3.1...HEAD +[0.3.1]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.3.1 [0.3.0]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.3.0 [0.2.2]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.2 [0.2.1]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.1 diff --git a/Containerfile b/Containerfile index 49c4431..eccf1fd 100644 --- a/Containerfile +++ b/Containerfile @@ -44,7 +44,7 @@ LABEL description="Every CrunchTools Python SDLC check in one image: ruff, mypy, LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc" LABEL org.opencontainers.image.description="Every CrunchTools Python SDLC check in one image." LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later" -LABEL version="0.3.0" +LABEL version="0.3.1" # What the image carries, readable without starting anything. `sdlc versions` # prints these and a consuming repo's CI pins them. diff --git a/IMAGE_TAG b/IMAGE_TAG index 0d91a54..9e11b32 100644 --- a/IMAGE_TAG +++ b/IMAGE_TAG @@ -1 +1 @@ -0.3.0 +0.3.1 diff --git a/README.md b/README.md index 5a35b57..5dcedf5 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ default_install_hook_types: [pre-commit, pre-push] repos: - repo: https://github.com/crunchtools/python-sdlc - rev: v0.3.0 + rev: v0.3.1 hooks: - id: sdlc-commit - id: sdlc-push diff --git a/bin/sdlc b/bin/sdlc index 5335775..bc89747 100755 --- a/bin/sdlc +++ b/bin/sdlc @@ -392,6 +392,16 @@ _lanes_running() { # 0 while any lane has not yet written its done marker _close_check() { # the open check's block is complete if [ -n "${_cur:-}" ]; then + # One footer per CHECK, carrying the time every one of its steps took. It + # used to be written per STEP, so `pytest-in-image` -- a `pytest-deps` step + # and then the run -- ended with two, the first of them "passed in 0s". + if [ "$_cur_rc" -eq 0 ]; then + printf '\n== %s passed in %ss\n' "$_cur_name" "$_cur_took" >> "$OUT/out.$_cur" + else + printf '\n%s: %s %s after %ss\n' "$ME" "$_cur_name" \ + "$([ "$_cur_rc" -eq 2 ] && echo 'COULD NOT RUN' || echo 'FAILED')" \ + "$_cur_took" >> "$OUT/out.$_cur" + fi printf '%s\n' "$_cur_rc" > "$OUT/rc.$_cur" _cur= fi @@ -404,6 +414,8 @@ run_lane() { # lane-index steps-file lane-cpus -> the lane's worst _failed= _cur= _cur_rc=0 + _cur_took=0 + _cur_name= # However this subshell ends -- a step's `die` exits it where it stands -- the # check it was on must get a verdict file and the lane must get its done # marker, or the printer waits for a block that is never coming. @@ -422,21 +434,22 @@ run_lane() { # lane-index steps-file lane-cpus -> the lane's worst case " $_failed " in *" $_check "*) continue ;; esac # A check's steps are contiguous within its lane, so a different index means # the previous block is finished and can be printed. - if [ "$_i" != "${_cur:-}" ]; then _close_check; _cur=$_i; _cur_rc=0; fi + if [ "$_i" != "${_cur:-}" ]; then + _close_check + _cur=$_i + _cur_rc=0 + _cur_took=0 + _cur_name=$_check + fi _t0=$(now_s) _rc=0 run_step "$_mode" "$_payload" >> "$OUT/out.$_i" 2>&1 || _rc=$? - _took=$(( $(now_s) - _t0 )) + _cur_took=$(( _cur_took + $(now_s) - _t0 )) if [ "$_rc" -ne 0 ]; then _failed="$_failed $_check" _cur_rc=$_rc - printf '\n%s: %s %s after %ss\n' "$ME" "$_check" \ - "$([ "$_rc" -eq 2 ] && echo 'COULD NOT RUN' || echo 'FAILED')" "$_took" \ - >> "$OUT/out.$_i" # A later 1 must not mask an earlier 2, in this lane or any other. if [ "$_rc" -eq 2 ] || [ "$_worst" -eq 2 ]; then _worst=2; else _worst=1; fi - else - printf '\n== %s passed in %ss\n' "$_check" "$_took" >> "$OUT/out.$_i" fi done < "$2" diff --git a/pyproject.toml b/pyproject.toml index 6613584..1230996 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ [project] name = "python-sdlc" -version = "0.3.0" +version = "0.3.1" description = "One container image and one script for every CrunchTools Python SDLC check" requires-python = ">=3.14" license = "AGPL-3.0-or-later" diff --git a/tests/test_host_contract.sh b/tests/test_host_contract.sh index f22d62c..04075ee 100755 --- a/tests/test_host_contract.sh +++ b/tests/test_host_contract.sh @@ -90,6 +90,10 @@ case " \$* " in printf 'w${TAB}one${TAB}image-ro${TAB}after-the-failure\n' printf 'y${TAB}two${TAB}image-ro${TAB}other-lane-first\n' printf 'z${TAB}two${TAB}image-ro${TAB}other-lane-second\n' ;; + *" plan lanes-two-step "*) + printf 'solo${TAB}one${TAB}image-ro${TAB}quiet-ok\n' + printf 'pair${TAB}two${TAB}image-ro${TAB}step-one\n' + printf 'pair${TAB}two${TAB}image-ro${TAB}step-two\n' ;; *" plan lanes-stall "*) printf 'f${TAB}one${TAB}image-ro${TAB}quiet-ok\n' printf 's${TAB}two${TAB}image-ro${TAB}very-slow-rc-one\n' ;; @@ -111,6 +115,8 @@ case "\$_last" in rc-two) printf 'RAN rc-two\n'; exit 2 ;; slow-rc-one) printf 'RAN slow-rc-one\n'; sleep 2; exit 1 ;; very-slow-rc-one) printf 'RAN very-slow-rc-one\n'; sleep 6; printf 'LAST LINE\n'; exit 1 ;; + step-one) printf 'RAN step-one\n'; sleep 1 ;; + step-two) printf 'RAN step-two\n'; sleep 1 ;; slow-rc-two) printf 'RAN slow-rc-two\n'; sleep 2; exit 2 ;; must-not-run) printf 'RAN must-not-run\n'; touch "$SHIM/must-not-run" ;; after-the-failure|other-lane-first|other-lane-second) @@ -225,6 +231,33 @@ else bad "a healthy run claimed no check had finished" fi +# A check with MORE THAN ONE step gets ONE footer, carrying the time all of its +# steps took. `pytest-in-image` is two steps -- install the lock's pytest into +# the cache volume, then run the tests in the image -- and v0.3.0 gave it two +# footers, the first reading "passed in 0s", because the footer was written per +# step. trentina's first lane run is what showed it. +lanes lanes-two-step && rc=0 || rc=$? +footers=$(grep -c '^== pair passed in' "$RUN/out" || true) +if [ "$footers" = 1 ]; then + ok "a two-step check gets exactly one footer" +else + bad "a two-step check printed $footers footers, want 1" + grep '^== ' "$RUN/out" | sed 's/^/ /' +fi +# Both steps took a second, so the one footer must report their sum, not the +# last step alone -- and never 0s. +if grep -qE '^== pair passed in [2-9][0-9]*s' "$RUN/out"; then + ok "the footer reports the time every step took" +else + bad "the footer does not sum the check's steps" + grep '^== pair' "$RUN/out" | sed 's/^/ /' +fi +if grep -q 'RAN step-one' "$RUN/out" && grep -q 'RAN step-two' "$RUN/out"; then + ok "both steps of the check ran" +else + bad "a step of the two-step check did not run" +fi + # Nothing finishing for STALL_MAX seconds. The case worth guarding is a lane # killed outright, which runs no EXIT trap and so never reports at all, leaving # the printer polling for a marker that is never coming. At the threshold it