-
Notifications
You must be signed in to change notification settings - Fork 178
384 lines (365 loc) · 16.5 KB
/
app-test-build-deploy.yaml
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# Run tests, build the app, and deploy it cross platform
name: 'App test, build, and deploy'
on:
push:
paths:
- 'Makefile'
- 'app/**/*'
- 'app-shell/**/*'
- 'app-shell-odd/**/*'
- 'components/**/*'
- 'shared-data/**/*'
- 'webpack-config/**/*'
- 'discovery-client/**/*'
- '*.js'
- 'scripts/**/*'
- '*.json'
- 'yarn.lock'
- '.github/workflows/app-test-build-deploy.yaml'
- '.github/workflows/utils.js'
branches:
- '**'
tags:
- 'v*'
- 'ot3@*'
pull_request:
paths:
- 'Makefile'
- 'app/**/*'
- 'app-shell/**/*'
- 'app-shell-odd/**/*'
- 'components/**/*'
- 'shared-data/**/*'
- 'webpack-config/**/*'
- 'discovery-client/**/*'
- '*.js'
- '*.json'
- 'yarn.lock'
- 'scripts/**/*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }}
cancel-in-progress: true
env:
CI: true
_APP_DEPLOY_BUCKET_ROBOTSTACK: opentrons-app
_APP_DEPLOY_FOLDER_ROBOTSTACK: builds
_APP_DEPLOY_BUCKET_OT3: ot3-development.builds.opentrons.com
_APP_DEPLOY_FOLDER_OT3: app
jobs:
js-unit-test:
# unit tests for the app's view layer (not the node layer)
runs-on: 'ubuntu-22.04'
name: 'opentrons app frontend unit tests'
timeout-minutes: 60
steps:
- uses: 'actions/checkout@v3'
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- name: 'install udev'
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.npm-cache/_prebuild
${{ github.workspace }}/.yarn-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: 'setup-js'
run: |
npm config set cache ${{ github.workspace }}/.npm-cache
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
make setup-js
- name: 'test frontend packages'
run: |
yarn jest --coverage=true --ci=true --collectCoverageFrom="app/src/**/*.(js|ts|tsx)" app/src components/src shared-data/js
- name: 'Upload coverage report'
uses: codecov/codecov-action@v3
with:
files: ./coverage/lcov.info
flags: app
build-app-test-backend:
# since js tests for "backend" projects (app-shell, discovery-client) need
# to run cross-platform just like builds, might as well do them in the same job
strategy:
matrix:
os: ['windows-2022', 'ubuntu-22.04', 'macos-11']
name: 'opentrons app backend unit tests and build'
runs-on: ${{ matrix.os }}
steps:
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/290
- name: 'Fix actions/checkout odd handling of tags'
if: startsWith(github.ref, 'refs/tags')
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
git checkout ${{ github.ref }}
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: 'downgrade npm version'
run: npm install -g npm@6
- name: check make version
run: make --version
- name: 'install libudev and libsystemd'
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.npm-cache/_prebuild
${{ github.workspace }}/.yarn-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: setup-js
run: |
npm config set cache ${{ github.workspace }}/.npm-cache
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
- name: setup-js
run: |
make setup-js
- name: 'test native(er) packages'
run: |
yarn jest --coverage=true --ci=true --collectCoverageFrom="(app-shell|app-shell-odd| discovery-client)/src/**/*.(js|ts|tsx)" app-shell/src app-shell-odd/src discovery-client/src
- name: 'Upload coverage report'
uses: 'codecov/codecov-action@v3'
with:
files: ./coverage/lcov.info
flags: app
# build the desktop app and deploy it
- if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
name: 'build app for ${{ matrix.os }}'
timeout-minutes: 60
env:
OT_APP_MIXPANEL_ID: ${{ secrets.OT_APP_MIXPANEL_ID }}
OT_APP_INTERCOM_ID: ${{ secrets.OT_APP_INTERCOM_ID }}
WIN_CSC_LINK: ${{ secrets.OT_APP_CSC_WINDOWS }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_WINDOWS }}
CSC_LINK: ${{ secrets.OT_APP_CSC_MACOS }}
CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_MACOS }}
APPLE_ID: ${{ secrets.OT_APP_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.OT_APP_APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.OT_APP_APPLE_TEAM_ID }}
HOST_PYTHON: python
OPENTRONS_PROJECT: robot-stack
OT_APP_DEPLOY_BUCKET: ${{ env._APP_DEPLOY_BUCKET_ROBOTSTACK }}
OT_APP_DEPLOY_FOLDER: ${{ env._APP_DEPLOY_FOLDER_ROBOTSTACK }}
run: |
make -C app-shell dist-${{ matrix.os }}
- if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
name: 'upload github artifact'
uses: actions/upload-artifact@v3
with:
name: 'opentrons-${{ matrix.os }}'
path: app-shell/dist/publish
# build the ODD app
- if: ${{ github.event_name != 'pull_request' && matrix.os == 'ubuntu-22.04' }}
name: 'build ODD app for linux'
timeout-minutes: 60
run: |
make -C app-shell-odd dist-ot3
build-app-ot3:
strategy:
matrix:
os: ['windows-2022', 'ubuntu-22.04', 'macos-latest']
exclude:
- os: format('macos-latest{0}', startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build') || null)
- os: format('windows-2022{0}', startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build') || null)
name: 'opentrons app backend unit tests and build for OT3'
runs-on: ${{ matrix.os }}
steps:
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/290
- name: 'Fix actions/checkout odd handling of tags'
if: startsWith(github.ref, 'refs/tags')
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
git checkout ${{ github.ref }}
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: 'downgrade npm version'
run: npm install -g npm@6
- name: check make version
run: make --version
- name: 'install libudev'
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install libudev-dev libsystemd-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.npm-cache/_prebuild
${{ github.workspace }}/.yarn-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: setup-js
run: |
npm config set cache ${{ github.workspace }}/.npm-cache
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
make setup-js
# build the app and deploy it
- if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
name: 'build app for ${{ matrix.os }}'
timeout-minutes: 60
env:
OT_APP_MIXPANEL_ID: ${{ secrets.OT_APP_MIXPANEL_ID }}
OT_APP_INTERCOM_ID: ${{ secrets.OT_APP_INTERCOM_ID }}
WIN_CSC_LINK: ${{ secrets.OT_APP_CSC_WINDOWS }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_WINDOWS }}
CSC_LINK: ${{ secrets.OT_APP_CSC_MACOS }}
CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_MACOS }}
APPLE_ID: ${{ secrets.OT_APP_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.OT_APP_APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.OT_APP_APPLE_TEAM_ID }}
HOST_PYTHON: python
OPENTRONS_PROJECT: ot3
OT_APP_DEPLOY_BUCKET: ${{ env._APP_DEPLOY_BUCKET_OT3 }}
OT_APP_DEPLOY_FOLDER: ${{ env._APP_DEPLOY_FOLDER_OT3 }}
run: |
make -C app-shell dist-${{ matrix.os }}
- if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
name: 'upload github artifact'
uses: actions/upload-artifact@v3
with:
name: 'opentrons-ot3-${{ matrix.os }}'
path: app-shell/dist/publish
deploy-app:
name: 'Deploy built app artifacts to S3'
runs-on: 'ubuntu-22.04'
needs: ['js-unit-test', 'build-app-test-backend']
if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
steps:
- name: 'download run app builds'
uses: 'actions/download-artifact@v3'
with:
path: .
- name: 'deploy builds to s3'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_APP_DEPLOY_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_APP_DEPLOY_SECRET }}
AWS_DEFAULT_REGION: us-east-2
run: |
mkdir to_upload
rm -rf ./opentrons-ot3-*
cp ./opentrons-*/* ./to_upload/
aws s3 sync --acl=public-read to_upload/ s3://${{ env._APP_DEPLOY_BUCKET_ROBOTSTACK }}/${{ env._APP_DEPLOY_FOLDER_ROBOTSTACK }}
deploy-app-ot3:
name: 'Deploy built OT3 app artifacts to S3'
runs-on: 'ubuntu-22.04'
needs: ['js-unit-test', 'build-app-ot3']
if: (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/edge') || startsWith(github.ref, 'refs/heads/internal-release') || startsWith(github.ref, 'refs/heads/release') || endsWith(github.ref, 'app-build'))
steps:
- name: 'download run app builds'
uses: 'actions/download-artifact@v3'
with:
path: .
- name: 'configure ot3 s3 deploy creds'
run: |
aws configure set aws_access_key_id ${{ secrets.S3_OT3_APP_DEPLOY_KEY_ID }} --profile identity
aws configure set aws_secret_access_key ${{ secrets.S3_OT3_APP_DEPLOY_SECRET }} --profile identity
aws configure set region us-east-2 --profile identity
aws configure set output json --profile identity
aws configure set region us-east-2 --profile deploy
aws configure set role_arn ${{ secrets.OT_APP_OT3_DEPLOY_ROLE }} --profile deploy
aws configure set source_profile identity --profile deploy
shell: bash
- name: 'deploy builds to s3'
run: |
mkdir to_upload
cp ./opentrons-ot3-*/* ./to_upload
aws --profile=deploy s3 sync --acl=public-read to_upload s3://${{ env._APP_DEPLOY_BUCKET_OT3 }}/${{ env._APP_DEPLOY_FOLDER_OT3 }}
- name: 'create GH release'
uses: 'ncipollo/[email protected]'
if: startsWith(github.ref, 'refs/tags/ot3@')
with:
allowUpdates: true
replacesArtifacts: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true
- name: 'upload windows artifact to GH release'
uses: 'ncipollo/[email protected]'
if: startsWith(github.ref, 'refs/tags/ot3@')
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: ./to_upload/*.exe
artifactContentType: application/vnd.microsoft.portable-executable
- name: 'upload mac artifact to GH release'
uses: 'ncipollo/[email protected]'
if: startsWith(github.ref, 'refs/tags/ot3@')
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: ./to_upload/*.dmg
artifactContentType: application/octet-stream
- name: 'upload linux artifact to GH release'
uses: 'ncipollo/[email protected]'
if: startsWith(github.ref, 'refs/tags/ot3@')
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: ./to_upload/*.AppImage
artifactContentType: application/octet-stream
- name: 'detect build data for notification'
id: names
run: |
ls ./to_upload
_windows_build=$(basename $(ls ./to_upload/Opentrons-OT3*.exe))
_mac_build=$(basename $(ls ./to_upload/Opentrons-OT3*.dmg))
_linux_build=$(basename $(ls ./to_upload/Opentrons-OT3*.AppImage))
if [[ -e latest.yml ]] ; then
echo "TYPE=release" >> $GITHUB_OUTPUT
else
echo "TYPE=branch" >> $GITHUB_OUTPUT
fi
echo "WINDOWS=$_windows_build">>$GITHUB_OUTPUT
echo "MAC=$_mac_build">>$GITHUB_OUTPUT
echo "LINUX=$_linux_build">>$GITHUB_OUTPUT
- name: 'slack notify for ot3 builds'
uses: slackapi/[email protected]
with:
payload: "{\"branch_or_tag\":\"${{ github.ref_name }}\",\"build_type\":\"${{ steps.names.outputs.TYPE }}\", \"gh_linkback\":\"https://github.com/Opentrons/opentrons/tree/${{ github.ref_name }}\", \"windows_build\":\"${{ env._ACCESS_URL }}/${{steps.names.outputs.WINDOWS}}\", \"mac_build\":\"${{ env._ACCESS_URL }}/${{steps.names.outputs.MAC}}\", \"linux_build\":\"${{ env._ACCESS_URL }}/${{steps.names.outputs.LINUX}}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.OT_APP_OT3_SLACK_NOTIFICATION_WEBHOOK_URL }}
_ACCESS_URL: https://${{env._APP_DEPLOY_BUCKET_OT3}}/${{env._APP_DEPLOY_FOLDER_OT3}}