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.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-039 | catalog |
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
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.
Checks
assert params["clewVersion"]["default"] == _version()assert {"wikiRepository", "wikiBranch"} <= set(params)assert "--format markdown --flavor ado" in textassert "System.AccessToken" in text and "http.extraheader" in textassert not re.search(r"https://[^\s]*\$\(System\.AccessToken\)", text)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-039 | catalog |
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
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.
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 runsassert "clew wiki build" in runs and "--format" in runsassert "site" in action["outputs"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-039 | catalog |
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"]