CI-18 review: --head needs B checked out; guard the CI image against CI_ONLY
checks / unit (pull_request) Successful in 20m22s
infra-pin / fresh (pull_request) Successful in 1s

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 <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-11-15 23:29:34 +01:00
co-authored by Claude Opus 5.5
parent b2d3066966
commit 22ef89bf10
4 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
```
+7 -2
View File
@@ -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)