Skip to content

Commit a270acb

Browse files
authored
Merge pull request #4287 from drizzle-team/optimize-int-tests
Optimize tests
2 parents f07c427 + 1946324 commit a270acb

12 files changed

+3393
-2007
lines changed

.github/workflows/release-feature-branch.yaml

+257-43
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@ on:
77
pull_request: {}
88

99
jobs:
10-
release:
10+
test:
1111
# only run on all pushes or pull requests from forks
1212
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
1313
strategy:
1414
matrix:
15-
package:
15+
shard:
16+
- gel
17+
- planetscale
18+
- singlestore-core
19+
- singlestore-proxy
20+
- singlestore-prefixed
21+
- singlestore-custom
22+
- neon-http
23+
- neon-serverless
1624
- drizzle-orm
1725
- drizzle-kit
1826
- drizzle-zod
1927
- drizzle-seed
2028
- drizzle-typebox
2129
- drizzle-valibot
22-
- eslint-plugin-drizzle
30+
- other
2331
runs-on: ubuntu-20.04
24-
permissions:
25-
contents: read
26-
id-token: write
2732
services:
2833
postgres-postgis:
2934
image: postgis/postgis:16-3.4
@@ -76,6 +81,155 @@ jobs:
7681
--health-retries 5
7782
ports:
7883
- 33306:3306
84+
singlestore:
85+
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
86+
env:
87+
ROOT_PASSWORD: singlestore
88+
ports:
89+
- 33307:3306
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- uses: actions/setup-node@v4
94+
with:
95+
node-version: '20.19'
96+
registry-url: 'https://registry.npmjs.org'
97+
98+
- uses: pnpm/action-setup@v3
99+
name: Install pnpm
100+
id: pnpm-install
101+
with:
102+
version: latest
103+
run_install: false
104+
105+
- name: Get pnpm store directory
106+
id: pnpm-cache
107+
shell: bash
108+
run: |
109+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
110+
111+
- uses: actions/cache@v4
112+
name: Setup pnpm cache
113+
with:
114+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
115+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
116+
restore-keys: |
117+
${{ runner.os }}-pnpm-store-
118+
119+
- name: Install dependencies
120+
run: pnpm install
121+
122+
- name: Build Prisma client
123+
working-directory: drizzle-orm
124+
run: pnpm prisma generate --schema src/prisma/schema.prisma
125+
126+
- name: Build
127+
run: pnpm build
128+
129+
- name: Run tests
130+
env:
131+
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55433/drizzle
132+
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
133+
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
134+
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
135+
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
136+
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
137+
# NEON_HTTP_CONNECTION_STRING: postgres://postgres:[email protected]:5432/postgres
138+
NEON_HTTP_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
139+
NEON_SERVERLESS_CONNECTION_STRING: postgres://postgres:postgres@localhost:5445/postgres
140+
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
141+
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
142+
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
143+
LIBSQL_URL: file:local.db
144+
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
145+
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
146+
SINGLESTORE_CONNECTION_STRING: singlestore://root:singlestore@localhost:33307/
147+
working-directory: integration-tests
148+
run: |
149+
if [[ ${{ github.event_name }} != "push" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
150+
export SKIP_EXTERNAL_DB_TESTS=1
151+
fi
152+
153+
case ${{ matrix.shard }} in
154+
155+
gel)
156+
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
157+
pnpm vitest run tests/gel
158+
fi
159+
;;
160+
161+
planetscale)
162+
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
163+
pnpm vitest run \
164+
tests/mysql/mysql-planetscale.test.ts \
165+
tests/relational/mysql.planetscale-v1.test.ts \
166+
tests/relational/mysql.planetscale.test.ts
167+
fi
168+
;;
169+
170+
singlestore-core)
171+
pnpm vitest run tests/singlestore/singlestore.test.ts
172+
;;
173+
174+
singlestore-proxy)
175+
pnpm vitest run tests/singlestore/singlestore-proxy.test.ts
176+
;;
177+
178+
singlestore-prefixed)
179+
pnpm vitest run tests/singlestore/singlestore-prefixed.test.ts
180+
;;
181+
182+
singlestore-custom)
183+
pnpm vitest run tests/singlestore/singlestore-custom.test.ts
184+
;;
185+
186+
neon-http)
187+
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
188+
pnpm vitest run tests/pg/neon-http.test.ts tests/pg/neon-http-batch.test.ts
189+
fi
190+
;;
191+
192+
neon-serverless)
193+
docker compose -f docker-neon.yml up -d
194+
pnpm vitest run tests/pg/neon-serverless.test.ts
195+
docker compose -f docker-neon.yml down
196+
;;
197+
198+
drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot)
199+
(cd .. && pnpm test --filter ${{ matrix.shard }})
200+
;;
201+
202+
other)
203+
pnpm vitest run \
204+
--exclude tests/gel \
205+
--exclude tests/mysql/mysql-planetscale.test.ts \
206+
--exclude tests/relational/mysql.planetscale-v1.test.ts \
207+
--exclude tests/relational/mysql.planetscale.test.ts \
208+
--exclude tests/singlestore/singlestore.test.ts \
209+
--exclude tests/singlestore/singlestore-proxy.test.ts \
210+
--exclude tests/singlestore/singlestore-prefixed.test.ts \
211+
--exclude tests/singlestore/singlestore-custom.test.ts \
212+
--exclude tests/pg/neon-http.test.ts \
213+
--exclude tests/pg/neon-http-batch.test.ts \
214+
--exclude tests/pg/neon-serverless.test.ts
215+
;;
216+
217+
esac
218+
219+
attw:
220+
# only run on all pushes or pull requests from forks
221+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
222+
strategy:
223+
matrix:
224+
package:
225+
- drizzle-orm
226+
- drizzle-kit
227+
- drizzle-zod
228+
- drizzle-seed
229+
- drizzle-typebox
230+
- drizzle-valibot
231+
- eslint-plugin-drizzle
232+
runs-on: ubuntu-20.04
79233
steps:
80234
- uses: actions/checkout@v4
81235

