Skip to content

[architect] refactor: single source of truth for scripts/render_pr_body.py and scripts/render_gate_section.py - #431

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
arch/refactor-render-script-single-source
Open

[architect] refactor: single source of truth for scripts/render_pr_body.py and scripts/render_gate_section.py#431
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
arch/refactor-render-script-single-source

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Refactor

Cluster claimed: scripts/render_pr_body.py, scripts/render_gate_section.py, tests/conftest.py (sys.path comment only), new tests/test_render_single_source.py.
Not touched: any .github/workflows/*.yml, any action.yml, any docs/ file, any bootc-build/ file, and the implementation bodies in .github/actions/render-pr-body/ and .github/actions/render-gate-section/ (unchanged, byte for byte).

The problem

scripts/render_pr_body.py and scripts/render_gate_section.py were byte-identical duplicates of the modules the render-pr-body / render-gate-section composite actions execute via $GITHUB_ACTION_PATH. They were the only duplicated blobs in the whole repository:

100644 759e58df…  .github/actions/render-gate-section/render_gate_section.py
100644 759e58df…  scripts/render_gate_section.py
100644 a7bcdd51…  .github/actions/render-pr-body/render_pr_body.py
100644 a7bcdd51…  scripts/render_pr_body.py

tests/conftest.py puts scripts/ first on sys.path, so the entire pytest suite exercised the scripts/ copies — while the copies that actually run in CI (reusable-promote-squash.yml:288, reusable-release-gate.yml:379) had 0% coverage, and nothing in the repo detected drift between the pairs.

Coverage on main (eb4c546), using the exact unit-tests.yml invocation:

.github/actions/render-gate-section/render_gate_section.py      52     52     0%
.github/actions/render-pr-body/render_pr_body.py                78     78     0%
scripts/render_gate_section.py                                  52      0   100%
scripts/render_pr_body.py                                       78      0   100%
TOTAL                                                          405    142    65%

The change

Make the two scripts/ paths genuine thin re-export wrappers that load the composite-action implementation with importlib and re-export its namespace. This matches the intent already written into the codebase — tests/conftest.py calls them "the shipped wrapper files", and tests/test_script_entrypoints.py already loads them under the module names render_pr_body_wrapper / render_gate_section_wrapper.

Both entry points keep working unchanged: import (import render_pr_body), importlib.util.spec_from_file_location, runpy.run_path(run_name="__main__"), and direct python3 scripts/render_pr_body.py execution.

Adds tests/test_render_single_source.py, which asserts the imported callables have __code__.co_filename pointing into .github/actions/… and that the scripts/ files are wrappers rather than restatements — so the duplication cannot be reintroduced silently.

Verification

Same unit-tests.yml pytest invocation, after the change:

.github/actions/render-gate-section/render_gate_section.py      52      1    98%
.github/actions/render-pr-body/render_pr_body.py                78      1    99%
scripts/render_gate_section.py                                  12      0   100%
scripts/render_pr_body.py                                       12      0   100%
TOTAL                                                          676     14    98%
313 passed
  • All 311 pre-existing tests still pass; 2 new guard tests added.
  • The files CI actually runs went 0% → 98%/99%; total 65% → 98%.
  • scripts/render_pr_body.py and .github/actions/render-pr-body/render_pr_body.py produce byte-identical output for the same CLI arguments (verified by diff).
  • The new guard tests were confirmed to fail when the old duplicate is restored.
  • No rendering behaviour, workflow, or action interface change.

Refs #430


Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=architect backend=copilot model=claude-opus-5

…der_gate_section

scripts/render_pr_body.py and scripts/render_gate_section.py were
byte-identical duplicates of the modules the render-pr-body and
render-gate-section composite actions execute via $GITHUB_ACTION_PATH.
They were the only duplicated blobs in the repository.

Because tests/conftest.py puts scripts/ first on sys.path, the whole
pytest suite exercised the scripts/ copies, leaving the two files that
actually run in CI at 0% coverage, and nothing detected drift between
the pairs.

Make the scripts/ paths genuine thin re-export wrappers around the
composite-action implementation, matching the intent already recorded in
the conftest comment and the *_wrapper module names in
tests/test_script_entrypoints.py. Add tests/test_render_single_source.py
to fail if the duplication is reintroduced.

No workflow, action.yml, or rendering behaviour changes.

Refs #430

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: kubestellar-hive[bot] <kubestellar-hive[bot]@users.noreply.github.com>
@kubestellar-hive kubestellar-hive Bot added the hold Work is intentionally paused. label Aug 28, 2026
@kubestellar-hive
kubestellar-hive Bot requested review from castrojo and p5 as code owners August 28, 2026 10:04
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Work is intentionally paused.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants