-
-
Notifications
You must be signed in to change notification settings - Fork 16
103 lines (86 loc) · 2.64 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Tests the App
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-test:
name: Build and test with Node.js ${{ matrix.node-version }} and ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
# Don't cancel all the jobs if one of them fails
fail-fast: false
matrix:
node-version: [18, 20]
db: [postgresql, mysql]
include:
- db: postgresql
db-image: postgres:14
db-port: 5432
db-username: postgres
db-options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
- db: mysql
db-image: mysql:8
db-port: 3306
db-username: root
db-options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
services:
db:
image: ${{ matrix.db-image }}
env:
POSTGRES_USER: ${{ matrix.db-username }}
POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }}
POSTGRES_DB: testdb
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_DATABASE: testdb
ports:
- ${{ matrix.db-port }}:${{ matrix.db-port }}
options: >-
--name db
--hostname db
${{ matrix.db-options }}
env:
DB_PROVIDER: ${{ matrix.db }}
DB_URL: ${{ matrix.db }}://${{ matrix.db-username }}:${{ secrets.DB_PASSWORD }}@localhost:${{ matrix.db-port }}/testdb
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}-${{ matrix.node-version }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install
- name: Run linting
run: pnpm run lint
- name: Run database migrations
run: pnpm run db:migrate
- name: Run database seed
run: pnpm run db:seed
- name: Build the app
run: pnpm run build
- name: Run unit tests
run: pnpm run test
- name: Run e2e tests
run: pnpm run test:e2e