This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (116 loc) · 4.88 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Run tests
on: [push]
jobs:
test-node:
name: Test on node ${{ matrix.node_version }}
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: testbench
ports:
- "3308:3306"
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
node_version: ["12", "14", "15", "16"]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install modules
run: yarn install
- name: Create database
env:
DB_TEST_HOST: "127.0.0.1"
DB_TEST_USER: root
DB_TEST_PASS: testbench
DB_TEST_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_TEST_DB: deployer__tests
run: mysql --host ${DB_TEST_HOST} -u${DB_TEST_USER} -p${DB_TEST_PASS} --port ${DB_TEST_PORT} -e "CREATE DATABASE IF NOT EXISTS ${DB_TEST_DB};"
- name: Run migrations
env:
DB_TEST_HOST: "127.0.0.1"
DB_TEST_USER: root
DB_TEST_PASS: testbench
DB_TEST_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_TEST_DB: deployer__tests
run: yarn run migrate:test
- name: Run node tests
env:
DB_TEST_HOST: "127.0.0.1"
DB_TEST_USER: root
DB_TEST_PASS: testbench
DB_TEST_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_TEST_DB: deployer__tests
run: |
mysql --host ${DB_TEST_HOST} -u${DB_TEST_USER} -p${DB_TEST_PASS} --port ${DB_TEST_PORT} -e "CREATE DATABASE IF NOT EXISTS ${DB_TEST_DB};"
yarn run test
yarn run report-coverage
- name: Send coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
test-migrate:
name: Test migrations on node ${{ matrix.node_version }}
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: testbench
ports:
- "3308:3306"
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
node_version: ["12", "14", "15", "16"]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install modules
run: yarn install
- name: Create database
env:
DB_TEST_HOST: "127.0.0.1"
DB_TEST_USER: root
DB_TEST_PASS: testbench
DB_TEST_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_TEST_DB: deployer__migrateupdown
run: mysql --host ${DB_TEST_HOST} -u${DB_TEST_USER} -p${DB_TEST_PASS} --port ${DB_TEST_PORT} -e "CREATE DATABASE IF NOT EXISTS ${DB_TEST_DB};"
- name: Run migration and rollback them
env:
DB_TEST_HOST: "127.0.0.1"
DB_TEST_USER: root
DB_TEST_PASS: testbench
DB_TEST_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_TEST_DB: deployer__migrateupdown
run: |
yarn run migrate:test
yarn run migrate:rollback:test