Skip to content

Commit 5d8811b

Browse files
committed
Setup test db (#132)
* add test db in compose and gh actions * add test db setup script * move cleanDatabase to a helper file * rm unused test * adjustments to make it work * remove header param from playwright and add NODE_ENV=test in gh test action Also adjust DATABASE_URL in env example * install browsers with deps * fix seeds
1 parent 5a031ae commit 5d8811b

File tree

11 files changed

+619
-82
lines changed

11 files changed

+619
-82
lines changed

.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DATABASE_URL=postgres://postgres:postgres@localhost:6532/taco
1+
DATABASE_URL=postgres://postgres:postgres@localhost:6532/db
22
SECRET_KEY=
33
POSTMARK_API_KEY=
44
EMAIL_SENDER_SIGNATURE=

.github/workflows/test.yml

+29-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12+
services:
13+
postgres:
14+
image: postgres:15
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: db
19+
ports:
20+
- 5432:5432
21+
options: >-
22+
--health-cmd pg_isready
23+
--health-interval 10s
24+
--health-timeout 5s
25+
--health-retries 5
26+
27+
env:
28+
POSTMARK_API_KEY: SECRET
29+
PUBLIC_SITE_NAME: TACO [TEST]
30+
EMAIL_SENDER_SIGNATURE: [email protected]
31+
PUBLIC_SENTRY_DSN: SECRET
32+
PUBLIC_SENTRY_ENV: test
33+
PUBLIC_SITE_URL: http://localhost:5173/
34+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/db
35+
NODE_ENV: test
1236

1337
steps:
1438
- name: Checkout repository
@@ -22,15 +46,11 @@ jobs:
2246
- name: Install dependencies
2347
run: npm ci
2448

25-
- name: Install Playwright browsers
26-
run: npx playwright install
49+
- name: Install Playwright Browsers
50+
run: npx playwright install --with-deps
51+
52+
- name: Run Prisma migrations
53+
run: npx prisma migrate deploy
2754

2855
- name: Run tests
2956
run: npm test
30-
env:
31-
POSTMARK_API_KEY: 'SECRET'
32-
PUBLIC_SITE_NAME: 'TACO [TEST]'
33-
EMAIL_SENDER_SIGNATURE: '[email protected]'
34-
PUBLIC_SENTRY_DSN: 'SECRET'
35-
PUBLIC_SENTRY_ENV: 'test'
36-
PUBLIC_SITE_URL: 'http://localhost:5173/'

docker-compose.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
version: "3.8"
22
services:
33
db:
4-
image: postgres:latest
4+
image: postgres:15
55
environment:
6-
- POSTGRES_USER=postgres
7-
- POSTGRES_PASSWORD=postgres
8-
- POSTGRES_DB=taco
6+
POSTGRES_USER: postgres
7+
POSTGRES_PASSWORD: postgres
8+
POSTGRES_DB: db
99
ports:
1010
- "6532:5432"
1111
volumes:
1212
- db:/var/lib/postgresql/data
13+
test-db:
14+
image: postgres:15
15+
environment:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: db
19+
ports:
20+
- "3432:5432"
1321

1422
volumes:
1523
db:

0 commit comments

Comments
 (0)