Skip to content

Commit 5779013

Browse files
committed
Add Testcontainers integration tests and GitHub Actions CI
1 parent 7a341ca commit 5779013

8 files changed

Lines changed: 2870 additions & 659 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
name: Typecheck and integration tests
13+
runs-on: ubuntu-24.04
14+
timeout-minutes: 15
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v7
19+
with:
20+
persist-credentials: false
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v7
24+
with:
25+
node-version-file: .nvmrc
26+
cache: npm
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Typecheck
32+
run: npm run typecheck
33+
34+
- name: Run integration tests with Testcontainers
35+
run: npm run test:containers

‎README.md‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ npm run typecheck
2626
npm test
2727
```
2828

29-
- `npm run docker:down` stops and removes the containers. Postgres data is
30-
kept in the named `postgres_data` volume; Redis is intentionally
31-
ephemeral and starts empty the next time the containers are created.
32-
- `npm run docker:reset` stops the containers **and deletes the Postgres
33-
volume**, dropping its schema and data. Re-run `docker:up` + `migrate`
34-
afterward to get back to a clean database.
35-
36-
Requires Node >=24.7 (see `.nvmrc`). Runtime commands such as `migrate` execute
37-
TypeScript directly through Node's built-in type stripping; Vitest transforms
38-
test files and their imports. The `erasableSyntaxOnly` compiler option keeps
39-
the application source compatible with Node's native execution. There is no
40-
build step.
29+
- `npm run docker:down` stops and removes the containers. Postgres data is kept in the named `postgres_data` volume; Redis is intentionally ephemeral and starts empty the next time the containers are created.
30+
- `npm run docker:reset` stops the containers **and deletes the Postgres volume**, dropping its schema and data. Re-run `docker:up` + `migrate` afterward to get back to a clean database.
31+
32+
Requires Node >=24.7 (see `.nvmrc`). Runtime commands such as `migrate` execute TypeScript directly through Node's built-in type stripping; Vitest transforms test files and their imports. The `erasableSyntaxOnly` compiler option keeps the application source compatible with Node's native execution. There is no build step.
33+
34+
## Running tests
35+
36+
Choose the command for your database and container runtime:
37+
38+
| Command | Services |
39+
| --- | --- |
40+
| `npm test` | Existing PostgreSQL and Redis, such as those started by `npm run docker:up` |
41+
| `npm run test:containers` | Temporary PostgreSQL and Redis containers; requires a running Docker daemon |
42+
| `npm run test:containers:colima` | The same temporary containers, with connection settings for Colima's default profile |
43+
44+
The container configuration starts one PostgreSQL (`postgres:16-alpine`) and one Redis (`redis:7-alpine`) container per suite, waits for readiness, and uses dynamically assigned ports. It removes the containers after the suite. Each test creates its own migrated database schema and namespaces Redis keys where needed, so no separate `docker:up` or `migrate` step is required for container tests. The first run may take longer while Docker downloads images.

0 commit comments

Comments
 (0)