Skip to content

test(packit): executed coverage for package_chunks and the packit_workflow CLI - #200

Merged
castrojo merged 2 commits into
mainfrom
quality/test-packit-workflow-cli
Sep 26, 2026
Merged

castrojo merged 2 commits into
mainfrom
quality/test-packit-workflow-cli

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Fresh, rebased replacement for #152, which @hanthor closed with: "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." This branch is cut from current main
(post-#178); the retained quality/test-packit-workflow-chunks branch is left
untouched.

Claimed ground: tests/test_packit_workflow.py only — covering
tools/packit_workflow.py package_chunks() and main(). No production code
is changed. This is disjoint from #192 (tools/rebuild_matrix.py,
tests/test_rebuild_matrix.py) and from #194 (architecture inventory counts).

package_chunks() and main() had zero coverage — the existing suite
exercised only package_names() and result().

package_chunks is the guard against GitHub expanding a matrix larger than
256 jobs to zero jobs without failing, which is what
.github/workflows/packit-srpm-pilot.yml feeds into matrix.chunk via
fromJson. A regression there is not a red run — it is a green run that built
nothing.

Added:

  • default chunk size stays under the 256-job cap
  • a list below the cap is one chunk; above it splits, and no chunk exceeds the cap
  • chunking is lossless and order-preserving
  • an empty package list yields an empty matrix, not a chunk holding nothing
  • package_chunks(..., size=0) and a negative size raise ValueError
  • packages / chunks / result subcommands print the JSON shapes the workflow consumes, driven as CI drives them, including --nevra defaulting
  • an invalid --status and a missing subcommand exit non-zero
  • the __main__ entrypoint propagates the exit code

Evidence

Before:

$ python3 -m coverage report --show-missing --include=tools/packit_workflow.py
tools/packit_workflow.py      37     20    46%   37, 52-74, 78

After:

tools/packit_workflow.py      37      0   100%

Full suite (python3 -m pytest tests -q, the command validate.yml:32 runs):
396 passed before, 411 passed after — no existing test changed.

Mutation check: raising MATRIX_CHUNK to 300 fails
test_default_chunk_size_stays_under_the_github_matrix_cap and
test_a_list_above_the_cap_is_split_and_no_chunk_exceeds_it, so the cap guard
is genuinely asserted rather than restated.

Related Issue

Closes #151

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

… CLI

package_chunks() and main() had zero coverage: tests/test_packit_workflow.py
exercised only package_names() and result(), leaving tools/packit_workflow.py
at 46%.

The uncovered half is what packit-srpm-pilot.yml depends on. package_chunks
exists because GitHub expands a matrix larger than 256 jobs to zero jobs
without failing, so a regression there is a green run that builds nothing.

Adds assertions that the default chunk size stays under the 256-job cap, that
splitting is lossless and order-preserving, that an empty package list yields
an empty matrix rather than an empty job, that a non-positive size is refused,
and that the packages/chunks/result subcommands print the JSON shapes the
workflow consumes - including the non-zero exits for an invalid --status and a
missing subcommand.

tools/packit_workflow.py coverage: 46% -> 100%.

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 20, 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 hivecommons-hive Bot added quality Code quality or test-coverage work. testing Test authoring or test infrastructure. agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq labels Sep 20, 2026

@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.

Reviewed: Adds thorough test coverage for package_chunks and the packit_workflow CLI in tests/test_packit_workflow.py. Clean trial merge and passes all tests. Carries maintainer 'hold' label; awaiting maintainer removal of hold and second independent review to satisfy merge policy.

@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.

Reviewed: Adds thorough test coverage for package_chunks and the packit_workflow CLI in tests/test_packit_workflow.py. Clean trial merge and passes all tests. Carries maintainer 'hold' label; awaiting maintainer removal of hold and second independent review to satisfy merge policy.

@castrojo

Copy link
Copy Markdown
Contributor

Reviewed: Adds thorough test coverage for package_chunks and the packit_workflow CLI in tests/test_packit_workflow.py. Clean trial merge and passes all tests. Carries maintainer 'hold' label; awaiting maintainer removal of hold and second independent review to satisfy merge policy.

@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.

Reviewed: Adds thorough test coverage for package_chunks and the packit_workflow CLI in tests/test_packit_workflow.py. Clean trial merge and passes all tests. Carries maintainer 'hold' label; awaiting maintainer removal of hold and second independent review to satisfy merge policy.

@Danathar Danathar 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.

Reviewed at ff592a6. The only change is tests/test_packit_workflow.py; tools/packit_workflow.py is untouched. The new cases call package_chunks() and main() directly (argv patched, stdout captured, the main path via runpy), and pytest --cov shows 97% of the module executed, the missing line being the if name guard itself. Mutation check on my side: MATRIX_CHUNK = 300 fails one test, an off-by-one in the chunk range (size + 1) fails one test, and changing the --nevra default fails one test, so the cap, the lossless split and the CLI defaults are genuinely asserted. Full suite passes at this head (411 passed) and after a trial merge of current main (426 passed); validate.py, factory_contract.py, runtime_contract.py --check and check_workflow_quoting.py pass. The PR still carries the hive hold label, which needs a maintainer to remove.

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test-only change to tests/test_packit_workflow.py. It merges cleanly into main and the 17 tests pass there. The red and cancelled checks are stale factory-build runs on the old head, which a test file can't affect. The hold label still needs removing before this merges.

@castrojo
castrojo merged commit 53fc357 into main Sep 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Filed or owned by the quality agent. hold Work is intentionally paused. quality Code quality or test-coverage work. testing Test authoring or test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] coverage-gap: packit_workflow.package_chunks and main() CLI are untested — the 256-job matrix cap guard has zero assertions

3 participants