greenberries-testbot
v1.0.0
Published
Universal pre-commit/pre-deploy test runner for Greenberries projects.
Readme
greenberries-testbot
Universal pre-commit and pre-deploy test runner for Greenberries projects. Auto-detects project type, runs every layer, blocks commits on any failure.
Install globally (once)
npm install -g /Users/danz0-home/Documents/projects/testbotAdd to a project (30 seconds)
cd ~/Documents/projects/your-project
# 1. Install git hooks
testbot install
# 2. Copy GitHub Actions workflow
mkdir -p .github/workflows
cp ~/Documents/projects/testbot/templates/github/ci.yml .github/workflows/testbot-ci.ymlDone. Every git commit now runs the full gate. Push only happens if CI passes.
What it checks
| Layer | What | Blocks commit |
|---|---|---|
| secrets | .env files staged, API keys in diff | Yes |
| dead-code | debugger, PII in logs, temp files staged | Yes (warn for console.log) |
| env-check | .env.example present and in sync | Yes |
| audit | npm audit --audit-level=high | Yes |
| typecheck | tsc --noEmit or node --check on staged files | Yes |
| lint | ESLint with zero warnings | Yes |
| unit | npm run test:ci or npm test | Yes |
| nextjs-audit | Suspense, SSR safety, metadataBase, netlify.toml | Yes (Next.js only) |
| build | npm run build | Yes |
| integration | npm run test:integration (if present) | Yes (Node.js API only) |
Commands
testbot # run full suite
testbot install # install .git/hooks/pre-commit and pre-push
testbot uninstall # remove hooks
testbot --skip=audit,build # skip specific layers
testbot --ci # CI modeSkip a layer for one commit
git commit --no-verify # bypass all hooks (use sparingly)
TESTBOT_SKIP=audit git commit # not implemented yet - use --no-verifyPer the Greenberries commit convention: always use --no-verify and run tsc + eslint manually first. The hooks are the safety net, not the first line of defense.
Build pipeline integration
GitHub Actions
The workflow in templates/github/ci.yml runs all layers on every push and PR. Copy it into .github/workflows/.
Netlify deploy gate
In your Netlify site settings: Settings > Build & deploy > Deploy notifications > turn on "Deploy to production" only when CI passes. Use the Branch deploys setting to deploy main only after GitHub checks pass (requires enabling "Required status checks" on the branch in GitHub).
Railway deploy gate
Railway auto-deploys on push to main. To gate it:
- In GitHub: Settings > Branches > Add rule for
main> require status checks to pass - Select
testbot / Full test gateas a required check - Railway only sees the push after GitHub allows it through (but Railway triggers independently - use GitHub Actions for Railway deploys instead for true gating)
Adding to a new project (checklist)
- [ ]
testbot install- hooks in .git/hooks/ - [ ] Copy
templates/github/ci.ymlto.github/workflows/testbot-ci.yml - [ ] In GitHub: Settings > Branches > Protect
main> requiretestbot / Full test gate - [ ] For Netlify: configure deploy notifications or use
templates/github/deploy-gate.yml - [ ] Add secrets to GitHub Actions: Settings > Secrets and variables > Actions
Updating testbot
cd ~/Documents/projects/testbot
# make your changes
npm install -g . # reinstall globally
# hooks in all projects automatically use the new version
# (hooks call the global testbot binary by absolute path)