-
Notifications
You must be signed in to change notification settings - Fork 179
171 lines (163 loc) · 5.86 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
# Run tests, build the app, and deploy it cross platform
name: 'App test, build, and deploy'
on:
push:
paths:
- 'Makefile'
- 'app/**/*'
- 'app-shell/**/*'
- '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*'
pull_request:
paths:
- 'Makefile'
- 'app/**/*'
- 'app-shell/**/*'
- 'components/**/*'
- 'shared-data/**/*'
- 'webpack-config/**/*'
- 'discovery-client/**/*'
- '*.js'
- '*.json'
- 'yarn.lock'
- 'scripts/**/*'
workflow_dispatch:
env:
CI: true
OT_APP_DEPLOY_BUCKET: opentrons-app
OT_APP_DEPLOY_FOLDER: builds
jobs:
js-unit-test:
# unit tests for js frontend projects (e.g. not app-shell or discovery-client) do not need
# to run cross-platform
runs-on: 'ubuntu-18.04'
name: 'opentrons app frontend unit tests'
timeout-minutes: 30
steps:
- uses: 'actions/checkout@v2'
- uses: 'actions/setup-node@v1'
with:
node-version: '14'
- name: 'install udev'
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/[email protected]
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v2
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@v2
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-latest', 'ubuntu-18.04', 'macos-latest']
name: 'opentrons app backend unit tests and build'
runs-on: ${{ matrix.os }}
steps:
- uses: 'actions/checkout@v2'
- uses: 'actions/setup-node@v1'
with:
node-version: '14'
- name: 'install libudev'
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/[email protected]
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v2
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 native(er) packages'
run: |
yarn jest --coverage=true --ci=true --collectCoverageFrom="(app-shell|discovery-client)/src/**/*.(js|ts|tsx)" app-shell/src discovery-client/src
- name: 'Upload coverage report'
uses: 'codecov/codecov-action@v2'
with:
files: ./coverage/lcov.info
flags: app
# build the app and deploy it
- if: github.event_name != 'pull_request'
name: 'build app for ${{ matrix.os }}'
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_ID_PASSWORD: ${{ secrets.OT_APP_APPLE_ID_PASSWORD }}
run: |
make -C app-shell dist-${{ matrix.os }}
- if: github.event_name != 'pull_request'
name: 'upload github artifact'
uses: actions/upload-artifact@v2
with:
name: 'opentrons-${{ matrix.os }}'
path: app-shell/dist/publish
deploy-app:
name: 'Deploy built app artifacts to S3'
runs-on: 'ubuntu-18.04'
needs: build-app-test-backend
if: github.event_name != 'pull_request'
steps:
- name: 'download run app builds'
uses: 'actions/download-artifact@v2'
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
cp ./opentrons-*/* ./to_upload/
aws s3 sync --acl=public-read to_upload/ s3://${{ env.OT_APP_DEPLOY_BUCKET }}/${{ env.OT_APP_DEPLOY_FOLDER }}