@@ -108,6 +262,9 @@ jobs:
108262
- name: Install dependencies
109263
run: pnpm install
110264

265+
- name: Install Bun
266+
uses: oven-sh/setup-bun@v2
267+
111268
- name: Check preconditions
112269
id: checks
113270
shell: bash
@@ -130,57 +287,114 @@ jobs:
130287
} >> $GITHUB_OUTPUT
131288
fi
132289
290+
- name: Build Prisma client
291+
if: steps.checks.outputs.has_new_release == 'true'
292+
working-directory: drizzle-orm
293+
run: pnpm prisma generate --schema src/prisma/schema.prisma
294+
133295
- name: Build
134296
if: steps.checks.outputs.has_new_release == 'true'
297+
run: pnpm build
298+
299+
- name: Pack
300+
if: steps.checks.outputs.has_new_release == 'true'
301+
working-directory: ${{ matrix.package }}
302+
run: npm run pack
303+
304+
- name: Run @arethetypeswrong/cli
305+
if: steps.checks.outputs.has_new_release == 'true'
306+
working-directory: ${{ matrix.package }}
307+
run: bunx attw package.tgz
308+
309+
release:
310+
# only run on all pushes or pull requests from forks
311+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
312+
needs:
313+
- test
314+
- attw
315+
strategy:
316+
matrix:
317+
package:
318+
- drizzle-orm
319+
- drizzle-kit
320+
- drizzle-zod
321+
- drizzle-seed
322+
- drizzle-typebox
323+
- drizzle-valibot
324+
- eslint-plugin-drizzle
325+
runs-on: ubuntu-20.04
326+
permissions:
327+
contents: read
328+
id-token: write
329+
steps:
330+
- uses: actions/checkout@v4
331+
332+
- uses: actions/setup-node@v4
333+
with:
334+
node-version: '18.18'
335+
registry-url: 'https://registry.npmjs.org'
336+
337+
- uses: pnpm/action-setup@v3
338+
name: Install pnpm
339+
id: pnpm-install
340+
with:
341+
version: latest
342+
run_install: false
343+
344+
- name: Get pnpm store directory
345+
id: pnpm-cache
346+
shell: bash
135347
run: |
136-
(
137-
cd drizzle-orm
138-
pnpm prisma generate --schema src/prisma/schema.prisma
139-
)
140-
pnpm build
348+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
141349
142-
- name: Run tests
143-
if: steps.checks.outputs.has_new_release == 'true'
144-
env:
145-
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55433/drizzle
146-
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
147-
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
148-
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
149-
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
150-
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
151-
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
152-
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
153-
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
154-
LIBSQL_URL: file:local.db
155-
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
156-
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
350+
- uses: actions/cache@v4
351+
name: Setup pnpm cache
352+
with:
353+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
354+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
355+
restore-keys: |
356+
${{ runner.os }}-pnpm-store-
357+
358+
- name: Install dependencies
359+
run: pnpm install
360+
361+
- name: Check preconditions
362+
id: checks
363+
shell: bash
364+
working-directory: ${{ matrix.package }}
157365
run: |
158-
if [[ ${{ github.event_name }} != "push" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
159-
export SKIP_EXTERNAL_DB_TESTS=1
160-
fi
161-
if [[ "${{ matrix.package }}" == "drizzle-orm" ]]; then
162-
pnpm test --filter ${{ matrix.package }} --filter integration-tests
366+
old_version="$(jq -r .version package.json)"
367+
version="$old_version-$(git rev-parse --short HEAD)"
368+
npm version $version
369+
tag="${{ github.ref_name }}"
370+
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')"
371+
372+
if [[ "$is_version_published" == "true" ]]; then
373+
echo "\`${{ matrix.package }}$version\` already published, adding tag \`$tag\`" >> $GITHUB_STEP_SUMMARY
374+
npm dist-tag add ${{ matrix.package }}@$version $tag
163375
else
164-
pnpm test --filter ${{ matrix.package }}
376+
{
377+
echo "version=$version"
378+
echo "tag=$tag"
379+
echo "has_new_release=true"
380+
} >> $GITHUB_OUTPUT
165381
fi
166382
167-
- name: Pack
383+
- name: Build Prisma client
384+
working-directory: drizzle-orm
385+
run: pnpm prisma generate --schema src/prisma/schema.prisma
386+
387+
- name: Build
168388
if: steps.checks.outputs.has_new_release == 'true'
169-
working-directory: ${{ matrix.package }}
170-
shell: bash
171-
env:
172-
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
173-
run: |
174-
npm run pack
175-
176-
- name: Run @arethetypeswrong/cli
389+
run: pnpm build
390+
391+
- name: Pack
177392
if: steps.checks.outputs.has_new_release == 'true'
178393
working-directory: ${{ matrix.package }}
179394
shell: bash
180395
env:
181396
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
182-
run: |
183-
pnpm attw package.tgz
397+
run: npm run pack
184398

185399
- name: Publish
186400
if: github.event_name == 'push' && steps.checks.outputs.has_new_release == 'true'

0 commit comments

Comments
 (0)