Skip to content

Commit f2cc9c7

Browse files
authored
Merge pull request #27 from noxify/optimize-tests
Optimize tests
2 parents ca47778 + 973c2e2 commit f2cc9c7

39 files changed

+1576
-2234
lines changed

.changeset/free-dancers-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vorsteh-queue/adapter-prisma": patch
3+
---
4+
5+
Fixed transform issue

.changeset/open-wolves-repair.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@vorsteh-queue/adapter-drizzle": patch
3+
"@vorsteh-queue/adapter-kysely": patch
4+
"@vorsteh-queue/adapter-prisma": patch
5+
---
6+
7+
use shared tests

.github/workflows/ci.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -68,50 +68,8 @@ jobs:
6868
- name: Typecheck
6969
run: pnpm typecheck
7070

71-
unittest:
72-
runs-on: ubuntu-latest
73-
strategy:
74-
matrix:
75-
node-version: [20, 22]
76-
name: Test (Node.js ${{ matrix.node-version }})
77-
steps:
78-
- uses: actions/checkout@v4
79-
80-
- name: Setup Node.js ${{ matrix.node-version }}
81-
uses: actions/setup-node@v4
82-
with:
83-
node-version: ${{ matrix.node-version }}
84-
85-
- name: Setup pnpm
86-
uses: pnpm/action-setup@v4
87-
with:
88-
version: 10.13.1
89-
run_install: false
90-
91-
- shell: bash
92-
run: pnpm install
93-
94-
- name: Build packages
95-
run: |
96-
pnpm -F adapter-prisma prisma:generate
97-
pnpm --filter "./packages/*" build
98-
99-
- name: Test Core Package
100-
run: pnpm test:core
101-
102-
- name: Test Drizzle PostgreSQL (PGlite)
103-
run: pnpm test:drizzle
104-
105-
- name: Test Prisma (Testcontainers - Postgres)
106-
run: |
107-
pnpm -F adapter-prisma prisma:generate
108-
pnpm test:prisma
109-
env:
110-
# Ensure Docker is available for Testcontainers
111-
TESTCONTAINERS_RYUK_DISABLED: true
112-
11371
pkg-new-release:
114-
needs: [lint, format, typecheck, unittest]
72+
needs: [lint, format, typecheck]
11573
if: github.event_name == 'pull_request'
11674
runs-on: ubuntu-latest
11775
steps:

.github/workflows/tests.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
branches: ["*"]
6+
push:
7+
branches: ["main", "changesets/release"]
8+
merge_group:
9+
workflow_dispatch:
10+
inputs:
11+
pr_number:
12+
description: "PR number to run CI for"
13+
required: false
14+
type: string
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
19+
20+
permissions:
21+
contents: read
22+
pull-requests: read
23+
checks: write
24+
statuses: write
25+
26+
# You can leverage Vercel Remote Caching with Turbo to speed up your builds
27+
# @link https://turborepo.org/docs/core-concepts/remote-caching#remote-caching-on-vercel-builds
28+
env:
29+
FORCE_COLOR: 3
30+
31+
jobs:
32+
node_versions:
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
node-version: [20, 22]
37+
name: Test (Node.js ${{ matrix.node-version }})
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Setup Node.js ${{ matrix.node-version }}
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: ${{ matrix.node-version }}
45+
46+
- name: Setup pnpm
47+
uses: pnpm/action-setup@v4
48+
with:
49+
version: 10.15.1
50+
run_install: false
51+
52+
- shell: bash
53+
run: pnpm install
54+
55+
- name: Build packages
56+
run: |
57+
pnpm -F adapter-prisma prisma:generate
58+
pnpm --filter "./packages/*" build
59+
60+
- name: Test Core Package
61+
run: pnpm test:core
62+
63+
- name: Test Drizzle
64+
run: pnpm test:drizzle
65+
env:
66+
# Ensure Docker is available for Testcontainers
67+
TESTCONTAINERS_RYUK_DISABLED: true
68+
69+
- name: Test Prisma
70+
run: |
71+
pnpm -F adapter-prisma prisma:generate
72+
pnpm test:prisma
73+
env:
74+
# Ensure Docker is available for Testcontainers
75+
TESTCONTAINERS_RYUK_DISABLED: true
76+
77+
- name: Test Kysely
78+
run: pnpm test:kysely
79+
env:
80+
# Ensure Docker is available for Testcontainers
81+
TESTCONTAINERS_RYUK_DISABLED: true
82+
83+
postgres-drizzle:
84+
runs-on: ubuntu-latest
85+
strategy:
86+
matrix:
87+
pg-version: [12, 13, 14, 15, 16, 17]
88+
name: Test Drizzle Adapter (Postgres ${{ matrix.pg-version }})
89+
steps:
90+
- uses: actions/checkout@v4
91+
92+
- name: Setup
93+
uses: ./.github/setup
94+
95+
- name: Setup pnpm
96+
uses: pnpm/action-setup@v4
97+
with:
98+
version: 10.15.1
99+
run_install: false
100+
101+
- shell: bash
102+
run: pnpm install
103+
104+
- name: Build package
105+
run: |
106+
pnpm --filter "./packages/*" build
107+
108+
- name: Test PostgreSQL (Postgres ${{ matrix.pg-version }})
109+
run: pnpm test:drizzle
110+
env:
111+
# Ensure Docker is available for Testcontainers
112+
TESTCONTAINERS_RYUK_DISABLED: true
113+
PG_VERSION: ${{ matrix.pg-version }}
114+
115+
postgres-prisma:
116+
runs-on: ubuntu-latest
117+
strategy:
118+
matrix:
119+
pg-version: [12, 13, 14, 15, 16, 17]
120+
name: Test Prisma Adapter (Postgres ${{ matrix.pg-version }})
121+
steps:
122+
- uses: actions/checkout@v4
123+
124+
- name: Setup
125+
uses: ./.github/setup
126+
127+
- name: Setup pnpm
128+
uses: pnpm/action-setup@v4
129+
with:
130+
version: 10.15.1
131+
run_install: false
132+
133+
- shell: bash
134+
run: pnpm install
135+
136+
- name: Build package
137+
run: |
138+
pnpm --filter "./packages/*" build
139+
140+
- name: Test PostgreSQL (Postgres ${{ matrix.pg-version }})
141+
run: |
142+
pnpm -F adapter-prisma prisma:generate
143+
pnpm test:prisma
144+
env:
145+
# Ensure Docker is available for Testcontainers
146+
TESTCONTAINERS_RYUK_DISABLED: true
147+
PG_VERSION: ${{ matrix.pg-version }}
148+
149+
postgres-kysely:
150+
runs-on: ubuntu-latest
151+
strategy:
152+
matrix:
153+
pg-version: [12, 13, 14, 15, 16, 17]
154+
name: Test Kysely Adapter (Postgres ${{ matrix.pg-version }})
155+
steps:
156+
- uses: actions/checkout@v4
157+
158+
- name: Setup
159+
uses: ./.github/setup
160+
161+
- name: Setup pnpm
162+
uses: pnpm/action-setup@v4
163+
with:
164+
version: 10.15.1
165+
run_install: false
166+
167+
- shell: bash
168+
run: pnpm install
169+
170+
- name: Build package
171+
run: |
172+
pnpm --filter "./packages/*" build
173+
174+
- name: Test PostgreSQL (Postgres ${{ matrix.pg-version }})
175+
run: pnpm test:kysely
176+
env:
177+
# Ensure Docker is available for Testcontainers
178+
TESTCONTAINERS_RYUK_DISABLED: true
179+
PG_VERSION: ${{ matrix.pg-version }}

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"remark-squeeze-paragraphs": "6.0.0",
5555
"remark-strip-badges": "7.0.0",
5656
"renoun": "9.5.0",
57-
"tm-grammars": "1.24.8",
57+
"tm-grammars": "1.24.9",
5858
"tm-themes": "1.10.9",
5959
"ts-morph": "26.0.0",
6060
"tw-animate-css": "^1.3.8",

