Skip to content

Commit a1d2ec2

Browse files
georgRusanovgeorgiy.rusanov
andauthored
test: fixing the pipeline (#1464)
* try to create a structure for the tests * separate jobs for different tests * ci fix --------- Co-authored-by: georgiy.rusanov <[email protected]>
1 parent c853ea3 commit a1d2ec2

File tree

8 files changed

+81
-55
lines changed

8 files changed

+81
-55
lines changed

.github/workflows/ci.yml

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,87 +20,114 @@ on:
2020

2121
jobs:
2222
test:
23-
name: Test / OS ${{ matrix.os }} / Node ${{ matrix.node }}
23+
name: Unit + Type Check / Node.js ${{ matrix.node }}
24+
runs-on: ubuntu-latest
2425
strategy:
2526
matrix:
26-
os: [ubuntu-latest]
27-
node: ['20']
28-
29-
runs-on: ${{ matrix.os }}
30-
27+
node: [20]
3128
steps:
3229
- uses: actions/checkout@v4
33-
34-
- name: Set up Node
35-
uses: actions/setup-node@v4
30+
- uses: actions/setup-node@v4
3631
with:
3732
node-version: ${{ matrix.node }}
3833

39-
- name: Run tests
40-
run: |
41-
npm clean-install
42-
npm run test:coverage
34+
- run: npm clean-install
35+
36+
- name: Type Check
37+
run: npm run test:types
38+
39+
- name: Run Unit Tests + Coverage
40+
run: npm run test:coverage
4341

4442
- name: Upload coverage results to Coveralls
4543
uses: coverallsapp/github-action@master
4644
with:
4745
github-token: ${{ secrets.GITHUB_TOKEN }}
4846
path-to-lcov: ./test/coverage/lcov.info
4947

50-
integration:
51-
name: Integration / OS ${{ matrix.os }} / Node ${{ matrix.node }} / Deno ${{ matrix.deno }}
48+
deno-tests:
49+
name: Deno Tests / ${{ matrix.deno }}
50+
runs-on: ubuntu-latest
5251
strategy:
5352
matrix:
54-
os: [ubuntu-latest]
55-
node: ['20']
5653
deno: ['1.x', '2.x']
57-
58-
runs-on: ${{ matrix.os }}
59-
6054
steps:
6155
- uses: actions/checkout@v4
62-
63-
- name: Set up Node
64-
uses: actions/setup-node@v4
65-
with:
66-
node-version: ${{ matrix.node }}
67-
6856
- uses: denoland/setup-deno@v2
6957
with:
7058
deno-version: ${{ matrix.deno }}
71-
72-
- name: Setup Supabase
73-
uses: supabase/setup-cli@v1
59+
- uses: supabase/setup-cli@v1
7460
with:
7561
version: latest
7662

7763
- name: Start Supabase
78-
run: |
79-
supabase start
64+
run: supabase start
8065

81-
- name: Build
66+
- name: Run Deno Tests
8267
run: |
8368
npm clean-install
8469
npm run build
70+
cd test/deno
71+
npm install
72+
npm test || npm test
8573
86-
- name: Run tests
74+
- name: Run integration and browser tests on Deno 2.x only
8775
if: ${{ matrix.deno == '2.x' }}
8876
run: |
8977
npm run test:integration || npm run test:integration
9078
npm run test:integration:browser
9179
92-
- name: Run Deno tests
80+
- name: Stop Supabase
81+
run: supabase stop
82+
83+
node-integration:
84+
name: Node Integration
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v4
88+
- uses: actions/setup-node@v4
89+
with:
90+
node-version: 20
91+
- uses: supabase/setup-cli@v1
92+
with:
93+
version: latest
94+
95+
- name: Start Supabase
96+
run: supabase start
97+
98+
- name: Run integration tests
9399
run: |
94-
cd test/deno
95-
npm test || npm test
100+
npm clean-install
101+
npm run build
102+
npm run test:integration || npm run test:integration
96103
97-
- name: Next.js Integration Tests
104+
- name: Stop Supabase
105+
run: supabase stop
106+
107+
next-integration:
108+
name: Next.js Integration
109+
runs-on: ubuntu-latest
110+
steps:
111+
- uses: actions/checkout@v4
112+
- uses: actions/setup-node@v4
113+
with:
114+
node-version: 20
115+
- uses: supabase/setup-cli@v1
116+
with:
117+
version: latest
118+
119+
- name: Start Supabase
120+
run: supabase start
121+
122+
- name: Install Playwright browsers and dependencies
123+
run: npx playwright install --with-deps
124+
125+
- name: Run integration tests
98126
run: |
99127
cd test/integration/next
100128
npm install
101129
npx playwright install
102-
npm run test
130+
npm run test
103131
104132
- name: Stop Supabase
105-
run: |
106-
supabase stop
133+
run: supabase stop

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
"test": "run-s test:types test:run",
3232
"test:all": "run-s test:types test:run test:integration test:integration:browser",
3333
"test:run": "jest --runInBand --detectOpenHandles",
34+
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
3435
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*|test/deno.*\"",
3536
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
3637
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
37-
"test:db": "cd infra/db && docker-compose down && docker-compose up -d && sleep 5",
3838
"test:watch": "jest --watch --verbose false --silent false",
39-
"test:clean": "cd infra/db && docker-compose down",
40-
"test:types": "run-s build:module && tsd --files test/*.test-d.ts",
39+
"test:types": "run-s build:module && tsd --files test/types/*.test-d.ts",
4140
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
4241
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals",
4342
"serve:coverage": "npm run test:coverage && serve test/coverage"

test/index.test-d.ts renamed to test/types/index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expectError, expectType } from 'tsd'
2-
import { PostgrestSingleResponse, createClient } from '../src/index'
3-
import { Database, Json } from './types'
2+
import { PostgrestSingleResponse, createClient } from '../../src/index'
3+
import { Database, Json } from '../types'
44

55
const URL = 'http://localhost:3000'
66
const KEY = 'some.fake.key'

test/SupabaseAuthClient.test.ts renamed to test/unit/SupabaseAuthClient.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { SupabaseAuthClient } from '../src/lib/SupabaseAuthClient'
2-
import SupabaseClient from '../src/SupabaseClient'
3-
import { DEFAULT_HEADERS } from '../src/lib/constants'
1+
import { SupabaseAuthClient } from '../../src/lib/SupabaseAuthClient'
2+
import SupabaseClient from '../../src/SupabaseClient'
3+
import { DEFAULT_HEADERS } from '../../src/lib/constants'
44

55
const DEFAULT_OPTIONS = {
66
auth: {

test/SupabaseClient.test.ts renamed to test/unit/SupabaseClient.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PostgrestClient } from '@supabase/postgrest-js'
2-
import { createClient, SupabaseClient } from '../src/index'
3-
import { Database } from './types'
2+
import { createClient, SupabaseClient } from '../../src/index'
3+
import { Database } from '../types'
44

55
const URL = 'http://localhost:3000'
66
const KEY = 'some.fake.key'

test/constants.test.ts renamed to test/unit/constants.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { DEFAULT_HEADERS } from '../src/lib/constants'
2-
import { version } from '../src/lib/version'
1+
import { DEFAULT_HEADERS } from '../../src/lib/constants'
2+
import { version } from '../../src/lib/version'
33

44
test('it has the correct type of returning with the correct value', () => {
55
let JS_ENV = ''

test/helper.test.ts renamed to test/unit/helper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ensureTrailingSlash } from '../src/lib/helpers'
1+
import { ensureTrailingSlash } from '../../src/lib/helpers'
22

33
test('Adds trailing slash to URL if missing', () => {
44
const input = 'http://localhost:3000'

test/helpers.test.ts renamed to test/unit/helpers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as helpers from '../src/lib/helpers'
2-
import { DEFAULT_HEADERS } from '../src/lib/constants'
1+
import * as helpers from '../../src/lib/helpers'
2+
import { DEFAULT_HEADERS } from '../../src/lib/constants'
33

44
test('uuid', async () => {
55
expect(helpers.uuid()).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)

0 commit comments

Comments
 (0)