From 22ef89bf10b9f5aa811647d3c06c7835c3490b57 Mon Sep 17 00:00:00 2001 From: glenn schrooyen Date: Sun, 15 Nov 2026 23:29:34 +0100 Subject: [PATCH] CI-18 review: --head needs B checked out; guard the CI image against CI_ONLY The selector reads the graph, and run-affected.sh runs the tests, from the working tree, so a --base/--head range is only right with the head checked out. The CI image is built from the merged tree, so an ENV CI_ONLY in its Dockerfile would make the gate partial; test_affected_tests.py now fails on it. Co-Authored-By: Claude Opus 5.5 --- .gitea/ci/affected_tests.py | 2 +- .gitea/ci/run-affected.sh | 2 +- README.md | 2 +- goodwe_controller/test_affected_tests.py | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitea/ci/affected_tests.py b/.gitea/ci/affected_tests.py index 9fec46c..9ea85d7 100644 --- a/.gitea/ci/affected_tests.py +++ b/.gitea/ci/affected_tests.py @@ -2,7 +2,7 @@ """CI-18: which test_*.py files does a diff affect? For DEV and REVIEW rounds only. python3 .gitea/ci/affected_tests.py # merge-base(origin/release/1.0) .. working tree - python3 .gitea/ci/affected_tests.py --base A --head B # a committed range + python3 .gitea/ci/affected_tests.py --base A --head B # a committed range (the graph is read from the working tree: check out B) python3 .gitea/ci/affected_tests.py --files f1 f2 # explicit changed paths (no git) ... --names # only the file names, one per line diff --git a/.gitea/ci/run-affected.sh b/.gitea/ci/run-affected.sh index 1228f04..680b024 100644 --- a/.gitea/ci/run-affected.sh +++ b/.gitea/ci/run-affected.sh @@ -3,7 +3,7 @@ # round. NOT the merge gate: `checks / unit (pull_request)` runs all of them. # # sh .gitea/ci/run-affected.sh # merge-base(origin/release/1.0) .. working tree -# sh .gitea/ci/run-affected.sh --base A --head B +# sh .gitea/ci/run-affected.sh --base A --head B # with B checked out: the tests run from the working tree # INFRA_DIR=/path/to/admin-goodwe@pin sh .gitea/ci/run-affected.sh # # Arguments go to affected_tests.py (which prints what it chose and why). It diff --git a/README.md b/README.md index 3a04a2b..dc8b04b 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ The pin tracks `admin/goodwe` **release/1.0**, not master. Two non-required chec ```bash INFRA_DIR=~/path/to/admin-goodwe-at-the-pin sh .gitea/ci/run-affected.sh # release/1.0 .. working tree -sh .gitea/ci/run-affected.sh --base origin/release/1.0 --head my-branch # a committed range +sh .gitea/ci/run-affected.sh --base origin/release/1.0 --head my-branch # a committed range, with my-branch checked out (the tests run from the working tree) python3 .gitea/ci/affected_tests.py --files goodwe_controller/app/price.py # only list, with the reasons ``` diff --git a/goodwe_controller/test_affected_tests.py b/goodwe_controller/test_affected_tests.py index 4283787..43f1e17 100644 --- a/goodwe_controller/test_affected_tests.py +++ b/goodwe_controller/test_affected_tests.py @@ -13,8 +13,8 @@ here are the ones whose failure would be a missed test: run-tests.sh select ALL, a changed test file is chosen. 4. THE MUTANT: break a real module in a private copy of the tree; the selector must choose a test that goes red, and the unbroken copy is green. - 5. The merge gate cannot be partial: checks.yml never mentions CI_ONLY and - still runs the unfiltered run-tests.sh line. + 5. The merge gate cannot be partial: checks.yml and the CI image never + mention CI_ONLY, and checks.yml still runs the unfiltered run-tests.sh line. Read MUTATION.md before you report a survivor. """ @@ -256,6 +256,11 @@ with open(os.path.join(REPO, ".gitea", "ci", "run-tests.sh"), rt = fh.read() check("run-tests.sh takes CI_ONLY from the environment only and says PARTIAL", "PARTIAL RUN" in rt and 'set -- test_*.py' in rt) +with open(os.path.join(REPO, ".gitea", "ci", "Dockerfile"), + encoding="utf-8") as fh: + df = fh.read() +check("the CI image (built from the merged tree) never sets CI_ONLY", + "CI_ONLY" not in df) for d in tmps: shutil.rmtree(d, ignore_errors=True)