Skip to content

test: unit coverage for tools/rebuild_matrix.py — tests/test_rebuild_matrix.py - #143

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-rebuild-matrix
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-rebuild-matrix

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/test_rebuild_matrix.py — 23 unit cases for tools/rebuild_matrix.py,
the driver .github/workflows/rebuild-rpms.yml runs to decide what the factory
builds.

Claimed ground: tests/test_rebuild_matrix.py (new file, the only file in
this PR) covering tools/rebuild_matrix.py::changed_recipes, changed_inventory,
fetch_published and main. No production file is touched, and no other module
under tools/ is claimed.

Why this module

It was the only module under tools/ with no test at all. The three other
modules reporting 0% line coverage — validate.py, check_workflow_quoting.py,
check_build_container_pinning.py — are exercised as subprocesses by their own
test files, which coverage.py simply cannot see into. rebuild_matrix had
neither: grep -rn rebuild_matrix tests/ Justfile returned nothing.

What is covered

  • changed_recipes — absent, all-zero, short and non-hex BASE_SHA all
    short-circuit before subprocess is reached; package names are taken from the
    path, not the file; paths outside packages/ and a bare packages/<name>
    entry name nothing; inventory changes are unioned in.
  • changed_inventory — an untouched inventory is never read out of git; a stage
    move counts as changed and an identical entry does not; a missing or
    unparseable inventory at the base commit proves nothing rather than everything.
  • fetch_published — an empty FACTORY_REPO fetches nothing; a base URL with no
    trailing slash still joins correctly; both the gzip and the zstd primary are
    decoded.
  • main — outputs are appended as GITHUB_OUTPUT lines; a full run never reads
    the published repository; a published package is skipped and said so; a changed
    recipe is rebuilt even when published; an unreachable mirror warns and rebuilds
    everything rather than failing; a missing factory repository warns and skips
    nothing; a stage split over 250 packages reports the split; a stage ≥ 11 stops
    the run instead of silently dropping packages.

Method

subprocess, urllib.request.urlopen and the module's ROOT are redirected at
the module object, so each case runs the real functions against a synthetic
factory tree. No case touches the network or a real git repository. The zstd
branch stands a recorder in for zstandard, so that path is proven without
adding a test dependency the CI job does not install.

Evidence

Before, on main at a8ab8e0:

tools/rebuild_matrix.py                     78     78     0%   9-162
TOTAL                                     1706    662    61%
316 passed

After:

tools/rebuild_matrix.py      78      1    99%   162
339 passed in 9.72s

The one remaining line is the if __name__ == "__main__" guard.

The cases were checked against mutations rather than only against green: forcing
if not full: to if False: fails 2 cases, and dropping the
changed_inventory union from changed_recipes fails 1.

Related Issue

Closes #142


Filed by quality agent (hold-gated mode). Human review required.

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

tools/rebuild_matrix.py was the only module under tools/ that no test
imported and no test ran as a subprocess: 78 statements at 0%, executed
only by .github/workflows/rebuild-rpms.yml in production.

It is the half of the rebuild decision that talks to the outside world,
and its uncovered paths are the ones that fail quietly rather than
loudly: the absent/all-zero BASE_SHA guard that keeps a scheduled run
from shelling out to an empty diff range, the base-commit inventory
reads that deliberately prove nothing when the file is missing or
unparseable, the mirror failure that rebuilds everything instead of
skipping a package, and the stage-overflow SystemExit that stops the
factory publishing a repository quietly missing those recipes.

Add tests/test_rebuild_matrix.py: 23 cases over changed_recipes,
changed_inventory, fetch_published and main. subprocess, urlopen and the
module's ROOT are redirected at the module object, so every case runs the
real functions against a synthetic factory tree with no network and no
git repository. The zstd branch of fetch_published stands a recorder in
for zstandard, so the branch is proven without adding a test dependency.

Coverage of tools/rebuild_matrix.py goes 0% -> 99%, the remaining line
being the __main__ guard. Suite goes 316 -> 339 passing.

No production code is changed.

Assisted-by: Claude Opus 5 via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the hold Work is intentionally paused. label Sep 18, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

publish / Validate Hummingbird-only consumer transaction is failing here for a repository-wide reason, not because of this PR's diff. The same step fails identically on #139, #141 and #143 — three unrelated diffs — because the factory repo has a broken soname closure (mozc/ibus-mozc vs abseil, libheif vs ffmpeg/openjph, mesa-dri-drivers vs SPIRV-Tools, gvfs vs libnfs/libbluray).

Tracked in #153. Deferring this PR until that incident closes; please don't re-run the check per-PR.

🐝 Hive Agent: scanner | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Blocked by the repository-wide CI incident, not by this diff.

The publish job fails identically on main (run https://github.com/projectbluefin/utah-packages/actions/runs/35326463447, job 105686398800): the Hummingbird-only consumer transaction will not resolve because factory packages reference sonames nothing provides —

nothing provides libnfs.so.16()(64bit) needed by gvfs-nfs-1.61.91-1.hum1.bfin.x86_64 from factory
nothing provides libabsl_*.so.2601.0.0()(64bit) needed by mozc / ibus-mozc ...

This PR adds only tests/test_rebuild_matrix.py and changes no recipe, source lock, or build input.

Tracking in #153; deferring this PR until the baseline is green.

🐝 Hive Agent: quality | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

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

@castrojo castrojo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substantive review:

  • Test Coverage: Adds 23 unit tests in tests/test_rebuild_matrix.py covering tools/rebuild_matrix.py (changed_recipes, changed_inventory, fetch_published, and main driver execution).
  • Isolation: All test cases use synthetic mock directories and URL openers without network dependency.
  • Validation: Factory contract, validate.py, and unittest suite pass cleanly against current main.
  • Outstanding: PR is hold-gated requiring human maintainer review to remove hold label and land.

@hanthor

hanthor commented Sep 20, 2026

Copy link
Copy Markdown
Member

Closing to consolidate the queue on the merged #178 full-factory candidate. The branch is retained; please re-open or submit a fresh, rebased PR after that build establishes the current baseline.

1 similar comment
@hanthor

hanthor commented Sep 20, 2026

Copy link
Copy Markdown
Member

Closing to consolidate the queue on the merged #178 full-factory candidate. The branch is retained; please re-open or submit a fresh, rebased PR after that build establishes the current baseline.

@hanthor hanthor closed this Sep 20, 2026
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.

[quality] coverage-gap: tools/rebuild_matrix.py has zero test coverage — the rebuild-rpms.yml driver

2 participants