Skip to content

Commit a0cb075

Browse files
committed
introduce prepush git hook (#408)
- Adds a 'prepush' target to multiple projects that includes fast-running checks - Enables caching selectively in multiple prepush dependencies - Adds a pre-push git hook to lefthook.yml that invokes prepush with nx affected
1 parent f1f7e06 commit a0cb075

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

lefthook.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ post-checkout:
4545
fi
4646
'claude-symlink':
4747
run: |
48-
if [ -n "$CLAUDE_SYMLINK_SCRIPT" ] && [ -f "$CLAUDE_SYMLINK_SCRIPT" ]; then
49-
"$CLAUDE_SYMLINK_SCRIPT" "$PWD"
50-
elif [ -z "$CLAUDE_SYMLINK_SCRIPT" ]; then
51-
echo "\033[33mWarning: CLAUDE_SYMLINK_SCRIPT not set. See LOCAL_DEV.md for setup instructions.\033[0m"
48+
# Only run for branch checkouts (not file checkouts)
49+
if [ "{3}" = "1" ]; then
50+
if [ -n "$CLAUDE_SYMLINK_SCRIPT" ] && [ -f "$CLAUDE_SYMLINK_SCRIPT" ]; then
51+
"$CLAUDE_SYMLINK_SCRIPT" --yes "$PWD"
52+
elif [ -z "$CLAUDE_SYMLINK_SCRIPT" ]; then
53+
echo "\033[33mWarning: CLAUDE_SYMLINK_SCRIPT not set. See LOCAL_DEV.md for setup instructions.\033[0m"
54+
fi
5255
fi
5356
5457
pre-push:
5558
commands:
5659
'nx-affected-checks':
57-
run: pnpm nx affected --target=lint,build --base=origin/main --head=HEAD
60+
run: pnpm nx affected --target=prepush --base=origin/main --head=HEAD --output-style=static
5861
scripts:
5962
'prevent-push-to-main.sh':
6063
runner: bash

pkgs/cli/project.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
"command": "./scripts/test-async-hang-issue-123",
9595
"cwd": "{projectRoot}"
9696
}
97+
},
98+
"prepush": {
99+
"executor": "nx:noop",
100+
"dependsOn": ["lint", "build", "typecheck", "test:vitest"]
97101
}
98102
}
99103
}

pkgs/client/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@
200200
},
201201
"test:types:vitest": {
202202
"executor": "nx:run-commands",
203+
"cache": true,
204+
"inputs": ["production", "^production"],
203205
"dependsOn": ["^build"],
204206
"options": {
205207
"cwd": "{projectRoot}",
@@ -208,6 +210,8 @@
208210
},
209211
"test:types:strict": {
210212
"executor": "nx:run-commands",
213+
"cache": true,
214+
"inputs": ["production", "^production"],
211215
"dependsOn": ["^build"],
212216
"options": {
213217
"cwd": "{projectRoot}",
@@ -217,6 +221,10 @@
217221
"test:types": {
218222
"executor": "nx:noop",
219223
"dependsOn": ["test:types:vitest", "test:types:strict"]
224+
},
225+
"prepush": {
226+
"executor": "nx:noop",
227+
"dependsOn": ["lint", "build", "typecheck", "verify-exports", "test:types:vitest", "test:types:strict"]
220228
}
221229
}
222230
}

pkgs/core/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@
273273
},
274274
"test:types:vitest": {
275275
"executor": "nx:run-commands",
276+
"cache": true,
277+
"inputs": ["production", "^production"],
276278
"dependsOn": ["^build"],
277279
"options": {
278280
"cwd": "{projectRoot}",
@@ -281,6 +283,8 @@
281283
},
282284
"test:types:strict": {
283285
"executor": "nx:run-commands",
286+
"cache": true,
287+
"inputs": ["production", "^production"],
284288
"dependsOn": ["^build"],
285289
"options": {
286290
"cwd": "{projectRoot}",
@@ -290,6 +294,10 @@
290294
"test:types": {
291295
"executor": "nx:noop",
292296
"dependsOn": ["test:types:vitest", "test:types:strict"]
297+
},
298+
"prepush": {
299+
"executor": "nx:noop",
300+
"dependsOn": ["lint", "build", "test:types:vitest", "test:types:strict"]
293301
}
294302
}
295303
}

pkgs/dsl/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
},
3939
"test:types:vitest": {
4040
"executor": "nx:run-commands",
41+
"cache": true,
42+
"inputs": ["production"],
4143
"dependsOn": [],
4244
"options": {
4345
"cwd": "{projectRoot}",
@@ -46,6 +48,8 @@
4648
},
4749
"test:types:strict": {
4850
"executor": "nx:run-commands",
51+
"cache": true,
52+
"inputs": ["production"],
4953
"dependsOn": [],
5054
"options": {
5155
"cwd": "{projectRoot}",
@@ -67,6 +71,10 @@
6771
"executor": "nx:noop",
6872
"inputs": ["default", "^production"],
6973
"dependsOn": ["test:vitest", "test:types"]
74+
},
75+
"prepush": {
76+
"executor": "nx:noop",
77+
"dependsOn": ["lint", "build", "test:vitest", "test:types:vitest"]
7078
}
7179
}
7280
}

pkgs/edge-worker/project.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,15 @@
235235
"executor": "nx:run-commands",
236236
"cache": true,
237237
"dependsOn": ["^build"],
238-
"inputs": ["default", "^production"],
238+
"inputs": ["production", "^production"],
239239
"options": {
240240
"cwd": "{projectRoot}",
241241
"command": "deno check --config deno.test.json src/examples/*.example.ts tests/types/*.test-d.ts"
242242
}
243+
},
244+
"prepush": {
245+
"executor": "nx:noop",
246+
"dependsOn": ["lint", "build", "test:types"]
243247
}
244248
},
245249
"tags": []

0 commit comments

Comments
 (0)