Skip to content

Commit ad598fb

Browse files
test(verify): the base-reachability pin skips where it cannot be judged (CI shallow checkout)
Run 35380095596 failed the 3.12 and 3.13 matrix on PR #24 while every other job passed and main was green an hour earlier. The cause is the new test_protected_file_bases_are_reachable_from_main from 34eb537: it runs `git merge-base --is-ancestor <base> main`, and CI's actions/checkout is a depth-1 clone of the PR ref with no `main` at all — there the base is not even an object ("fatal: Not a valid object name d7f568b"). Reproduced locally in a `--depth 1` clone of the branch: same failure. The property the test pins — both protected-files bases reachable on origin — cannot be judged in that checkout, so the test now skips with the reason when the repository is shallow (`rev-parse --is-shallow-repository`) or has no `main` ref, and judges it everywhere else. Proved three ways: passes in the full clone; still fails there with the old 3a4f6b01 restored ("not an ancestor of main"); skips in the shallow clone with "shallow checkout: the bases' reachability cannot be judged here". Module 27/27; ruff/pyright clean.
1 parent fc66514 commit ad598fb

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎packages/studyloop/tests/test_verify_plan_integration_script.py‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,25 @@ def test_protected_file_bases_are_reachable_from_main(self, script) -> None:
170170
check fail on every fresh checkout (2026-09-18: ``3a4f6b01`` survived the
171171
history consolidation as a dangling object here and nowhere else). Both
172172
bases must be ancestors of the local ``main`` -- the property a rewritten
173-
SHA loses."""
173+
SHA loses.
174+
175+
Judged only where it can be: CI's ``actions/checkout`` is a depth-1
176+
clone of the PR ref with no ``main``, where neither base is even an
177+
object (run 35380095596 failed the 3.12 and 3.13 matrix on exactly
178+
this). There the test skips and says why, rather than reporting a
179+
failure the checkout cannot distinguish from the real one."""
174180
import subprocess
175181

182+
def git(*args: str) -> subprocess.CompletedProcess[str]:
183+
return subprocess.run(["git", *args], cwd=REPO_ROOT, capture_output=True, text=True)
184+
185+
if git("rev-parse", "--is-shallow-repository").stdout.strip() == "true":
186+
pytest.skip("shallow checkout: the bases' reachability cannot be judged here")
187+
if git("rev-parse", "--verify", "-q", "main^{commit}").returncode != 0:
188+
pytest.skip("no local `main` ref: the bases' reachability cannot be judged here")
189+
176190
for base in (script.PROTECTED_EARLY_BASE, script.PROTECTED_LATE_BASE):
177-
result = subprocess.run(
178-
["git", "merge-base", "--is-ancestor", base, "main"],
179-
cwd=REPO_ROOT,
180-
capture_output=True,
181-
text=True,
182-
)
191+
result = git("merge-base", "--is-ancestor", base, "main")
183192
assert result.returncode == 0, f"{base} is not an ancestor of main: {result.stderr}"
184193

185194
def test_architect_grants_check_derives_the_ten_names_from_the_inventory(self, script) -> None:

0 commit comments

Comments
 (0)