Skip to content

Commit 785ad09

Browse files
committed
fix(ci): make infra .py-count drift check robust to build artifacts
test_canonical_facts_infrastructure_python_count_matches_tree counted on-disk infrastructure/**/*.py via rglob against the live repo, so a build- or test-generated .py (e.g. a version stub written during `uv sync` on ubuntu CI) inflated the count 483->484 and flapped the gate per-environment (green on macOS, red on ubuntu). Count git-tracked source files instead — that is what the factsheet documents as 'drift', and it is immune to transient on-disk artifacts.
1 parent 1eebc87 commit 785ad09

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/infra_tests/test_docs_discovery_consistency.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import re
6+
import subprocess
67
from pathlib import Path
78

89
from infrastructure.project.public_scope import public_project_names
@@ -145,9 +146,20 @@ def test_canonical_facts_infrastructure_python_count_matches_tree() -> None:
145146
assert count_match, "canonical_facts.md must include the refreshed infrastructure Python-file count"
146147

147148
documented = int(count_match.group("count"))
148-
actual = sum(1 for path in (root / "infrastructure").rglob("*.py") if path.is_file())
149+
# Count git-tracked source files, not an on-disk rglob: build- or test-generated
150+
# .py files under infrastructure/ (e.g. a version stub written during `uv sync`
151+
# in CI) would otherwise inflate the count and flap this gate per-environment.
152+
# The factsheet documents the tracked source surface, which is what drift means.
153+
tracked = subprocess.run(
154+
["git", "ls-files", "infrastructure"],
155+
cwd=root,
156+
capture_output=True,
157+
text=True,
158+
check=True,
159+
).stdout.splitlines()
160+
actual = sum(1 for path in tracked if path.endswith(".py"))
149161
assert documented == actual, (
150-
"canonical_facts.md drifted from the live infrastructure Python-file count; "
162+
"canonical_facts.md drifted from the tracked infrastructure Python-file count; "
151163
f"documented={documented} actual={actual}"
152164
)
153165

@@ -191,8 +203,6 @@ def test_continual_learning_local_state_gitignored() -> None:
191203

192204
def test_continual_learning_index_not_tracked() -> None:
193205
"""Transcript index is machine-local and must not be git-tracked."""
194-
import subprocess
195-
196206
root = _repo_root()
197207
result = subprocess.run(
198208
["git", "ls-files", ".cursor/hooks/state/continual-learning-index.json"],

0 commit comments

Comments
 (0)