test(check): add subprocess-based test suite + wire into CI#234
Open
RJK134 wants to merge 2 commits into
Open
Conversation
The 4 vertical plugins (private-equity, financial-analysis, equity-research,
wealth-management) had `hooks.json` written as `[]`, which the Claude Code
plugin loader rejects with `expected: "record", path: ["hooks"], received:
undefined`. Investment-banking already had the correct `{"hooks": {}}` shape.
This corrects the 4 files, adds a hooks.json schema check to `scripts/check.py`
(fails CI on any future regression of this shape), and wires `check.py` into a
new `check` GitHub Actions workflow that runs on every PR + push to main.
Supersedes the duplicate community PRs that have been queuing on this issue
(anthropics#226, anthropics#225, anthropics#224, anthropics#221, anthropics#216, anthropics#206, anthropics#203, anthropics#200, anthropics#193, anthropics#192, anthropics#167, anthropics#163,
anthropics#162, anthropics#146, anthropics#141, and others).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds `scripts/tests/{conftest.py,test_check.py}` covering:
- hooks.json schema validator (Phase 1 / anthropics#231 regression coverage):
array form, missing `hooks` key, malformed JSON
- agent.md missing-frontmatter detection
- system.file ref-resolution failure
- bundled-skill drift detector (sync-agent-skills.py prompt)
- marketplace `source` path resolution
- missing required cookbook files (steering-examples.json)
- clean-tree baseline
Tests use a tmpdir fixture (`minimal_repo`) that builds a minimal-valid repo
skeleton and copies `check.py` into it so the script's
`Path(__file__).resolve().parents[1]` lands on the fixture. Each test mutates
exactly one file and asserts exit code + specific error string. No production
code refactor required.
Extends `.github/workflows/check.yml` to install pytest and run the suite
after `check.py` on every PR + push to main.
Supersedes community PR anthropics#214 (which only covered `rel()` and `err()`).
Stacked on anthropics#231 (which adds the hooks.json validator under test) — base will
auto-rebase to `main` after anthropics#231 merges.
Co-Authored-By: Claude Opus 4.7 <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.
Summary
Adds a real test suite for
scripts/check.pycovering both the new hooks.json validator (#231) and the existing validators that previously had no regression coverage.scripts/tests/conftest.py—minimal_repofixture builds a minimal-valid repo skeleton in a tmpdir and copiescheck.pyinto it. Tests mutate one file each and assert exit code + specific error string.scripts/tests/test_check.py— 9 tests covering:hookskey, malformed JSON)system.fileref-resolution failuresourcepath resolutionsteering-examples.json).github/workflows/check.ymlto install pytest and run the suite aftercheck.pyon every PR + push to main.No production code refactor — tests run check.py as a subprocess inside the fixture so the script is exercised as it actually runs in CI.
Why this approach (vs PR #214)
Community PR #214 covered only
rel()anderr()— two trivial 1-line helpers. This PR exercises the actual validator logic that produces real CI signal, including regression coverage for the hooks.json bug class that produced the 27-PR queue cleared by #231.Stacking
This PR is stacked on #231 (
fix/hooks-json-schema-and-ci-guard). The diff againstmainshows two commits — the Phase 1 hooks.json fix + this Phase 3 test suite — because the hooks.json tests need the validator that #231 adds. When #231 merges, this PR auto-narrows to only the test-suite commit.Verification
python3 -m pytest scripts/tests/ -v— all 9 tests pass locally (Python 3.12.3, pytest 9.0.3).python3 scripts/check.py— still clean (OK — 85 file(s) checked, 0 issues.).checkworkflow runs the test suite green onmain.Test plan
🤖 Generated with Claude Code