Repository navigation
Description
Reproduction and tested fix
AI-assisted contribution submitted for the useful-improvement track of BOUNTY.md.
At main commit 5071ce8e2a4954871a07a305c076ad111e3f5fbc, tools/check_test_registration.py (blob 51063a53ca383cf664a371c1d81013c406ac679f, unchanged on main at recheck) counts invocations inside jobs or steps explicitly disabled by a literal false condition. Thus a test file that never executes can be certified as registered.
Create a temporary fixture root with tools/test_disabled.py containing raise RuntimeError("never executed"), tests/test_live.py containing pass, and this ci.yml:
name: CI
on: push
jobs:
guarded:
runs-on: ubuntu-latest
steps:
- name: Disabled suite
if: false
run: python3 -m unittest discover -s tools -p test_disabled.py
live:
runs-on: ubuntu-latest
steps:
- run: python3 tests/test_live.pyRun the actual guard with python3 tools/check_test_registration.py --root FIXTURE_ROOT --workflow FIXTURE_ROOT/ci.yml.
Expected: exit 1 and an unregistered-file diagnostic for tools/test_disabled.py. Actual: exit 0. Moving the false condition to the job also reproduces the defect. The independent live step prevents the no-registrations misuse branch.
Proposed change
Insert this helper before workflow_run_lines:
def statically_disabled(fields):
"""Recognize a literal false job/step condition, not arbitrary expressions."""
condition = fields.get("if")
if condition is None:
return False
value = condition[0].strip()
quoted = re.fullmatch(r'''(['"])(.*?)\1(?:\s+#.*)?''', value)
scalar = quoted[2] if quoted else re.split(r"\s+#", value, 1)[0]
return re.fullmatch(r"(?:false|\$\{\{ *false *\}\})", scalar.strip(),
re.IGNORECASE) is not NoneIn workflow_run_lines, change the job guard from if fields is None: to if fields is None or statically_disabled(fields):. In the existing step guard, retain all existing predicates (including the YAML merge-key check) and append or statically_disabled(step) before the final colon.
Verification
Nine offline subprocess fixture cases were run in the preceding implementation session. Original: 4/9 pass; patched: 9/9 pass. Expected exit codes:
- Disabled job or step (literal false), disabled job with false expression, disabled step with false expression and comment, quoted false expression with comment: original 0, patched 1.
- No condition, literal true, context-dependent condition, and disabled job with another enabled invocation of the same suite: both 0.
This is deliberately scoped to literal false conditions, not a general Actions expression evaluator. No full repository or hosted CI was run. Prior issue/PR searches for disabled job/step registration found no matching fix. Related shell-level masking and working-directory issues are distinct.
Please triage this tested tooling improvement for the bounty ladder if eligible. No award or payment is claimed.
Activity