Skip to content

Commit 6fce1db

Browse files
committed
fix: missing inputs and other nx issues (#258)
### TL;DR Improved NX build caching configuration across all packages to optimize build times and CI performance. ### What changed? - Added proper `inputs` configurations to all project targets to enable better caching - Fixed the `serve` command in the CLI package to use the built output instead of source files - Removed the `test:e2e:install:duplicates` dependency from the CLI test target - Updated the client test command to exclude integration tests - Fixed the Supabase reset command in edge-worker to depend on verified migrations - Updated paths for Atlas configuration files in the core package - Removed an invalid link card in the Supabase RPC documentation - Added `cache` and `local` flags to appropriate targets to improve build performance ### How to test? 1. Run `nx build client` followed by `nx build client` again to verify the second build is cached 2. Run `nx test client` to ensure tests run correctly with the updated configuration 3. Verify the CLI serve command works properly with `nx serve cli` 4. Check that the website builds and deploys correctly with the new caching configuration ### Why make this change? This change optimizes the build system by properly configuring NX's caching mechanism. By specifying the correct inputs for each target, we ensure that builds are only re-run when relevant files change. This significantly improves development and CI performance by avoiding unnecessary rebuilds and test runs, especially for packages that haven't changed.
1 parent 38a198a commit 6fce1db

File tree

12 files changed

+107
-28
lines changed

12 files changed

+107
-28
lines changed

.claude/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
"Bash(ls:*)",
2525
"Bash(mkdir:*)",
2626
"Bash(npx tsc:*)",
27-
"Bash(pnpm tsc:*)",
2827
"Bash(pnpm eslint:*)",
2928
"Bash(pnpm nx build:*)",
29+
"Bash(pnpm nx graph:*)",
3030
"Bash(pnpm nx lint:*)",
3131
"Bash(pnpm nx run:*)",
32+
"Bash(pnpm nx show project:*)",
3233
"Bash(pnpm nx supabase:*)",
3334
"Bash(pnpm nx supabase:reset:*)",
3435
"Bash(pnpm nx supabase:start:*)",
@@ -39,6 +40,7 @@
3940
"Bash(pnpm nx typecheck:*)",
4041
"Bash(pnpm nx verify-migrations:*)",
4142
"Bash(pnpm nx verify-schemas-synced:*)",
43+
"Bash(pnpm tsc:*)",
4244
"Bash(pnpm vitest run:*)",
4345
"Bash(pnpm vitest:*)",
4446
"Bash(psql:*)",

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ jobs:
4444
- name: Set Nx SHAs for affected commands
4545
uses: nrwl/nx-set-shas@v4
4646

47+
- name: Verify NX_BASE and NX_HEAD are set
48+
run: echo "BASE=$NX_BASE HEAD=$NX_HEAD"
49+
4750
- name: Quality gate (lint + typecheck + test)
48-
run: pnpm nx affected -t lint typecheck test --parallel --configuration=production
51+
run: pnpm nx affected -t lint typecheck test --parallel --configuration=production --base="$NX_BASE" --head="$NX_HEAD"
4952

5053
- name: Build all affected projects (except playground)
51-
run: pnpm nx affected -t build --configuration=production --parallel --exclude=playground
54+
run: pnpm nx affected -t build --configuration=production --parallel --exclude=playground --base="$NX_BASE" --head="$NX_HEAD"
5255

5356

5457
# ────────────────────────────────── 2. DEPLOY PLAYGROUND ───────────────────────────
@@ -112,11 +115,14 @@ jobs:
112115

113116
- name: Set Nx SHAs for affected commands
114117
uses: nrwl/nx-set-shas@v4
115-
118+
119+
- name: Verify NX_BASE and NX_HEAD are set
120+
run: echo "BASE=$NX_BASE HEAD=$NX_HEAD"
121+
116122
- name: Check if website is affected
117123
id: check-affected
118124
run: |
119-
if pnpm nx show projects --affected -t build | grep -q "^website$"; then
125+
if pnpm nx show projects --affected -t build --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^website$"; then
120126
echo "affected=true" >> $GITHUB_OUTPUT
121127
echo "Website is affected by changes"
122128
else

nx.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "./node_modules/nx/schemas/nx-schema.json",
3+
"defaultBase": "origin/main",
34
"namedInputs": {
45
"default": ["{projectRoot}/**/*", "sharedGlobals"],
56
"production": [

pkgs/cli/project.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": {
1010
"executor": "@nx/js:tsc",
1111
"outputs": ["{options.outputPath}"],
12+
"inputs": ["production", "^production"],
1213
"options": {
1314
"main": "{projectRoot}/src/index.ts",
1415
"tsConfig": "{projectRoot}/tsconfig.lib.json",
@@ -25,18 +26,20 @@
2526
},
2627
"serve": {
2728
"executor": "nx:run-commands",
29+
"cache": false,
30+
"local": true,
2831
"dependsOn": ["build"],
2932
"options": {
30-
"command": "tsx src/index.ts",
33+
"command": "node dist/index.js",
3134
"cwd": "{projectRoot}"
3235
}
3336
},
3437
"test": {
3538
"executor": "nx:noop",
39+
"inputs": ["default", "^production"],
3640
"dependsOn": [
3741
"test:vitest",
3842
"test:e2e:install",
39-
"test:e2e:install:duplicates",
4043
"test:e2e:compile",
4144
"test:e2e:async-hang-issue-123"
4245
],
@@ -46,6 +49,7 @@
4649
},
4750
"test:vitest": {
4851
"executor": "nx:run-commands",
52+
"inputs": ["default", "^production"],
4953
"options": {
5054
"command": "vitest run",
5155
"cwd": "{projectRoot}"
@@ -55,6 +59,7 @@
5559
"executor": "nx:run-commands",
5660
"local": true,
5761
"dependsOn": ["build"],
62+
"inputs": ["default", "^production"],
5863
"options": {
5964
"commands": [
6065
"./scripts/test-install",
@@ -68,6 +73,7 @@
6873
"executor": "nx:run-commands",
6974
"local": true,
7075
"dependsOn": ["test:e2e:install", "build"],
76+
"inputs": ["default", "^production"],
7177
"options": {
7278
"commands": [
7379
"rm -rf supabase/",
@@ -83,6 +89,7 @@
8389
"executor": "nx:run-commands",
8490
"local": true,
8591
"dependsOn": ["build"],
92+
"inputs": ["default", "^production"],
8693
"options": {
8794
"command": "./scripts/test-async-hang-issue-123",
8895
"cwd": "{projectRoot}"

pkgs/client/project.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
"targets": {
88
"build": {
99
"executor": "nx:noop",
10+
"inputs": ["production", "^production"],
1011
"outputs": ["{projectRoot}/dist"],
11-
"dependsOn": ["build:lib", "build:browser", "verify-exports"]
12+
"dependsOn": ["^build", "build:lib", "build:browser", "verify-exports"]
1213
},
1314
"verify-exports": {
1415
"executor": "nx:run-commands",
16+
"inputs": [
17+
"{projectRoot}/scripts/verify-exports.js",
18+
"{projectRoot}/package.json"
19+
],
1520
"options": {
1621
"cwd": "{projectRoot}",
1722
"command": "pnpm run verify-exports"
@@ -22,6 +27,7 @@
2227
"executor": "@nx/vite:build",
2328
"outputs": ["{options.outputPath}"],
2429
"dependsOn": ["^build"],
30+
"inputs": ["production", "^production"],
2531
"options": {
2632
"outputPath": "pkgs/client/dist",
2733
"configFile": "pkgs/client/vite.config.ts"
@@ -31,6 +37,7 @@
3137
"executor": "@nx/vite:build",
3238
"outputs": ["{options.outputPath}"],
3339
"dependsOn": ["^build"],
40+
"inputs": ["production", "^production"],
3441
"options": {
3542
"outputPath": "pkgs/client/dist",
3643
"configFile": "pkgs/client/vite.browser.config.ts"
@@ -39,6 +46,7 @@
3946
"typecheck": {
4047
"executor": "@nx/js:tsc",
4148
"dependsOn": ["^build"],
49+
"inputs": ["default", "^production"],
4250
"options": {
4351
"noEmit": true,
4452
"tsConfig": "pkgs/client/tsconfig.lib.json",
@@ -48,7 +56,7 @@
4856
},
4957
"lint": {
5058
"executor": "@nx/eslint:lint",
51-
"inputs": ["default"]
59+
"inputs": ["default", "^production"]
5260
},
5361
"supabase:ensure-started": {
5462
"executor": "nx:run-commands",
@@ -96,6 +104,14 @@
96104
"executor": "nx:run-commands",
97105
"local": true,
98106
"dependsOn": ["^verify-migrations"],
107+
"inputs": [
108+
"{workspaceRoot}/pkgs/core/supabase/migrations/**/*.sql",
109+
"{workspaceRoot}/pkgs/core/supabase/seed.sql"
110+
],
111+
"outputs": [
112+
"{projectRoot}/supabase/migrations",
113+
"{projectRoot}/supabase/seed.sql"
114+
],
99115
"options": {
100116
"cwd": "{projectRoot}",
101117
"commands": [
@@ -157,7 +173,7 @@
157173
"inputs": ["default", "^production"],
158174
"options": {
159175
"cwd": "{projectRoot}",
160-
"commands": ["vitest run __tests__/"],
176+
"commands": ["vitest run __tests__/ --exclude __tests__/integration/"],
161177
"parallel": false
162178
}
163179
},
@@ -174,6 +190,7 @@
174190
},
175191
"test": {
176192
"executor": "nx:noop",
193+
"inputs": ["default", "^production"],
177194
"dependsOn": ["test:vitest", "test:types"]
178195
},
179196
"benchmark": {
@@ -189,14 +206,19 @@
189206
},
190207
"test:types:vitest": {
191208
"executor": "nx:run-commands",
209+
"cache": true,
192210
"dependsOn": ["build"],
211+
"inputs": ["default", "^production"],
193212
"options": {
194213
"cwd": "{projectRoot}",
195214
"command": "pnpm vitest --typecheck.only --run"
196215
}
197216
},
198217
"test:types:strict": {
199218
"executor": "nx:run-commands",
219+
"cache": true,
220+
"dependsOn": ["build"],
221+
"inputs": ["default", "^production"],
200222
"options": {
201223
"cwd": "{projectRoot}",
202224
"command": "bash ../../scripts/typecheck-ts2578.sh"

pkgs/core/project.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"schemas": ["{projectRoot}/schemas/**/*.sql"],
99
"migrations": ["{projectRoot}/supabase/migrations/**/*.sql"],
1010
"atlasSetup": [
11-
"{projectRoot}/atlas.hcl",
12-
"{projectRoot}/Dockerfile.atlas",
11+
"{projectRoot}/atlas/atlas.hcl",
1312
"{projectRoot}/supabase/migrations/atlas.sum",
1413
"{projectRoot}/scripts/atlas-verify-schemas-synced"
1514
],
@@ -75,7 +74,7 @@
7574
},
7675
"build": {
7776
"executor": "@nx/js:tsc",
78-
"inputs": ["default", "databaseTypes"],
77+
"inputs": ["production", "databaseTypes", "^production"],
7978
"options": {
8079
"outputPath": "pkgs/core/dist",
8180
"main": "pkgs/core/src/index.ts",
@@ -93,6 +92,9 @@
9392
},
9493
"jsr:publish": {
9594
"executor": "nx:run-commands",
95+
"cache": false,
96+
"local": true,
97+
"dependsOn": ["build"],
9698
"outputs": ["{workspaceRoot}/pkgs/core/"],
9799
"options": {
98100
"cwd": "pkgs/core",
@@ -103,18 +105,18 @@
103105
"lint:sqruff": {
104106
"executor": "nx:run-commands",
105107
"local": true,
108+
"inputs": ["schemas", "sqruffConfig"],
106109
"options": {
107110
"cwd": "{projectRoot}",
108111
"commands": [
109112
"sqruff --config=../../.sqruff lint --parsing-errors schemas/"
110113
],
111-
"inputs": ["schemas", "sqruffConfig"],
112114
"parallel": false
113115
}
114116
},
115117
"lint:eslint": {
116118
"executor": "@nx/eslint:lint",
117-
"inputs": ["default"]
119+
"inputs": ["default", "^production"]
118120
},
119121
"lint": {
120122
"executor": "nx:noop",
@@ -124,12 +126,12 @@
124126
"fix-sql": {
125127
"executor": "nx:run-commands",
126128
"local": true,
129+
"inputs": ["schemas", "sqruffConfig"],
127130
"options": {
128131
"cwd": "{projectRoot}",
129132
"commands": [
130133
"sqruff --config=../../.sqruff fix --force --parsing-errors schemas/"
131134
],
132-
"inputs": ["schemas", "sqruffConfig"],
133135
"parallel": false
134136
}
135137
},
@@ -198,6 +200,7 @@
198200
},
199201
"test": {
200202
"executor": "nx:noop",
203+
"inputs": ["default", "^production", "schemas", "migrations", "pgtapTests", "databaseTypes"],
201204
"dependsOn": ["test:pgtap", "test:vitest", "test:types"]
202205
},
203206
"test:pgtap": {
@@ -214,8 +217,8 @@
214217
},
215218
"test:vitest": {
216219
"executor": "@nx/vite:test",
217-
"dependsOn": ["^build", "build", "verify-gen-types"],
218-
"inputs": ["default", "databaseTypes"],
220+
"dependsOn": ["build", "verify-gen-types"],
221+
"inputs": ["default", "databaseTypes", "^production"],
219222
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
220223
"options": {
221224
"passWithNoTests": true,
@@ -272,14 +275,19 @@
272275
},
273276
"test:types:vitest": {
274277
"executor": "nx:run-commands",
278+
"cache": true,
275279
"dependsOn": ["build"],
280+
"inputs": ["default", "^production"],
276281
"options": {
277282
"cwd": "{projectRoot}",
278283
"command": "pnpm vitest --typecheck.only --run"
279284
}
280285
},
281286
"test:types:strict": {
282287
"executor": "nx:run-commands",
288+
"cache": true,
289+
"dependsOn": ["^build"],
290+
"inputs": ["default", "^production"],
283291
"options": {
284292
"cwd": "{projectRoot}",
285293
"command": "bash ../../scripts/typecheck-ts2578.sh"

pkgs/core/src/types.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ import type {
44
Simplify,
55
AnyFlow,
66
ExtractFlowInput,
7+
Json,
78
} from '@pgflow/dsl';
89
import type { Database } from './database-types.js';
910

10-
export type Json =
11-
| string
12-
| number
13-
| boolean
14-
| null
15-
| { [key: string]: Json | undefined }
16-
| Json[];
11+
export type { Json };
1712

1813
/**
1914
* Record representing a task from pgflow.start_tasks

pkgs/dsl/project.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"targets": {
99
"build": {
1010
"executor": "@nx/js:tsc",
11+
"inputs": ["production", "^production"],
1112
"options": {
1213
"outputPath": "pkgs/dsl/dist",
1314
"main": "pkgs/dsl/src/index.ts",
@@ -28,6 +29,7 @@
2829
"test:vitest": {
2930
"executor": "@nx/vite:test",
3031
"dependsOn": ["build"],
32+
"inputs": ["default", "^production"],
3133
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
3234
"options": {
3335
"passWithNoTests": true,
@@ -36,13 +38,19 @@
3638
},
3739
"test:types:vitest": {
3840
"executor": "nx:run-commands",
41+
"cache": true,
42+
"dependsOn": ["build"],
43+
"inputs": ["default", "^production"],
3944
"options": {
4045
"cwd": "{projectRoot}",
4146
"command": "pnpm vitest --typecheck.only --run"
4247
}
4348
},
4449
"test:types:strict": {
4550
"executor": "nx:run-commands",
51+
"cache": true,
52+
"dependsOn": ["^build"],
53+
"inputs": ["default", "^production"],
4654
"options": {
4755
"cwd": "{projectRoot}",
4856
"command": "bash ../../scripts/typecheck-ts2578.sh"
@@ -61,6 +69,7 @@
6169
},
6270
"test": {
6371
"executor": "nx:noop",
72+
"inputs": ["default", "^production"],
6473
"dependsOn": ["test:vitest", "test:types"]
6574
}
6675
}

0 commit comments

Comments
 (0)