From cf4f06a6a2bf44e1e3295be5f743702e75907f4a Mon Sep 17 00:00:00 2001 From: "yk-lab (k.yamada)" Date: Mon, 6 Jul 2026 01:22:27 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20lefthook=20=E3=81=A7=20pre-push=20?= =?UTF-8?q?=E3=81=AB=20CI=20=E7=9B=B8=E5=BD=93=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=92=E4=BB=95=E8=BE=BC=E3=82=80=EF=BC=88#9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit push 前に typecheck / lint / test / build をローカル実行し、失敗を CI より先に 検出する。lefthook で 4 チェックを並列実行(逐次より速く、どれが落ちたか一目)。 - lefthook.yml(新規): pre-push で typecheck/lint/test/build を parallel 実行 - package.json: lefthook を devDependencies に - pnpm-workspace.yaml: allowBuilds で lefthook の postinstall を許可 (`pnpm install` で pre-push hook が自動インストールされる) - CLAUDE.md: pre-push hook の説明を追記 - TODO.md: #9 を解決済み(#71)へ 補足: 元 issue の「dist 差分で fail」は #36 で dist 未コミット化され前提消滅。 本 PR は残る価値(CI 判定のローカル再現)を実装。lefthook run --all-files で 4 ジョブ green を確認済み。 Closes #9 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01AECzAv2vcdATecuvLjBSa6 --- CLAUDE.md | 5 +++ TODO.md | 2 +- lefthook.yml | 15 +++++++ package.json | 1 + pnpm-lock.yaml | 100 ++++++++++++++++++++++++++++++++++++++++++++ pnpm-workspace.yaml | 3 ++ 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 lefthook.yml diff --git a/CLAUDE.md b/CLAUDE.md index e2729d1..3027d7c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,6 +24,11 @@ pnpm exec vitest run tests/version.test.ts # run a single test file pnpm exec vitest run -t "resolves a semver range" # run tests matching a name ``` +A **lefthook `pre-push` hook** runs typecheck / lint / test / build in parallel so +CI failures surface locally first. `pnpm install` sets it up automatically +(lefthook's post-install is approved in `pnpm-workspace.yaml` `allowBuilds`); run +`pnpm exec lefthook install` if the hook ever goes missing. + ## Critical: `dist/` is built at release time, NOT committed to source branches GitHub Actions runs the bundled `dist/index.js` directly (see `action.yml` → `main: dist/index.js`), **not** the TypeScript source — so a consumed ref must contain `dist/`. This repo keeps `dist/` **out of `main`** (`.gitignore`d) and builds it at release time, committing it **only onto the release tag**. Consequences: diff --git a/TODO.md b/TODO.md index 1367fa6..1b3c150 100644 --- a/TODO.md +++ b/TODO.md @@ -31,7 +31,6 @@ | # | 概要 | 優先度 | 参照 | 備考 | |---|---|---|---|---| -| [#9](https://github.com/yk-lab/setup-task/issues/9) | `[chore]` lefthook で pre-push に `pnpm run all` を仕込む | `P3: low` | `ci` `chore` | stale dist / 未 lint コミット防止 | ### 未対応・進行中(リリース運用 / M3・M4) @@ -82,3 +81,4 @@ v1.0.0 実装中に作成・解決済みの Issue(参考)。 | [#45](https://github.com/yk-lab/setup-task/issues/45) | `[chore]` Biome 導入を評価 → 一元化採用 | #70 | | [#38](https://github.com/yk-lab/setup-task/issues/38) | `[docs]` README に arduino/setup-task からの移行ガイドを追加 | #72 | | [#73](https://github.com/yk-lab/setup-task/issues/73) | `[docs]` セキュア路線へポジショニング見直し(arduino v3 を受けて) | #72 | +| [#9](https://github.com/yk-lab/setup-task/issues/9) | `[chore]` lefthook で pre-push に `pnpm run all` を仕込む | #71 | diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..8a0abf1 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,15 @@ +# Pre-push gate: run the same checks CI does — in parallel, so every failure +# surfaces at once, locally, before a push spends CI minutes. `dist/` is built +# at release time and not committed, so there's nothing to diff; this just fails +# on typecheck / lint / test / build errors (#9). +pre-push: + parallel: true + jobs: + - name: typecheck + run: pnpm run typecheck + - name: lint + run: pnpm run lint + - name: test + run: pnpm run test + - name: build + run: pnpm run build diff --git a/package.json b/package.json index b85ecc4..0e10b0c 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@types/semver": "^7.5.8", "@vercel/ncc": "^0.44.0", "@vitest/coverage-v8": "^4.1.9", + "lefthook": "^2.1.9", "typescript": "^6.0.3", "vitest": "^4.1.9" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 80beadc..aacd2da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,6 +36,9 @@ importers: '@vitest/coverage-v8': specifier: ^4.1.9 version: 4.1.9(vitest@4.1.9) + lefthook: + specifier: ^2.1.9 + version: 2.1.9 typescript: specifier: ^6.0.3 version: 6.0.3 @@ -391,6 +394,60 @@ packages: js-tokens@10.0.0: resolution: {integrity: sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==} + lefthook-darwin-arm64@2.1.9: + resolution: {integrity: sha512-119HryNcvr4nqn0wUIrNPgpMEPn9yMQzEcW/lezRsnb56PCJriJB92+MCySPVcWDxJnZef7o0T3jdnPNiSH7Qg==} + cpu: [arm64] + os: [darwin] + + lefthook-darwin-x64@2.1.9: + resolution: {integrity: sha512-dwo5Tke2XcQCM56DGHgFKBfRbJIL6xs2wZ0zG1TUVZgl4t4mQUt6LiZ4V/ZQfYHTZF9qywvXoIlR5N35qOaiVQ==} + cpu: [x64] + os: [darwin] + + lefthook-freebsd-arm64@2.1.9: + resolution: {integrity: sha512-+09PVap6nl6xsaHch5JLtq7WvIR++U1Q2MzA2ai0M4uB/VP3AqrvKqHw6+9hjyKnIH+HHL83uqi77EAY+LaxLA==} + cpu: [arm64] + os: [freebsd] + + lefthook-freebsd-x64@2.1.9: + resolution: {integrity: sha512-8XresjKIYpkE9ARgCtBEZgJZxAU3T4MIqzj4zNy15XRT59I1Us+QdqXTNm+pkZ41Yd2X/nxs2Pkvbq3NWWlIGw==} + cpu: [x64] + os: [freebsd] + + lefthook-linux-arm64@2.1.9: + resolution: {integrity: sha512-1oNIQfwrPe6rgU2KcDM3aF6+hpZDCKx1TmawQKpXUY5gVsbZ7MqX0Sk/1lnnWxqPm+kQQ5f6J2dpFWd+4xH8jg==} + cpu: [arm64] + os: [linux] + + lefthook-linux-x64@2.1.9: + resolution: {integrity: sha512-fT+7Q+BJyGp+CslFQkNXmdFRgyVXsPHPi9NAsDX0a6QOyNnoORByAsvx6zeAKuF5rL3BBgNfho1/v2RuGxGy9w==} + cpu: [x64] + os: [linux] + + lefthook-openbsd-arm64@2.1.9: + resolution: {integrity: sha512-4bVuafBk3dddVNo0+3hMbjcJs4mqYAstxpPMmX2ufkudSTYFNIhWoqwuGVQV/SS/xdcOKJAldW4qayAzed2ysw==} + cpu: [arm64] + os: [openbsd] + + lefthook-openbsd-x64@2.1.9: + resolution: {integrity: sha512-PmPoMmLP/wQQWcQ9u2YH86bTZ3UCfBsxuEmVTEyPU2U8R1qSTp5r/Gs3G8cN5Mxo91XB9oBERtF1n+xD3W6aVA==} + cpu: [x64] + os: [openbsd] + + lefthook-windows-arm64@2.1.9: + resolution: {integrity: sha512-KphfkBKmwBnmolyrdhIl3lrBaOyTcCgXBT2AB/9OHnEXhOLvv5uTCUkrD4YRAxXPtFKq6UvnapIeoL3GZq0bdA==} + cpu: [arm64] + os: [win32] + + lefthook-windows-x64@2.1.9: + resolution: {integrity: sha512-2qlUtkJHZ3MyUxgV5XTEmcrIoNZA07iwaquoswAcqv/1MeBFXlD+O+koFRfrzWng2O5WYEbpJnd8tvaYnV8fTA==} + cpu: [x64] + os: [win32] + + lefthook@2.1.9: + resolution: {integrity: sha512-bwDaIOViTktE8kJLf9jP0p+H2/RDTlFFlc43Am2YgUsX22hI6Sq4RbzsrecwzY5y+MHTipOH7WsmWSEniePHWQ==} + hasBin: true + lightningcss-android-arm64@1.32.0: resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==} engines: {node: '>= 12.0.0'} @@ -936,6 +993,49 @@ snapshots: js-tokens@10.0.0: {} + lefthook-darwin-arm64@2.1.9: + optional: true + + lefthook-darwin-x64@2.1.9: + optional: true + + lefthook-freebsd-arm64@2.1.9: + optional: true + + lefthook-freebsd-x64@2.1.9: + optional: true + + lefthook-linux-arm64@2.1.9: + optional: true + + lefthook-linux-x64@2.1.9: + optional: true + + lefthook-openbsd-arm64@2.1.9: + optional: true + + lefthook-openbsd-x64@2.1.9: + optional: true + + lefthook-windows-arm64@2.1.9: + optional: true + + lefthook-windows-x64@2.1.9: + optional: true + + lefthook@2.1.9: + optionalDependencies: + lefthook-darwin-arm64: 2.1.9 + lefthook-darwin-x64: 2.1.9 + lefthook-freebsd-arm64: 2.1.9 + lefthook-freebsd-x64: 2.1.9 + lefthook-linux-arm64: 2.1.9 + lefthook-linux-x64: 2.1.9 + lefthook-openbsd-arm64: 2.1.9 + lefthook-openbsd-x64: 2.1.9 + lefthook-windows-arm64: 2.1.9 + lefthook-windows-x64: 2.1.9 + lightningcss-android-arm64@1.32.0: optional: true diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f76c7e5..721189a 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,6 @@ +# lefthook installs the git hooks (pre-push) via its postinstall. +allowBuilds: + lefthook: true # Supply-chain hardening: don't install a dependency version until it has been # public for at least 3 days (4320 minutes), giving time for a compromised # release to be yanked. Applies when the lockfile is updated (local installs,