Skip to content

fix: add missing run-mockery.sh for the pre-commit mockery hook#92

Merged
devantler merged 2 commits into
mainfrom
claude/fix-mockery-precommit-hook
Jun 7, 2026
Merged

fix: add missing run-mockery.sh for the pre-commit mockery hook#92
devantler merged 2 commits into
mainfrom
claude/fix-mockery-precommit-hook

Conversation

@devantler

Copy link
Copy Markdown
Contributor

🤖 Generated by the Daily AI Assistant

Problem

.pre-commit-config.yaml wires a local mockery hook that runs
.github/scripts/run-mockery.sh:

  - repo: local
    hooks:
      - id: mockery
        name: Generate mocks with mockery
        entry: .github/scripts/run-mockery.sh
        language: script
        files: '\.go$'
        pass_filenames: false

…but that script does not exist (.github/scripts/ is absent). With
language: script, pre-commit executes the entry directly, so every commit
that touches a .go file fails
the hook on a fresh clone of the scaffold —
and the README advertises this very feature: "A pre-commit hook runs
golangci-lint formatting (and mockery mock generation) locally on commit."

Because this is a template, the broken hook propagates to every project
scaffolded from it.

mockery is clearly intended: .github/workflows/copilot-setup-steps.yml
installs it (go install github.com/vektra/mockery/v3@v3.5.4). The fix is to
supply the missing script, not to remove the hook.

Fix

Add .github/scripts/run-mockery.sh (executable, 100755). It is written to be
template-friendly:

  • The scaffold ships an empty, idiomatic layout — no interfaces and no mockery
    config — so there is nothing to generate yet. The script no-ops (exit 0)
    until a .mockery.yml/.mockery.yaml exists
    , keeping the pre-commit hook
    green on a fresh clone.
  • Once a consumer adds a mockery config, it runs mockery (resolved from
    PATH, matching the go install …/mockery/v3@v3.5.4 the Copilot setup
    workflow performs). If a config is present but mockery is not installed, it
    exits non-zero with a clear install hint rather than silently skipping
    (stale-mock safety).

No behaviour change for the empty scaffold beyond unbreaking the hook;
golangci-lint-fmt is untouched.

Validation

  • shellcheck .github/scripts/run-mockery.sh → clean.
  • No config (template state) → exit 0. ✓
  • Config present, mockery absent → exit 1 with install hint. ✓
  • Executable bit committed (git ls-files -s100755).
  • No Go sources changed (go build/go test unaffected).

Trade-offs / alternatives considered

  • Removing the mockery hook + README claim instead — rejected: the Copilot
    setup workflow installs mockery, so the feature is intended; removing it would
    drop advertised functionality.
  • Shipping a .mockery.yml — out of scope: the scaffold has no interfaces
    to mock, and ksail's config enumerates project-specific packages (not
    portable). Generating mock config belongs to the consumer, hence the
    no-op-until-configured design.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 6 0 0 0.36s
✅ ACTION zizmor 6 0 0 0 1.34s
✅ BASH bash-exec 1 0 0 0.01s
✅ BASH shellcheck 1 0 0 0.02s
✅ BASH shfmt 1 0 0 0 0.01s
✅ COPYPASTE jscpd yes no no 0.92s
✅ EDITORCONFIG editorconfig-checker 29 0 0 0.06s
✅ GO golangci-lint yes yes no no 20.5s
✅ JSON jsonlint 1 0 0 0.37s
✅ JSON prettier 1 0 0 0 0.63s
✅ JSON v8r 1 0 0 2.12s
✅ MARKDOWN markdownlint 5 0 0 0 0.9s
✅ MARKDOWN markdown-table-formatter 5 0 0 0 0.27s
✅ REPOSITORY checkov yes no no 37.78s
✅ REPOSITORY gitleaks yes no no 0.17s
✅ REPOSITORY git_diff yes no no 0.01s
✅ REPOSITORY grype yes no no 60.92s
✅ REPOSITORY osv-scanner yes no no 2.27s
✅ REPOSITORY secretlint yes no no 0.94s
✅ REPOSITORY syft yes no no 1.44s
✅ REPOSITORY trivy yes no no 8.7s
✅ REPOSITORY trivy-sbom yes no no 0.22s
✅ REPOSITORY trufflehog yes no no 3.97s
✅ SPELL lychee 16 0 0 1.34s
✅ YAML prettier 10 0 0 0 0.54s
✅ YAML v8r 10 0 0 11.53s
✅ YAML yamllint 10 0 0 0.56s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@devantler devantler marked this pull request as ready for review June 7, 2026 14:54
@devantler devantler merged commit ed7d191 into main Jun 7, 2026
17 checks passed
@devantler devantler deleted the claude/fix-mockery-precommit-hook branch June 7, 2026 16:13
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.

1 participant