test_every_action_is_pinned_by_commit_sha

Tests › tests/test_hosting.py

passed Passed in the packaged run.

What this test is for

Why it exists

Workflows and the composite action: `owner/action@<40-hex sha>` or a local path.

Verifies REQ-DDB-WIKI-039

Given

  1. files = [ *(REPO / ".github" / "workflows").glob("*.yml"), *(REPO / ".github" / "actions").rglob("action.yml"), ]
  2. loose = [ (f.relative_to(REPO).as_posix(), use) for f in files for use in _uses(yaml.safe_load(f.read_text())) if not use.startswith("./") and not _SHA.match(use) ]
→

When

  1. —
→

Then

  1. ✓ any("actions" in f.parts for f in files) holds
  2. ✓ loose equals []

What this test is for

Why it exists

S2, 1.1.0 AUDIT. A mutable ref means the code that runs in CI is chosen by whoever can move that ref, and `pypa/gh-action-pypi-publish@release/v1` was a BRANCH in the job holding the publishing credential — a force-push to it publishes anything it likes as this project. A local `./.github/workflows/...` call is exempt: it names this repository at this commit.

Verifies REQ-DDB-WIKI-039

Given

  1. offenders = [ f"{where}: {ref}" for where, ref in _action_refs() if not ref.startswith("./") and not _SHA_RE.match(ref.partition("@")[2].split()[0]) ]
→

When

  1. —
→

Then

  1. ✓ offenders is false

tests/test_hosting.py:52 · its file's page

What it checks (2)

  1. assert any("actions" in f.parts for f in files), "the composite action must exist" not attributed
  2. assert loose == [], f"actions not pinned by commit SHA: {loose}" observes _uses via loose

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_every_action_is_pinned_by_commit_sha→_uses

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

tests/test_packaging.py:307 · its file's page

What it checks (1)

  1. assert not offenders, ( "these action references are mutable, so the code CI runs is chosen by whoever can " f"move the ref: {offenders}" ) observes _action_refs via offenders

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_every_action_is_pinned_by_commit_sha→_action_refs

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-WIKI-039catalogunknown