test_hosting.py

tests/test_hosting.py

Hosting the wiki from CI (round 3, P5c).

test_every_action_is_pinned_by_commit_sha

None test_hosting.test_every_action_is_pinned_by_commit_sha()

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

tests/test_hosting.py:52

Show on the map →

Called by none

Calls _uses

Checks

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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-039catalog
Source · 16 lines
def test_every_action_is_pinned_by_commit_sha() -> None:
    """@brief Workflows and the composite action: `owner/action@<40-hex sha>` or a local path."""
    files = [
        *(REPO / ".github" / "workflows").glob("*.yml"),
        *(REPO / ".github" / "actions").rglob("action.yml"),
    ]
    assert any("actions" in f.parts for f in files), "the composite action must exist"
    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)
    ]
    assert loose == [], f"actions not pinned by commit SHA: {loose}"

Activity · 4 steps
lines 54–57files = [ *(REPO / ".github" / "workflows").glob("*.yml"), *(REPO / ".github" / "actions").rglob("action.yml"), ]lines 58–58assert any("actions" in f.parts for f in files), "the composite action must exist"lines 59–64loose = [ (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) ]lines 65–65assert loose == [], f"actions not pinned by commit SHA: {loose}"

test_the_azure_template_pushes_the_ado_flavour_to_a_code_wiki

None test_hosting.test_the_azure_template_pushes_the_ado_flavour_to_a_code_wiki()

Azure Pipelines template.

tests/test_hosting.py:81

Show on the map →

Called by none

Calls _version

Checks

  • assert params["clewVersion"]["default"] == _version()
  • assert {"wikiRepository", "wikiBranch"} <= set(params)
  • assert "--format markdown --flavor ado" in text
  • assert "System.AccessToken" in text and "http.extraheader" in text
  • assert not re.search(r"https://[^\s]*\$\(System\.AccessToken\)", text)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-039catalog
Source · 14 lines
def test_the_azure_template_pushes_the_ado_flavour_to_a_code_wiki() -> None:
    """THE JOB'S OWN TOKEN, NEVER PRINTED: it reaches git through an extra header, not a URL that
    would land in the log.

    @brief Azure Pipelines template.
    """
    text = (REPO / "templates" / "azure-pipelines-wiki.yml").read_text()
    doc = yaml.safe_load(text)
    params = {p["name"]: p for p in doc["parameters"]}
    assert params["clewVersion"]["default"] == _version()
    assert {"wikiRepository", "wikiBranch"} <= set(params)
    assert "--format markdown --flavor ado" in text
    assert "System.AccessToken" in text and "http.extraheader" in text
    assert not re.search(r"https://[^\s]*\$\(System\.AccessToken\)", text)

1 more lines, not shown

Activity · 8 steps
lines 87–87text = (REPO / "templates" / "azure-pipelines-wiki.yml").read_text()lines 88–88doc = yaml.safe_load(text)lines 89–89params = {p["name"]: p for p in doc["parameters"]}lines 90–90assert params["clewVersion"]["default"] == _version()lines 91–91assert {"wikiRepository", "wikiBranch"} <= set(params)lines 92–92assert "--format markdown --flavor ado" in textlines 93–93assert "System.AccessToken" in text and "http.extraheader" in textlines 94–94assert not re.search(r"https://[^\s]*\$\(System\.AccessToken\)", text)

test_the_composite_action_builds_the_wiki_at_this_release

None test_hosting.test_the_composite_action_builds_the_wiki_at_this_release()

Composite; clew at this release with the wiki extra; HTML or Markdown; the site out.

tests/test_hosting.py:68

Show on the map →

Called by none

Calls _version

Checks

  • assert action["runs"]["using"] == "composite"
  • assert inputs["version"]["default"] == _version()
  • assert {"format", "flavor", "out", "config", "audience"} <= set(inputs)
  • assert "clew-trace[wiki]==${{ inputs.version }}" in runs
  • assert "clew wiki build" in runs and "--format" in runs
  • assert "site" in action["outputs"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-039catalog
Source · 13 lines
def test_the_composite_action_builds_the_wiki_at_this_release() -> None:
    """@brief Composite; clew at this release with the wiki extra; HTML or Markdown; the site out."""
    action = yaml.safe_load((REPO / ".github" / "actions" / "wiki" / "action.yml").read_text())
    assert action["runs"]["using"] == "composite"
    inputs = action["inputs"]
    assert inputs["version"]["default"] == _version()
    assert {"format", "flavor", "out", "config", "audience"} <= set(inputs)
    runs = "\n".join(str(s.get("run", "")) for s in action["runs"]["steps"])
    assert "clew-trace[wiki]==${{ inputs.version }}" in runs
    assert "clew wiki build" in runs and "--format" in runs
    assert "site" in action["outputs"]

Activity · 9 steps
lines 70–70action = yaml.safe_load((REPO / ".github" / "actions" / "wiki" / "action.yml").read_text())lines 71–71assert action["runs"]["using"] == "composite"lines 72–72inputs = action["inputs"]lines 73–73assert inputs["version"]["default"] == _version()lines 74–74assert {"format", "flavor", "out", "config", "audience"} <= set(inputs)lines 75–75runs = "\n".join(str(s.get("run", "")) for s in action["runs"]["steps"])lines 76–76assert "clew-trace[wiki]==${{ inputs.version }}" in runslines 77–77assert "clew wiki build" in runs and "--format" in runslines 78–78assert "site" in action["outputs"]