Skip to content

[Workflows] Add Husky pre-commit/pre-push with lint-staged + jest/bats #62

Closed

Description

@ashleyshaw

Summary

Add a pre-push Husky hook that runs the Jest and Bats test suites before any push reaches the remote. The pre-commit hook (lint-staged) is already in place — this issue covers the missing push-time gate.

Current State

Hook Status What it does
pre-commit ✅ Exists (.husky/pre-commit) Runs npx lint-staged — ESLint + Prettier on staged JS/TS/MD/JSON/YAML
pre-push ❌ Missing Should run Jest (npm run test:js) and Bats shell tests

Both test runners are already configured and available:

  • Jest — npm run test:js → jest --config .jest.config.cjs --coverage --forceExit --detectOpenHandles
  • Bats — bats is in devDependencies; shell agent specs require .bats test files per the CodeRabbit review instructions

husky and lint-staged are both present in devDependencies and the "prepare": "husky" lifecycle script is wired up.

Work Required

  1. Create .husky/pre-push with:

    #!/usr/bin/env sh
    npm run test:js

    Add a Bats step once .bats test files exist (see [Workflows/Agents] Validate imports/includes; add bats/jest smoke tests #63 — adding smoke tests is a related task).

  2. Verify the hook is executable — Husky requires the hook file to have execute permissions (chmod +x .husky/pre-push). Confirm the prepare script handles this on fresh installs.

  3. Update docs/DEVELOPMENT.md (or equivalent) to document the pre-push behaviour so contributors know pushes will trigger the test suite.

  4. Update CONTRIBUTING.md if it describes local setup, to mention that npm ci (which runs prepare → husky) sets up both hooks.

Out of Scope

Acceptance Criteria

  • .husky/pre-push exists and is executable
  • Running git push locally triggers npm run test:js and fails the push if tests fail
  • Hook is documented in docs/DEVELOPMENT.md or equivalent
  • CONTRIBUTING.md local-setup section references the hook
  • No regressions to the existing pre-commit hook
  • PR uses branch prefix automation/ or fix/

Definition of Ready (DoR)

Definition of Done (DoD)

  • All acceptance criteria met
  • Hook tested on a clean npm ci install
  • Documentation updated
  • Approved by maintainer

Activity

  1. added this to the milestone on May 27, 2026
  2. self-assigned this
    on May 27, 2026
  3. ashleyshaw commented on May 27, 2026

    @ashleyshaw
    MemberAuthor

    Started implementation in PR #458.

  4. added a commit that references this issue on May 27, 2026
  5. added 2 commits that reference this issue on May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions