-
-
Notifications
You must be signed in to change notification settings - Fork 219
355 lines (328 loc) · 11.5 KB
/
build.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
name: Build and test
on: [push, pull_request]
env:
COUCH_URL: http://admin:pass@localhost:5984/medic-test
BUILDS_SERVER: ${{ secrets.AUTH_MARKET_URL && '_couch/builds_testing' || '_couch/builds_external' }}
STAGING_SERVER: ${{ secrets.AUTH_MARKET_URL && '_couch/builds_4' || '_couch/builds_external' }}
MARKET_URL_READ: 'https://staging.dev.medicmobile.org'
MARKET_URL: ${{ secrets.AUTH_MARKET_URL || 'https://staging.dev.medicmobile.org' }}
INTERNAL_CONTRIBUTOR: ${{ secrets.AUTH_MARKET_URL && 'true' }}
DOCKERHUB_USERNAME: 'dockermedic'
ECR_REPO: '720541322708.dkr.ecr.eu-west-2.amazonaws.com/medic'
ECR_PUBLIC_REPO: 'public.ecr.aws/medic'
COUCHDB_LOG_LEVEL: 'debug'
TAG: ${{ (github.ref_type == 'tag' && github.ref_name) || '' }}
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_NUMBER: ${{ github.run_id }}
jobs:
build:
name: Compile the app
runs-on: ubuntu-22.04
steps:
- name: Install bats
run: |
sudo apt-get update
sudo apt-get install -y bats
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: ${{ env.INTERNAL_CONTRIBUTOR }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
if: ${{ env.INTERNAL_CONTRIBUTOR }}
- name: Login to Amazon ECR
id: login-ecr
if: ${{ env.INTERNAL_CONTRIBUTOR }}
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Couch Start
run: ./scripts/ci/couch-start
- name: Create logs directory
run: mkdir tests/logs
- run: npm ci
- name: Compile
run: npm run ci-compile
- name: Publish for testing
run: npm run publish-for-testing
- name: Upload docker images as artifacts
uses: actions/upload-artifact@v3
with:
name: cht-images
path: images/
if: ${{ !env.INTERNAL_CONTRIBUTOR }}
config-tests:
needs: build
name: ${{ matrix.cmd }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
cmd: ['test-config-standard', 'test-config-default']
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- name: Run Tests
run: npm run ${{ matrix.cmd }}
test-cht-form:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: sudo apt-get install -y xsltproc
- run: npm ci
- name: Build cht-form Web Component
run: npm run build-cht-form
- name: Run Tests
run: npm run wdio-cht-form
tests:
needs: build
name: ${{ matrix.cmd }}-${{ matrix.suite || '' }}${{ matrix.chrome-version == '90' && '-minimum-browser' || '' }}
runs-on: ubuntu-22.04
env:
NODE: 16.x
CHROME_VERSION: ${{ matrix.chrome-version }}
strategy:
fail-fast: false
matrix:
cmd: ['ci-webdriver-standard', 'ci-integration-all', 'ci-integration-sentinel', 'ci-webdriver-default-mobile']
chrome-version: ['90', 'latest']
suite: [all]
include:
- cmd: ci-webdriver-default
suite: core
- cmd: ci-webdriver-default
suite: data
- cmd: ci-webdriver-default
suite: enketo
- cmd: ci-webdriver-default
suite: lowLevel
- cmd: ci-webdriver-default
suite: workflows
exclude: # temporary until all suites run on Chrome 90
- cmd: ci-integration-all
chrome-version: 90
- cmd: ci-integration-sentinel
chrome-version: 90
- cmd: ci-webdriver-default-mobile
chrome-version: 90
- cmd: ci-webdriver-default
chrome-version: 90
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: ${{ env.INTERNAL_CONTRIBUTOR }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
if: ${{ env.INTERNAL_CONTRIBUTOR }}
- name: Login to Amazon ECR
id: login-ecr
if: ${{ env.INTERNAL_CONTRIBUTOR }}
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- uses: actions/checkout@v3
- name: Download docker images artifacts
uses: actions/download-artifact@v3
with:
name: cht-images
path: images/
if: ${{ !env.INTERNAL_CONTRIBUTOR }}
- name: Load docker images
run: ls -1 *.tar | xargs --no-run-if-empty -L 1 docker load -i
working-directory: images/
if: ${{ !env.INTERNAL_CONTRIBUTOR }}
- name: Set ENV
run: |
echo "HORTI_BUILDS_SERVER=$MARKET_URL_READ/$BUILDS_SERVER" >> $GITHUB_ENV
- name: Create logs directory
run: mkdir tests/logs
- name: Install pyxform
run: python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
- name: Install cht-conf
run: npm install -g cht-conf
- run: npm ci
- name: Fetch allure history
uses: actions/checkout@v3
with:
repository: 'medic/build-history-data'
path: 'build-history-data'
persist-credentials: false
- name: Copy allure history
run: |
mkdir -p allure-results/history
cp -r build-history-data/cht-core/allure/${{ matrix.cmd }}-${{ matrix.suite }}/allure-report/history allure-results | true
- name: Install Chrome 90
if: ${{matrix.chrome-version=='90'}}
run: |
wget -O "google-chrome-stable_current_amd64.deb" https://www.slimjet.com/chrome/download-chrome.php?file=files/90.0.4430.72/google-chrome-stable_current_amd64.deb
sudo dpkg -i "google-chrome-stable_current_amd64.deb"
npm install chromedriver@^90.0.1
- name: Run tests ${{ matrix.cmd }}-${{ matrix.suite }} on Chrome ${{ matrix.chrome-version }}
run: npm run ${{ matrix.cmd }} -- --suite=${{ matrix.suite }}
- name: Fetch allure history
if: always()
uses: actions/checkout@v3
with:
repository: 'medic/build-history-data'
path: 'build-history-data-new'
persist-credentials: false
- name: Copy new allure history
if: always()
run: |
mkdir -p build-history-data-new/cht-core/allure/${{ matrix.cmd }}-${{ matrix.suite }}/history
cp -r allure-report/history build-history-data-new/cht-core/allure/${{ matrix.cmd }}-${{ matrix.suite }}/allure-report | true
- name: Upload allure report history
if: always() && github.ref == 'refs/heads/master' # whether pass or fail, but only on master
continue-on-error: true # don't fail the build if git push fails
uses: actions-js/push@master
with:
github_token: ${{ secrets.BUILD_HISTORY_DATA_PUSH_TOKEN }}
directory: 'build-history-data-new'
repository: 'medic/build-history-data'
force: true
- name: Fetch report repo
if: always()
uses: actions/checkout@v3
with:
repository: 'medic/build-history'
path: 'build-history'
persist-credentials: false
- name: Copy new report
if: always()
run: |
mkdir -p build-history/cht-core/allure/${{ matrix.cmd }}-${{ matrix.suite }}
cp -r allure-report build-history/cht-core/allure/${{ matrix.cmd }}-${{ matrix.suite }} | true
- name: Upload allure report
if: always() && github.ref == 'refs/heads/master' # whether pass or fail, but only on master
continue-on-error: true # don't fail the build if git push fails
uses: actions-js/push@master
with:
github_token: ${{ secrets.BUILD_HISTORY_DATA_PUSH_TOKEN }}
directory: 'build-history'
repository: 'medic/build-history'
force: true
- name: Archive Results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.cmd }}-${{ matrix.suite || ''}}
path: |
allure-results
allure-report
tests/logs
tests/results/
if: ${{ failure() }}
publish:
needs: [tests, config-tests, test-cht-form]
name: Publish branch build
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Delete image artifacts
if: ${{ !env.INTERNAL_CONTRIBUTOR }}
uses: geekyeggo/delete-artifact@v1
with:
name: cht-images
- name: Configure AWS credentials
if: ${{ env.INTERNAL_CONTRIBUTOR }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: Login to Amazon ECR
if: ${{ env.INTERNAL_CONTRIBUTOR }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Configure AWS credentials Public
if: ${{ env.INTERNAL_CONTRIBUTOR }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Public Amazon ECR
if: ${{ env.INTERNAL_CONTRIBUTOR }}
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
mask-password: 'true'
- uses: actions/checkout@v3
- name: Publish
run: |
cd scripts/ci
npm ci
node ./publish.js
node ./tag-docker-images.js
upgrade:
needs: [publish]
name: Upgrade from latest release
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Configure AWS credentials Public
if: ${{ env.INTERNAL_CONTRIBUTOR }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Public Amazon ECR
if: ${{ env.INTERNAL_CONTRIBUTOR }}
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
mask-password: 'true'
- uses: actions/checkout@v3
- name: Set ENV
run: |
echo "BUILDS_SERVER=$STAGING_SERVER" >> $GITHUB_ENV
- run: npm ci
- name: Create logs directory
run: mkdir tests/logs
- name: Upgrade
run: npm run upgrade-wdio
- name: Archive Results
uses: actions/upload-artifact@v3
with:
name: Upgrade
path: |
allure-results
allure-report
tests/logs
tests/results/
if: ${{ failure() }}