test(scaffold): cover the pre-commit mockery hook (run-mockery.sh)#131
Merged
Conversation
run-mockery.sh is the entry point of the pre-commit `mockery` hook; its job is the guarded no-op that keeps a fresh clone's first commit green until the project adds a mockery config, and a helpful exit-1 (not a bare `command not found`) once a config exists but mockery is not installed. It had no coverage, while its sibling rename-placeholders.sh is fully test-paired and CI-gated. Add a hermetic run-mockery.test.sh that runs the real script under a stripped PATH and pins all three branches (silent no-op without config; exit 1 + install hint when mockery absent; exec when present), and wire it into the existing template-repo-only validate-scaffold.yaml gate alongside the onboarding-script test. Docs synced in AGENTS.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
.github/scripts/run-mockery.shis theentryof the pre-commitmockeryhook (.pre-commit-config.yaml), but it had no test coverage — while its siblingscripts/rename-placeholders.shis fully test-paired and CI-gated byvalidate-scaffold.yaml.The script exists for one reason: the scaffold ships no interfaces and no mockery config, so the hook must be a guarded no-op that keeps a fresh clone's first commit green, and must fail with a helpful install hint (not a bare
command not found) once a config exists butmockeryisn't installed. A silent regression here — e.g. "simplifying" it to a bareexec mockery— would make every fresh clone's first commit fail, with nothing to catch it.Change (behaviour-preserving — test + wiring only)
.github/scripts/run-mockery.test.sh— a hermetic test that runs the real script against throwaway working directories under a strippedPATH(so the missing-mockery case is guaranteed, not dependent on the runner's installed tools) and pins all three branches:.mockery.yml/.mockery.yaml→ silent no-op, exit 0;mockeryPATH-absent → exit 1 with thego install …hint;mockerypresent → it isexec'd (verified via a/bin/shstub + marker)..github/workflows/validate-scaffold.yaml— runs the new test alongside the existing onboarding-script test (same template-repo-only gate; no-ops in generated projects via thegithub.repositoryguard).AGENTS.md— Structure + Validation sections synced to list the new test and the broadened gate.Validation
sh .github/scripts/run-mockery.test.sh→ PASS (all three branches).shellcheck .github/scripts/run-mockery.test.sh→ clean.actionlint .github/workflows/validate-scaffold.yaml→ clean.run-mockery.shmakes the test FAIL (no-config case exits 1 instead of 0); restoring it passes — confirming the test catches a real regression.No production/script behaviour changed.