From 33089a2847424168072845277152a9cc0fb3c543 Mon Sep 17 00:00:00 2001 From: Varun Poojari <83573233+Varunpoojari@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:44:26 +0000 Subject: [PATCH 1/2] docs: REFERENCE.md says release builds run on tag push, but release.yml is workflow_dispatch only The Distribution section claimed binaries are built "on every vX.Y.Z tag push". release.yml deliberately triggers only on workflow_dispatch, so a tag push does nothing. Describe the real flow and add tests/test_docs_consistency.py so the wording cannot drift back. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01DsERxaCi7rNtqUTYked7Jd --- docs/REFERENCE.md | 7 +++++-- tests/test_docs_consistency.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/test_docs_consistency.py diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index b104aa5..82176e0 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1027,8 +1027,11 @@ Every install channel above is built on the same foundation: standalone, self-contained binaries (bundled Python interpreter + all dependencies — nothing needs to be pre-installed) for macOS (arm64/x64), Linux (x64/arm64), and Windows (x64), built by CI (`.github/workflows/release.yml`) -on every `vX.Y.Z` tag push and attached to the matching GitHub Release -along with a `SHA256SUMS` file. +when a maintainer with write access runs the Release workflow by hand +(Actions tab, `workflow_dispatch`) for an existing `vX.Y.Z` tag that matches +`src/secfoo/__about__.py`. It is deliberately not triggered by tag pushes. +The binaries are attached to the matching GitHub Release along with a +`SHA256SUMS` file. - **pip**: the "real"/native path — a normal Python sdist+wheel, published to PyPI as usual. diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py new file mode 100644 index 0000000..c5ac8e6 --- /dev/null +++ b/tests/test_docs_consistency.py @@ -0,0 +1,19 @@ +"""Guards against documentation drifting away from the code it describes.""" + +from __future__ import annotations + +import re +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def test_release_docs_do_not_claim_tag_push_trigger() -> None: + """The release workflow is workflow_dispatch only, so the docs must not say otherwise.""" + workflow = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8") + triggers = workflow.split("\non:\n", 1)[1].split("\n\n", 1)[0] + assert "workflow_dispatch" in triggers + assert not re.search(r"^\s{2}push:", triggers, re.MULTILINE) + + reference = (ROOT / "docs" / "REFERENCE.md").read_text(encoding="utf-8") + assert "tag push" not in reference.replace("not triggered by tag pushes", "") From 24910616ab43110c61d3a997c99be2e782e0d6f5 Mon Sep 17 00:00:00 2001 From: Satyanarayana Vuppala Date: Fri, 20 Nov 2026 10:12:45 +0000 Subject: [PATCH 2/2] docs/test: say what a Release dispatch does; harden the trigger guard Review follow-ups for #151 (#120 item 5), pushed by the maintainers: - REFERENCE.md: the version check reads __about__.py at the tag, the run creates the GitHub Release itself, and the same run also publishes to PyPI, npm and GHCR (a PyPI version cannot be re-uploaded). - tests/test_docs_consistency.py: the on: block now runs to the next top-level key (a push trigger after a blank line, in flow form or under a quoted "on" key is caught; comments are ignored), and the tag-push check is case-insensitive, covers "tag-push" and "on every vX.Y.Z tag", and scans README.md, CONTRIBUTING.md and all docs, allowing negations. Co-Authored-By: Claude Opus 5.5 --- docs/REFERENCE.md | 10 ++++--- tests/test_docs_consistency.py | 50 ++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 82176e0..5f8bc20 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1028,10 +1028,12 @@ self-contained binaries (bundled Python interpreter + all dependencies — nothing needs to be pre-installed) for macOS (arm64/x64), Linux (x64/arm64), and Windows (x64), built by CI (`.github/workflows/release.yml`) when a maintainer with write access runs the Release workflow by hand -(Actions tab, `workflow_dispatch`) for an existing `vX.Y.Z` tag that matches -`src/secfoo/__about__.py`. It is deliberately not triggered by tag pushes. -The binaries are attached to the matching GitHub Release along with a -`SHA256SUMS` file. +(Actions tab, `workflow_dispatch`) for an existing `vX.Y.Z` tag whose +`src/secfoo/__about__.py` (at that tag) has the same version. It is +deliberately not triggered by tag pushes. The run creates the GitHub Release +for that tag, attaches the binaries and a `SHA256SUMS` file, and in the same +run publishes to PyPI, npm and GHCR. A PyPI version cannot be re-uploaded, so +dispatch it only for a version you mean to release. - **pip**: the "real"/native path — a normal Python sdist+wheel, published to PyPI as usual. diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py index c5ac8e6..e7256ce 100644 --- a/tests/test_docs_consistency.py +++ b/tests/test_docs_consistency.py @@ -7,13 +7,51 @@ ROOT = Path(__file__).resolve().parents[1] +# "tag push", "tag-push", "Tag push", "on every vX.Y.Z tag" ... unless negated. +_TAG_PUSH_CLAIM = re.compile(r"tag[- ]push|on every `?v?X\.Y\.Z`? tag", re.IGNORECASE) +_NEGATED = re.compile(r"\bnot\b[^.]{0,40}$", re.IGNORECASE) -def test_release_docs_do_not_claim_tag_push_trigger() -> None: - """The release workflow is workflow_dispatch only, so the docs must not say otherwise.""" + +def _has_push_trigger(on_block: str) -> bool: + """`push` as a trigger: the inline value (`on: push`, `on: [push, ...]`) + or a block-form key (` push:`). Comments and descriptions don't count.""" + inline, _, body = on_block.partition("\n") + if re.search(r"\bpush\b", inline.split("#", 1)[0]): + return True + return bool(re.search(r"^[ \t]+push[ \t]*:", body, re.MULTILINE)) + + +def _top_level_on_block(workflow: str) -> str: + """The workflow's `on:` block: from `on:` to the next top-level key, + blank lines and comments included (a blank line must not end it).""" + match = re.search(r'^["\']?on["\']?:[ \t]*(.*)\n((?:(?:[ \t]+.*|[ \t]*|#.*)\n)*)', workflow, re.MULTILINE) + assert match, "release.yml has no top-level `on:` key" + return match.group(1) + "\n" + match.group(2) + + +def test_release_workflow_is_manual_only() -> None: + """The release workflow is workflow_dispatch only; any push trigger + (block form, flow form, or after a blank line) fails this test.""" workflow = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8") - triggers = workflow.split("\non:\n", 1)[1].split("\n\n", 1)[0] + triggers = _top_level_on_block(workflow) assert "workflow_dispatch" in triggers - assert not re.search(r"^\s{2}push:", triggers, re.MULTILINE) + assert not _has_push_trigger(triggers), triggers + + +def test_docs_do_not_claim_the_release_runs_on_tag_push() -> None: + files = [ROOT / "README.md", ROOT / "CONTRIBUTING.md", *sorted((ROOT / "docs").rglob("*.md"))] + offenders = [] + for path in files: + for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1): + for match in _TAG_PUSH_CLAIM.finditer(line): + if not _NEGATED.search(line[: match.start()]): + offenders.append(f"{path.relative_to(ROOT)}:{number}: {line.strip()}") + assert offenders == [] + - reference = (ROOT / "docs" / "REFERENCE.md").read_text(encoding="utf-8") - assert "tag push" not in reference.replace("not triggered by tag pushes", "") +def test_the_on_block_parser_sees_triggers_after_a_blank_line() -> None: + workflow = "name: R\non:\n workflow_dispatch:\n inputs: {}\n\n push:\n tags: ['v*']\njobs: {}\n" + assert _has_push_trigger(_top_level_on_block(workflow)) + assert _has_push_trigger(_top_level_on_block('"on": [push, workflow_dispatch]\njobs: {}\n')) + commented = "on:\n workflow_dispatch:\n\n# the GHCR push needs packages: write\njobs: {}\n" + assert not _has_push_trigger(_top_level_on_block(commented))