From ec0ad14cdf4eee322c771894e532aadeb704f647 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Mon, 18 May 2026 12:46:19 +0700 Subject: [PATCH] update CI to validate pre-commit hooks Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Alfi Maulana --- .github/workflows/ci.yaml | 18 +++++++----------- CLAUDE.md | 2 +- README.md | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe79e505..1ce36ece 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,25 +12,21 @@ jobs: - name: Checkout uses: actions/checkout@v6.0.2 + - name: Install Lefthook + run: | + curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash + sudo apt install lefthook + - name: Setup pnpm uses: threeal/setup-pnpm-action@v1.0.0 with: version: 10.33.4 - - name: Install dependencies - run: pnpm install - - - name: Check types - run: pnpm tsc + - name: Check pre-commit hook + run: lefthook run pre-commit --all-files - name: Test run: pnpm test - - name: Check formatting - run: pnpm prettier --check . - - - name: Check lint - run: pnpm eslint - - name: Package run: pnpm pack diff --git a/CLAUDE.md b/CLAUDE.md index c1f20313..34665933 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,5 +46,5 @@ The development workflow uses **jiti** to run `src/bin.ts` directly without a co - **ESLint** uses flat config (`eslint.config.ts`) with `typescript-eslint` strict + stylistic type-checked rules. - **Prettier** uses `prettier-plugin-organize-imports` — import order is auto-managed. -- **Lefthook** is an external tool (not a dev dependency) that manages Git hooks. It must be installed independently and set up with `lefthook install`. Pre-commit hooks run type-check → format → lint with `fail_on_changes: always`, so hooks can auto-fix files but will abort the commit if any file changed, requiring a re-stage. +- **Lefthook** is an external tool (not a dev dependency) that manages Git hooks. It must be installed independently and set up with `lefthook install`. Pre-commit hooks run type-check → format → lint with `fail_on_changes: always`, so hooks can auto-fix files but will abort the commit if any file changed, requiring a re-stage. The CI also validates the pre-commit hook by running `lefthook run pre-commit --all-files`. - **Vitest** requires 100% code coverage (lines, functions, branches, statements) enforced via the `coverage` threshold in `vitest.config.ts`. diff --git a/README.md b/README.md index 012feb89..f4569102 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This template provides a basic Node.js project containing a sample library writt - Uses [pnpm](https://pnpm.io/) as the package manager. - Supports formatting with [Prettier](https://prettier.io/), linting with [ESLint](https://eslint.org/), and testing with [Vitest](https://vitest.dev/). - Fixes formatting and linting during pre-commit hooks using [Lefthook](https://lefthook.dev/). -- Preconfigured workflows for [Dependabot](https://docs.github.com/en/code-security/dependabot) and [GitHub Actions](https://github.com/features/actions). +- Preconfigured [Dependabot](https://docs.github.com/en/code-security/dependabot) and [GitHub Actions](https://github.com/features/actions) workflows that validate the pre-commit hook. ## Usage