Skip to content

Commit 40174d2

Browse files
v2: Add left-hook pre-push (#1003)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
1 parent 78bae74 commit 40174d2

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ dist/
5252

5353
# Conformance test results
5454
results/
55+
56+
# Ignore local lefthook configuration
57+
lefthook-local.yml

lefthook-local.example.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Optional local lefthook configuration
2+
# To enable this:
3+
# cp lefthook-local.example.yml lefthook-local.yml
4+
5+
pre-commit:
6+
parallel: true
7+
jobs:
8+
- name: 'Typecheck'
9+
run: pnpm typecheck:all
10+
11+
- name: 'Lint Fix & Format'
12+
run: pnpm lint:fix:all
13+
stage_fixed: true
14+
15+
post-checkout:
16+
jobs:
17+
- name: 'Install Dependencies'
18+
run: pnpm install
19+
20+
post-merge:
21+
jobs:
22+
- name: 'Install Dependencies'
23+
run: pnpm install

lefthook.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# lefthook.yml
2+
# Configuration reference: https://lefthook.dev/configuration/
3+
4+
assert_lefthook_installed: true
5+
6+
output:
7+
- meta # Print lefthook version
8+
- summary # Print summary block (successful and failed steps)
9+
- empty_summary # Print summary heading when there are no steps to run
10+
- success # Print successful steps
11+
- failure # Print failed steps printing
12+
- execution # Print any execution logs (but prints if the execution failed)
13+
- execution_out # Print execution output (but still prints failed commands output)
14+
- execution_info # Print `EXECUTE > ...` logging
15+
- skips # Print "skip" (i.e. no files matched)
16+
17+
pre-push:
18+
follow: true
19+
parallel: true
20+
jobs:
21+
- name: 'Typecheck'
22+
run: pnpm run typecheck:all
23+
fail_text: |
24+
💡 To catch typechecking issues earlier, enable the pre-commit hook:
25+
cp lefthook-local.example.yml lefthook-local.yml
26+
27+
- name: 'Lint'
28+
run: pnpm run lint:all
29+
fail_text: |
30+
💡 To catch linting issues earlier, enable the pre-commit hook:
31+
cp lefthook-local.example.yml lefthook-local.yml
32+
33+
- name: 'Build'
34+
run: pnpm run build:all
35+
fail_text: |
36+
💡 To catch build issues earlier, enable the pre-commit hook:
37+
cp lefthook-local.example.yml lefthook-local.yml

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"lint:fix:all": "pnpm sync:snippets && pnpm -r lint:fix",
3535
"check:all": "pnpm -r typecheck && pnpm -r lint && pnpm run docs:check",
3636
"test:all": "pnpm -r test",
37+
"prepare": "npx --no-install lefthook install",
3738
"test:conformance:client": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client",
3839
"test:conformance:client:all": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client:all",
3940
"test:conformance:client:run": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client:run",
@@ -43,6 +44,7 @@
4344
"test:conformance:all": "pnpm run test:conformance:client:all && pnpm run test:conformance:server:all"
4445
},
4546
"devDependencies": {
47+
"lefthook": "^2.0.16",
4648
"@cfworker/json-schema": "catalog:runtimeShared",
4749
"@changesets/changelog-github": "^0.5.2",
4850
"@changesets/cli": "^2.29.8",

pnpm-lock.yaml

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)