From 9547b0c9d10d6fe7d22a57ed0fe2f9f8fe51b200 Mon Sep 17 00:00:00 2001 From: kitsuyui Date: Wed, 10 Jun 2026 01:47:29 +0900 Subject: [PATCH] chore: add lefthook to run CI checks locally Mirrors the lint and test scripts from CI into pre-commit and pre-push hooks. CI workflow is unchanged. --- README.md | 15 +++++++++++++++ lefthook.yml | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lefthook.yml diff --git a/README.md b/README.md index 1214ac5..72958ad 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,21 @@ jobs: This repository keeps a local example workflow in `.github/workflows/main.yml`. It uses `pull_request` and `uses: ./` so changes in the current branch are tested before release. That pattern should stay limited to the action repository itself, because a local action from an untrusted fork must not run with `pull_request_target`. +## Development + +Install [lefthook](https://github.com/evilmartians/lefthook) and run: + +```sh +lefthook install +``` + +This sets up the following Git hooks: + +- **pre-commit**: runs `bun run lint` (Biome checks) — fast static feedback before each commit. +- **pre-push**: runs `bun run lint` and `bun run test` — full local validation before pushing. + +CI still runs the complete suite on every pull request and push to main; the hooks bring that feedback earlier in your workflow. + ## License MIT diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..331d78d --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,13 @@ +# Clear Git hook environment variables before running checks so nested or sibling +# repositories are not affected: https://git-scm.com/docs/githooks +pre-commit: + jobs: + - name: lint + run: for name in $(env | sed -n 's/^\(GIT_[A-Za-z0-9_]*\)=.*/\1/p'); do unset "$name"; done; bun run lint + +pre-push: + jobs: + - name: lint + run: for name in $(env | sed -n 's/^\(GIT_[A-Za-z0-9_]*\)=.*/\1/p'); do unset "$name"; done; bun run lint + - name: test + run: for name in $(env | sed -n 's/^\(GIT_[A-Za-z0-9_]*\)=.*/\1/p'); do unset "$name"; done; bun run test