examples/kysely-postgres/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@vorsteh-queue/adapter-kysely": "workspace:*",
1414
"@vorsteh-queue/core": "workspace:*",
1515
"kysely": "^0.28.5",
16-
"kysely-postgres-js": "^2.0.0",
16+
"kysely-postgres-js": "^3.0.0",
1717
"postgres": "^3.4.7"
1818
},
1919
"devDependencies": {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"engines": {
66
"node": ">=20"
77
},
8-
"packageManager": "pnpm@10.13.1",
8+
"packageManager": "pnpm@10.15.1",
99
"author": {
1010
"name": "Marcus Reinhardt",
1111
"url": "https://github.com/noxify"
@@ -34,6 +34,7 @@
3434
"test:core": "pnpm -F core test",
3535
"test:drizzle": "pnpm -F adapter-drizzle test",
3636
"test:prisma": "pnpm -F adapter-prisma test",
37+
"test:kysely": "pnpm -F adapter-kysely test",
3738
"cs": "changeset",
3839
"ci:publish": "pnpm -F adapter-prisma prisma:generate && pnpm build:pkg && pnpm publish -r --access public --publish-branch main && pnpm changeset tag",
3940
"ci:version": "pnpm changeset version && pnpm install --no-frozen-lockfile && git add ."

packages/adapter-drizzle/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@electric-sql/pglite": "^0.3.7",
7171
"@vorsteh-queue/eslint-config": "workspace:*",
7272
"@vorsteh-queue/prettier-config": "workspace:*",
73+
"@vorsteh-queue/shared-tests": "workspace:*",
7374
"@vorsteh-queue/tsconfig": "workspace:*",
7475
"drizzle-kit": "^0.31.4",
7576
"drizzle-orm": "^0.44.5",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Migration logic is powered by https://github.com/drizzle-team/drizzle-orm/discussions/1901
2+
3+
import { createRequire } from "module"
4+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"
5+
import { drizzle } from "drizzle-orm/postgres-js"
6+
import postgres from "postgres"
7+
8+
import type { DatabaseConnectionProps } from "@vorsteh-queue/shared-tests/types"
9+
import { runTests } from "@vorsteh-queue/shared-tests/tests/adapter"
10+
11+
import { PostgresQueueAdapter } from "../src"
12+
import * as schema from "../src/postgres-schema"
13+
14+
global.require = createRequire(import.meta.url)
15+
16+
const { generateDrizzleJson, generateMigration } = await import("drizzle-kit/api")
17+
18+
runTests<PostgresJsDatabase<typeof schema>>({
19+
initDbClient: (props: DatabaseConnectionProps): PostgresJsDatabase<typeof schema> => {
20+
const client = postgres(props.container.getConnectionUri(), {
21+
max: 10, // Connection pool size
22+
})
23+
return drizzle(client, { schema })
24+
},
25+
initAdapter: (db) => {
26+
return new PostgresQueueAdapter(db)
27+
},
28+
migrate: async (db) => {
29+
try {
30+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
31+
const [previous, current] = await Promise.all(
32+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
33+
[{}, schema].map((schemaObject) => generateDrizzleJson(schemaObject)),
34+
)
35+
36+
const statements = await generateMigration(previous, current)
37+
const migration = statements.join("\n")
38+
39+
await db.execute(migration)
40+
} catch (err) {
41+
// eslint-disable-next-line no-console
42+
console.error("Migration error:", err)
43+
throw err
44+
}
45+
},
46+
})

0 commit comments

Comments
 (0)