-
Notifications
You must be signed in to change notification settings - Fork 4
249 lines (214 loc) · 6.53 KB
/
automated-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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
on:
push:
branches:
- master
pull_request:
branches:
- master
name: CI
jobs:
lint:
name: ESLint
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x]
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Restore ESLint from cache
uses: actions/cache@v2
id: eslint_api_cache
with:
path: |
./node_modules
key: ${{ runner.os }}-${{ hashFiles('./package-lock.json') }}
- name: Install ESLint
if: steps.eslint_api_cache.outputs.cache-hit != 'true'
run: npm install eslint --ignore-scripts
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
fail_on_error: true
eslint_flags: 'packages/api'
web:
name: WEB tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x]
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Restore dependencies from cache
uses: actions/cache@v2
id: web_dependencies_cache
with:
path: |
**/web/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/web/package-lock.json') }}
- name: Install dependencies
if: steps.web_dependencies_cache.outputs.cache-hit != 'true'
working-directory: packages/web
run: npm ci
- name: Run WEB tests
working-directory: packages/web
run: npm run jest:ci
- name: Zip coverage data
working-directory: packages/web
run: zip -r coverage.zip ./coverage/
- name: Upload coverage data
uses: actions/upload-artifact@v2
with:
name: web_coverage
path: |
**/web/coverage.zip
retention-days: 2
api:
name: API tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x]
os: ["ubuntu-latest"]
services:
plataforma-sabia-redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
plataforma-sabia-mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: sabia_testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Restore dependencies from cache
uses: actions/cache@v2
id: api_dependencies_cache
with:
path: |
**/api/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/api/package-lock.json') }}
- name: Install dependencies
if: steps.api_dependencies_cache.outputs.cache-hit != 'true'
working-directory: packages/api
run: npm ci
- name: Setup API environments
working-directory: packages/api
run: cp .env.testing .env
- name: Run API tests
working-directory: packages/api
run: npm run coverage
- name: Zip coverage data
working-directory: packages/api
run: zip -r coverage.zip ./.nyc_output
- name: Upload coverage data
uses: actions/upload-artifact@v2
with:
name: api_coverage
path: |
**/api/coverage.zip
retention-days: 2
# This job needs artifacts that are generated by each one of the above jobs
# Theoretically we should wait them to finish before start this one
# But, we can try to get coverage data after E2E tests run
# It should be enough time to web/api job get done
e2eAndCoverage:
name: E2E / Coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x]
os: ["ubuntu-latest"]
services:
plataforma-sabia-redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
plataforma-sabia-mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: sabia_testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore dependencies from cache
uses: actions/cache@v2
id: project_dependencies
with:
path: |
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install project dependencies
if: steps.project_dependencies.outputs.cache-hit != 'true'
run: npm ci
- name: Prepare API for e2e tests
working-directory: packages/api
run: |
cp .env.testing .env
npm run migration:run -- --seed
- name: Run Cypress tests
uses: cypress-io/github-action@v2
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
command: npm run test:e2e:run
browser: chrome
install: false
- name: Download WEB coverage
uses: actions/download-artifact@v2
with:
name: web_coverage
- name: Download API coverage
uses: actions/download-artifact@v2
with:
name: api_coverage
- name: Unzip WEB coverage
working-directory: packages/web
run: |
unzip coverage.zip -d .
- name: Unzip API coverage
working-directory: packages/api
run: |
unzip coverage.zip -d .
- name: Merge coverages
run: |
npm run merge-coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}