-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (63 loc) · 1.69 KB
/
node.js.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
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
test:
runs-on: ubuntu-latest
needs: build
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: test
ports:
- 3307:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Wait for MySQL to be healthy
run: |
while ! docker exec -t $(docker ps -q --filter "ancestor=mysql:8.0") mysqladmin ping --silent; do sleep 1; done
- name: Initialize database
run: |
docker exec -i $(docker ps -q --filter "ancestor=mysql:8.0") mysql -uroot -prootpassword test < ./dbscripts/mysql.sql
- name: Run tests
env:
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_HOST: 127.0.0.1
MYSQL_PASSWORD: rootpassword
MYSQL_URL: mysql://root:[email protected]:3307/test
MYSQL_PORT: 3307
NODE_ENV: test
run: npm test