Skip to content

Commit ea64a25

Browse files
authored
chore(ci): integrate Verdaccio for integration tests (#1795)
1 parent c408c47 commit ea64a25

File tree

7 files changed

+286
-52
lines changed

7 files changed

+286
-52
lines changed

.github/workflows/ci-supabase-js.yml

Lines changed: 143 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ env:
2020

2121
jobs:
2222
build-package:
23-
name: Build supabase-js package
23+
name: Build all packages
2424
runs-on: ubuntu-latest
25-
outputs:
26-
tgz-name: ${{ steps.pack.outputs.filename }}
2725
steps:
2826
- name: Checkout code
2927
uses: actions/checkout@v4
@@ -41,22 +39,20 @@ jobs:
4139

4240
- uses: nrwl/nx-set-shas@v4
4341

44-
- name: Build
45-
run: npx nx build supabase-js
42+
- name: Build all packages
43+
run: npx nx run-many --target=build --all
4644

47-
- name: Pack npm module
48-
id: pack
49-
run: |
50-
cd packages/core/supabase-js
51-
PKG=$(npm pack)
52-
echo "filename=$PKG" >> "$GITHUB_OUTPUT"
53-
cd ../../..
54-
55-
- name: Upload .tgz package
45+
- name: Upload built packages
5646
uses: actions/upload-artifact@v4
5747
with:
58-
name: supabase-tgz
59-
path: packages/core/supabase-js/${{ steps.pack.outputs.filename }}
48+
name: packages-dist
49+
path: |
50+
packages/core/auth-js/dist
51+
packages/core/functions-js/dist
52+
packages/core/postgrest-js/dist
53+
packages/core/realtime-js/dist
54+
packages/core/storage-js/dist
55+
packages/core/supabase-js/dist
6056
6157
- name: Upload UMD build
6258
uses: actions/upload-artifact@v4
@@ -147,11 +143,26 @@ jobs:
147143
with:
148144
node-version: ${{ env.NODE_VERSION }}
149145
cache: 'npm'
150-
- name: Download artifact
146+
147+
- name: Download built packages
151148
uses: actions/download-artifact@v4
152149
with:
153-
name: supabase-tgz
154-
path: ./packages/core/supabase-js/supabase-pkg
150+
name: packages-dist
151+
path: packages/core
152+
153+
- name: Install dependencies
154+
run: npm ci --legacy-peer-deps
155+
156+
- name: Start Verdaccio
157+
run: |
158+
npx verdaccio --config .verdaccio/config.yml &
159+
sleep 3
160+
161+
- name: Configure npm auth for Verdaccio
162+
run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken"
163+
164+
- name: Publish packages to Verdaccio
165+
run: node scripts/populate-verdaccio.mjs
155166

156167
- name: Start Supabase and apply migrations
157168
run: |
@@ -169,29 +180,35 @@ jobs:
169180
echo "Verifying storage bucket exists"
170181
supabase db query "select id, name from storage.buckets where id = 'test-bucket';"
171182
172-
- name: Install dependencies and build
183+
- name: Verify packages in Verdaccio
173184
run: |
174-
npm ci --legacy-peer-deps
175-
npx nx build supabase-js
185+
echo "Verifying @supabase/supabase-js is available in Verdaccio..."
186+
npm view @supabase/supabase-js version --registry http://localhost:4873
187+
npm view @supabase/supabase-js --registry http://localhost:4873 | head -20
176188
177-
- name: Run Deno Tests
189+
- name: Run Deno Tests (1.x)
178190
if: ${{ matrix.deno == '1.x' }}
179191
env:
180192
STORAGE_JS_ENTRY: main
193+
DENO_NPM_REGISTRY: http://localhost:4873
181194
run: |
182195
cd packages/core/supabase-js/test/deno
183-
cp ../../supabase-pkg/supabase-supabase-js-0.0.0-automated.tgz .
196+
echo "registry=http://localhost:4873/" > .npmrc
184197
npm install
185198
npm test || npm test
199+
rm -f .npmrc
186200
cd ../../..
187201
188-
- name: Run Deno Tests
202+
- name: Run Deno Tests (2.x)
189203
if: ${{ matrix.deno == '2.x' }}
204+
env:
205+
DENO_NPM_REGISTRY: http://localhost:4873
190206
run: |
191207
cd packages/core/supabase-js/test/deno
192-
cp ../../supabase-pkg/supabase-supabase-js-0.0.0-automated.tgz .
208+
echo "registry=http://localhost:4873/" > .npmrc
193209
npm install
194210
npm test || npm test
211+
rm -f .npmrc
195212
cd ../../..
196213
197214
- name: Run integration and browser tests on Deno 2.x only
@@ -286,17 +303,31 @@ jobs:
286303
node-version: ${{ env.NODE_VERSION }}
287304
cache: 'npm'
288305

289-
- name: Download artifact
290-
uses: actions/download-artifact@v4
291-
with:
292-
name: supabase-tgz
293-
path: ./packages/core/supabase-js/supabase-pkg
294-
295306
- name: Setup Supabase CLI
296307
uses: supabase/setup-cli@v1
297308
with:
298309
version: latest
299310

311+
- name: Download built packages
312+
uses: actions/download-artifact@v4
313+
with:
314+
name: packages-dist
315+
path: packages/core
316+
317+
- name: Install dependencies
318+
run: npm ci --legacy-peer-deps
319+
320+
- name: Start Verdaccio
321+
run: |
322+
npx verdaccio --config .verdaccio/config.yml &
323+
sleep 3
324+
325+
- name: Configure npm auth for Verdaccio
326+
run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken"
327+
328+
- name: Publish packages to Verdaccio
329+
run: node scripts/populate-verdaccio.mjs
330+
300331
- name: Start Supabase and apply migrations
301332
run: |
302333
cd packages/core/supabase-js
@@ -316,13 +347,23 @@ jobs:
316347
- name: Install Playwright browsers and dependencies
317348
run: npx playwright install --with-deps
318349

319-
- name: Run integration tests
350+
- name: Verify packages in Verdaccio
351+
run: |
352+
echo "Verifying @supabase/supabase-js is available in Verdaccio..."
353+
npm view @supabase/supabase-js version --registry http://localhost:4873
354+
npm view @supabase/supabase-js --registry http://localhost:4873 | head -20
355+
356+
- name: Run integration tests in isolation
320357
run: |
321-
cd packages/core/supabase-js/test/integration/next
322-
cp ../../../supabase-pkg/supabase-supabase-js-0.0.0-automated.tgz .
358+
TEST_DIR="/tmp/test-next-${{ github.run_id }}"
359+
mkdir -p "$TEST_DIR"
360+
cp -r packages/core/supabase-js/test/integration/next/* "$TEST_DIR/"
361+
cd "$TEST_DIR"
362+
echo "registry=http://localhost:4873/" > .npmrc
323363
npm install --legacy-peer-deps
324364
npx playwright install
325365
npm run test
366+
rm -f .npmrc
326367
327368
- name: Stop Supabase
328369
if: always()
@@ -352,11 +393,25 @@ jobs:
352393
with:
353394
version: latest
354395

355-
- name: Download artifact
396+
- name: Download built packages
356397
uses: actions/download-artifact@v4
357398
with:
358-
name: supabase-tgz
359-
path: ./packages/core/supabase-js/supabase-pkg
399+
name: packages-dist
400+
path: packages/core
401+
402+
- name: Install dependencies
403+
run: npm ci --legacy-peer-deps
404+
405+
- name: Start Verdaccio
406+
run: |
407+
npx verdaccio --config .verdaccio/config.yml &
408+
sleep 3
409+
410+
- name: Configure npm auth for Verdaccio
411+
run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken"
412+
413+
- name: Publish packages to Verdaccio
414+
run: node scripts/populate-verdaccio.mjs
360415

361416
- name: Start Supabase and apply migrations
362417
run: |
@@ -374,12 +429,22 @@ jobs:
374429
echo "Verifying storage bucket exists"
375430
supabase db query "select id, name from storage.buckets where id = 'test-bucket';"
376431
377-
- name: Install dependencies and run tests
432+
- name: Verify packages in Verdaccio
378433
run: |
379-
cd packages/core/supabase-js/test/integration/expo
380-
cp ../../../supabase-pkg/supabase-supabase-js-0.0.0-automated.tgz .
434+
echo "Verifying @supabase/supabase-js is available in Verdaccio..."
435+
npm view @supabase/supabase-js version --registry http://localhost:4873
436+
npm view @supabase/supabase-js --registry http://localhost:4873 | head -20
437+
438+
- name: Install test dependencies and run tests in isolation
439+
run: |
440+
TEST_DIR="/tmp/test-expo-${{ github.run_id }}"
441+
mkdir -p "$TEST_DIR"
442+
cp -r packages/core/supabase-js/test/integration/expo/* "$TEST_DIR/"
443+
cd "$TEST_DIR"
444+
echo "registry=http://localhost:4873/" > .npmrc
381445
npm install
382-
npm test || npm test
446+
npm test
447+
rm -f .npmrc
383448
384449
- name: Stop Supabase
385450
if: always()
@@ -403,16 +468,36 @@ jobs:
403468
with:
404469
bun-version: latest
405470

471+
- name: Setup Node.js
472+
uses: actions/setup-node@v4
473+
with:
474+
node-version: ${{ env.NODE_VERSION }}
475+
cache: 'npm'
476+
406477
- name: Setup Supabase CLI
407478
uses: supabase/setup-cli@v1
408479
with:
409480
version: latest
410481

411-
- name: Download artifact
482+
- name: Download built packages
412483
uses: actions/download-artifact@v4
413484
with:
414-
name: supabase-tgz
415-
path: ./packages/core/supabase-js/supabase-pkg
485+
name: packages-dist
486+
path: packages/core
487+
488+
- name: Install dependencies
489+
run: npm ci --legacy-peer-deps
490+
491+
- name: Start Verdaccio
492+
run: |
493+
npx verdaccio --config .verdaccio/config.yml &
494+
sleep 3
495+
496+
- name: Configure npm auth for Verdaccio
497+
run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken"
498+
499+
- name: Publish packages to Verdaccio
500+
run: node scripts/populate-verdaccio.mjs
416501

417502
- name: Start Supabase and apply migrations
418503
run: |
@@ -430,12 +515,22 @@ jobs:
430515
echo "Verifying storage bucket exists"
431516
supabase db query "select id, name from storage.buckets where id = 'test-bucket';"
432517
433-
- name: Install dependencies and run tests
518+
- name: Verify packages in Verdaccio
519+
run: |
520+
echo "Verifying @supabase/supabase-js is available in Verdaccio..."
521+
npm view @supabase/supabase-js version --registry http://localhost:4873
522+
npm view @supabase/supabase-js --registry http://localhost:4873 | head -20
523+
524+
- name: Install dependencies and run tests in isolation
434525
run: |
435-
cd packages/core/supabase-js/test/integration/bun
436-
cp ../../../supabase-pkg/supabase-supabase-js-0.0.0-automated.tgz .
526+
TEST_DIR="/tmp/test-bun-${{ github.run_id }}"
527+
mkdir -p "$TEST_DIR"
528+
cp -r packages/core/supabase-js/test/integration/bun/* "$TEST_DIR/"
529+
cd "$TEST_DIR"
530+
echo "registry=http://localhost:4873/" > .npmrc
437531
bun install
438532
bun test
533+
rm -f .npmrc
439534
440535
- name: Stop Supabase
441536
if: always()

packages/core/supabase-js/test/deno/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"setup-deps": "node setup-deps.js"
88
},
99
"dependencies": {
10-
"@supabase/supabase-js": "file:supabase-supabase-js-0.0.0-automated.tgz"
10+
"@supabase/supabase-js": "*"
1111
}
1212
}

packages/core/supabase-js/test/integration/bun/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test:watch": "bun test --watch integration.test.ts"
77
},
88
"dependencies": {
9-
"@supabase/supabase-js": "file:supabase-supabase-js-0.0.0-automated.tgz"
9+
"@supabase/supabase-js": "*"
1010
},
1111
"devDependencies": {
1212
"bun-types": "latest"

packages/core/supabase-js/test/integration/expo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@react-navigation/bottom-tabs": "^7.3.10",
1717
"@react-navigation/elements": "^2.3.8",
1818
"@react-navigation/native": "^7.1.6",
19-
"@supabase/supabase-js": "file:supabase-supabase-js-0.0.0-automated.tgz",
19+
"@supabase/supabase-js": "*",
2020
"expo": "~53.0.9",
2121
"expo-blur": "~14.1.4",
2222
"expo-constants": "~17.1.6",

packages/core/supabase-js/test/integration/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@radix-ui/react-label": "^2.1.6",
1818
"@radix-ui/react-slot": "^1.2.2",
1919
"@supabase/ssr": "latest",
20-
"@supabase/supabase-js": "file:supabase-supabase-js-0.0.0-automated.tgz",
20+
"@supabase/supabase-js": "*",
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",
2323
"lucide-react": "^0.511.0",

project.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "supabase-js-workspace",
3+
"$schema": "node_modules/nx/schemas/project-schema.json",
4+
"projectType": "library",
5+
"targets": {
6+
"local-registry": {
7+
"executor": "@nx/js:verdaccio",
8+
"options": {
9+
"port": 4873,
10+
"config": ".verdaccio/config.yml",
11+
"storage": "tmp/local-registry/storage",
12+
"clear": false
13+
}
14+
},
15+
"populate-local-registry": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"command": "node scripts/populate-verdaccio.mjs"
19+
},
20+
"dependsOn": ["local-registry"]
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)