Skip to content

ci: One Python call stamps the Sphinx docs version (GEN-005, refs #2681) - #2682

Merged
zackees merged 2 commits into
masterfrom
infra/2681-gen-005-generate-docs
Oct 27, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2681-gen-005-generate-docs

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Refs #2681 — the first unit of the GEN-005 (shell budget) burn-down: one composite action's run: step becomes one call into a Python module.

What changed

.github/actions/generate-docs/action.yaml runs.steps[0] (id: setup) was a 30-line shell block:

  • grep -E '#define LIBOBS_API_(MAJOR|MINOR|PATCH)_VER ' + sed/tr + read to get the libobs API version;
  • three sed -i -E rewrites of docs/sphinx/conf.py (version, release, copyright with the current year);
  • an optional html_link_suffix = None → '' blank;
  • two $GITHUB_OUTPUT appends (artifactName, commitHash).

It is now one line:

run: uv run --no-project --script ci/docs_version_stamp.py --source-directory "${{ inputs.sourceDirectory }}" --disable-link-extensions "${{ inputs.disableLinkExtensions }}"

ci/docs_version_stamp.py (stdlib only, #!/usr/bin/env -S uv run --script) does the same work: same LIBOBS_API_*_VER parse, same three substitutions with the same regexes, same two outputs, same "No Extensions" artifact name. A missing define is a hard error naming the file.

The action installs uv before the call (astral-sh/setup-uv, pinned to the SHA compatibility-validator already uses, with the repo's save-cache: ${{ github.ref == 'refs/heads/master' }} and the delimited cache-suffix expression) because all three callers — ci.yml, push.yaml, dispatch.yaml's update-documentation jobs — run on a bare ubuntu-26.04 with no uv on PATH. ci/test_cache013_actions.py gains generate-docs/action.yaml in its TARGETS pin for that step.

The file's GEN-005 [[exceptions]] block is deleted.

RED → GREEN

  • RED 0ced87273 — ci/test_docs_version_stamp.py only. Fails on master: the module does not exist (6 errors), the setup step is still a run: | shell block, and the ci.toml exception is still present (3 failures).
  • GREEN 6862b6f3a — the module, the one-line step, the setup-uv step, the CACHE-013 pin, and the exception deletion.

RED/GREEN is the precheck header, run against this checkout with the repo's pin:

origin/master : ci-lint precheck: 11 violation(s), 491 approved exception(s), 10 needs_review
this branch   : ci-lint precheck: 11 violation(s), 490 approved exception(s), 10 needs_review

and the [GEN-005] APPROVED EXCEPTION .github/actions/generate-docs/action.yaml — runs.steps[0] line is gone, with no new finding in any rule.

Local checks: uv run python -m unittest ci/test_docs_version_stamp.py ci/test_cache013_actions.py ci/test_uv_run.py ci/test_ci_toml.py ci/test_wf002_concurrency.py ci/test_ci_job_timeouts.py ci/test_tool_guard.py — 17 + 13 + … all OK; uvx ruff check on the touched Python — clean.

Notes

  • The RED commit also carried a test_uv_run.py invocation through a subprocess argv pair, which TOOL-003 rightly rejects (uv run must be the literal text on the line); GREEN drops that redundant check rather than allowlisting the file — ci/test_uv_run.py runs on its own in CI.
  • The first version of the RED test also asserted a github_output write path with mock.patch.dict; that stayed, the argv-based gate test did not.
  • Not executed: a real docs run. update-documentation is gated on github.repository_owner == 'obsproject', so neither PR CI nor push.yaml runs it in this fork; the port is pinned by the unit test instead (fixture obs-config.h + fixture conf.py, both branches of disableLinkExtensions).

CI/configuration-only change: no docs/features.md line.

The generate-docs composite action's `setup` step is a 30-line shell block
that reads the libobs API version from libobs/obs-config.h and rewrites
docs/sphinx/conf.py with sed -- a GEN-005 'shell budget' finding.

This pins the shape the port must have: the step is a single
`uv run --no-project --script ci/docs_version_stamp.py` line, the module
stamps conf.py and writes the step's artifactName/commitHash outputs, the
action installs uv itself (all three callers run on a bare ubuntu-26.04),
and the GEN-005 exception leaves ci.toml.

RED: the module does not exist and the step is still shell.
The generate-docs composite action's `setup` step was a 30-line shell block:
grep/tr/read to split LIBOBS_API_{MAJOR,MINOR,PATCH}_VER out of
libobs/obs-config.h, three `sed -i -E` rewrites of docs/sphinx/conf.py, an
optional link-suffix blank, and two $GITHUB_OUTPUT appends.

It is now a single `uv run --no-project --script ci/docs_version_stamp.py`
line; the module (stdlib only) does the same work byte for byte. The action
installs uv itself with the repo's save-cache/cache-suffix expressions, the
compatibility-validator precedent, because all three callers (ci.yml,
push.yaml, dispatch.yaml update-documentation) run on a bare ubuntu-26.04.

The GEN-005 `[[exceptions]]` block for the action is deleted: precheck goes
491 -> 490 approved exceptions and the generate-docs line is gone, with the
11 violations and 10 needs_review unchanged.
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 8b84251 Oct 27, 2026
32 checks passed
@zackees
zackees deleted the infra/2681-gen-005-generate-docs branch October 27, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant