Files
shopdb-flask/tests/test_docs_publishable.py
cproudlock ee083ea80e docs: stop publishing internal references to a public wiki
docs/ is excluded from the code bundle and its scrub gate, because it goes to
the GitHub wiki instead - via a generator that has no gate at all. So the one
part of the repository written in prose, by people, about internal
infrastructure, was the one part nothing checked.

What was reaching a public wiki: the internal git server's URL and hostname,
.gitea workflow paths, developer home directories in the GE-Enforce cutover
reference, and a dev database root password inside a copy-pasteable command in
the import guide.

All replaced with neutral equivalents. tests/test_docs_publishable.py is now the
gate, at the source, in CI - a wiki page cannot be un-published, so catching this
after the fact is not good enough.

PROJECT-REVIEW.md also referred to internal tooling by name throughout; those
references are generalised. It remains an internal candid assessment of this
project that is nonetheless published, which is worth a separate decision.
2026-08-03 15:12:25 -04:00

64 lines
2.4 KiB
Python

"""docs/ is published to a PUBLIC wiki, so it must not carry internal references.
The code bundle has a scrub gate in tools/export-github.sh that refuses to commit
when internal names leak. docs/ is EXCLUDED from that bundle - it goes to the
wiki instead, by a generator that has no gate at all. So the one part of the
repository written in prose, by people, about internal infrastructure, was the
one part nothing checked.
It had leaked: the internal git server's URL, its hostname, `.gitea` workflow
paths, developer home directories, and a dev database root password inside a
copy-pasteable command.
This test is the gate. It runs in CI, at the source, before anything reaches a
wiki nobody can un-publish.
"""
import re
from pathlib import Path
import pytest
REPO = Path(__file__).resolve().parents[1]
DOCS = REPO / 'docs'
# Kept in step with the scrub list in tools/export-github.sh. Two mechanisms for
# one rule is not ideal, but the export scrubs a tree it is about to commit while
# this one fails a build - and docs/ never reaches the export at all.
FORBIDDEN = [
(r'gitea', 'names the internal git server'),
(r'proudtech', 'names an internal domain'),
(r'/home/[a-z]+/', 'contains a developer home directory'),
(r'rootpassword', 'contains a database root password'),
(r'\bclaude\b', 'names an LLM assistant'),
(r'\banthropic\b', 'names an LLM vendor'),
]
# Generated API surface. Not prose, not hand-edited, and regenerated from the
# code by scripts/gen_openapi.py.
SKIP = {'openapi.json', 'api-inventory.json'}
def documentation_files():
return sorted(
path for path in DOCS.rglob('*')
if path.is_file() and path.suffix in {'.md', '.txt'} and path.name not in SKIP
)
def test_there_are_docs_to_check():
"""A path change that silently matched nothing would make this suite pass
while checking absolutely nothing."""
assert len(documentation_files()) > 20
@pytest.mark.parametrize('pattern,why', FORBIDDEN)
def test_docs_carry_no_internal_references(pattern, why):
offenders = []
compiled = re.compile(pattern, re.I)
for path in documentation_files():
for number, line in enumerate(path.read_text(errors='replace').splitlines(), 1):
if compiled.search(line):
offenders.append('%s:%d %s' % (path.relative_to(REPO), number, line.strip()[:100]))
assert not offenders, (
'docs/ is published to a public wiki, and this %s:\n %s' % (why, '\n '.join(offenders[:10])))