Fork-skip guards still run on a fork during a local test run
The fork skip from #463 is skipIf(os.environ.get("GITHUB_REPOSITORY", UPSTREAM) != UPSTREAM), used in tests/test_placeholder_integrity.py (twice) and tests/test_setup_command.py. It works in CI. In a local run GITHUB_REPOSITORY is unset, so it falls back to UPSTREAM and the placeholder guards fire on every personalized fork: after /setup, a fork's local test run is permanently red, which teaches its owner to ignore it.
Reproduce: on a fork that has run /setup, run python -m unittest discover -s tests locally (no GITHUB_REPOSITORY set).
Suggested fix (in use in my fork): one shared helper, so all three skips answer the question the same way.
# tests/_upstream.py
def is_upstream_checkout() -> bool:
env_repo = os.environ.get("GITHUB_REPOSITORY")
if env_repo: # CI: authoritative
return env_repo == UPSTREAM
try:
origin = subprocess.run(["git", "remote", "get-url", "origin"],
cwd=REPO, capture_output=True, text=True, timeout=10)
except (OSError, subprocess.SubprocessError):
return True
if origin.returncode != 0:
return True
return UPSTREAM.lower() in origin.stdout.strip().lower()When nothing can be determined it assumes upstream, the safe direction: the worst case is that a guard runs exactly as it does today. Happy to open a PR if you want it.
Source: MadsLorentzen/ai-job-search