Skip to content

Guard against false-positive command coverage check when package commands fail to load#216

Merged
swissspidy merged 2 commits intoadd/command-check-workflowfrom
copilot/sub-pr-213
Mar 4, 2026
Merged

Guard against false-positive command coverage check when package commands fail to load#216
swissspidy merged 2 commits intoadd/command-check-workflowfrom
copilot/sub-pr-213

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

If wp cli cmd-dump succeeds but the package's commands never registered (e.g. autoloader failure), REGISTERED contains only built-in WP-CLI commands. The existing loop finds no mismatches and exits cleanly with "All commands correctly documented." — a silent false positive.

Changes

  • Pre-flight validation: After computing REGISTERED, iterate over the documented root commands (ROOTS) and assert at least one is present in the registered set. If none match, fail with an actionable error:
    ::error::None of the documented root commands were found in the registered commands. Package commands may have failed to load.
    
    This gates the missing-command check on evidence that the package actually loaded, preventing the check from vacuously passing.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…mands

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on workflow for detecting missing commands in README Guard against false-positive command coverage check when package commands fail to load Mar 4, 2026
@swissspidy swissspidy marked this pull request as ready for review March 4, 2026 09:41
@swissspidy swissspidy requested a review from a team as a code owner March 4, 2026 09:41
Copilot AI review requested due to automatic review settings March 4, 2026 09:41
@swissspidy swissspidy merged commit 25d455c into add/command-check-workflow Mar 4, 2026
11 checks passed
@swissspidy swissspidy deleted the copilot/sub-pr-213 branch March 4, 2026 09:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the reusable README-regeneration workflow to avoid a false-positive “command coverage” pass when wp cli cmd-dump succeeds but the package’s commands never actually register (e.g., autoloader failure), by ensuring there’s evidence that the package’s documented command roots are present in the dumped command set.

Changes:

  • Add a pre-flight check that verifies at least one documented root command appears in the registered command list before running the missing-command detection.
  • Fail early with a GitHub Actions ::error::... message when none of the documented roots are found, preventing a vacuous pass.
Comments suppressed due to low confidence (1)

.github/workflows/reusable-regenerate-readme.yml:117

  • The failure message implies only a package load problem, but this condition can also happen when extra.commands is out of sync (e.g., roots renamed/removed) even if the package loaded correctly. Consider expanding the message to mention both likely causes and include the documented roots to aid debugging.
          if [ "$FOUND_ROOT" -eq 0 ]; then
            echo "::error::None of the documented root commands were found in the registered commands. Package commands may have failed to load."
            exit 1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants