-
Notifications
You must be signed in to change notification settings - Fork 58
391 lines (330 loc) · 11 KB
/
build-test-pr.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
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
385
386
387
388
389
390
391
name: PR BuildAndTest.CI
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
env:
pythonVersion: 3.7
HIML_TENANT_ID: ${{ secrets.HIML_TENANT_ID }}
HIML_RESOURCE_GROUP: ${{ secrets.HIML_RESOURCE_GROUP }}
HIML_SUBSCRIPTION_ID: ${{ secrets.HIML_SUBSCRIPTION_ID }}
HIML_WORKSPACE_NAME: ${{ secrets.HIML_WORKSPACE_NAME }}
HIML_SERVICE_PRINCIPAL_ID: ${{ secrets.HIML_SERVICE_PRINCIPAL_ID }}
HIML_SERVICE_PRINCIPAL_PASSWORD: ${{ secrets.HIML_SERVICE_PRINCIPAL_PASSWORD }}
HIML_DIST_ARTIFACT_SUFFIX: '-dist'
HIML_PACKAGE_NAME_ARTIFACT_SUFFIX: '-package_name'
HIML_VERSION_ARTIFACT_SUFFIX: '-latest_version'
HIML_COV_DOT_ARTIFACT_SUFFIX: '-code_coverage_report_dot'
HIML_COV_HTML_ARTIFACT_SUFFIX: '-code_coverage_report_html'
HIML_COV_TXT_ARTIFACT_SUFFIX: '-code_coverage_txt'
HIML_COV_XML_ARTIFACT_SUFFIX: '-code_coverage_xml'
jobs:
flake8:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: flake8
run: make flake8
mypy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: mypy
run: make mypy
pyright:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true
- uses: actions/setup-node@v2
with:
node-version: '14'
- uses: conda-incubator/setup-miniconda@v2
- name: pyright
shell: bash -l {0}
run: |
conda info
make pyright
pytest_fast:
runs-on: ubuntu-18.04
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure, hi-ml-histopathology ]
# This will let all parts of the matrix run, to collect as many errors as possible, rather than aborting after first fail
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: Install hi-ml-azure in editable mode
if: ${{ matrix.folder != 'hi-ml-azure' }}
run: |
cd hi-ml-azure
# Install local package in editable mode
make pip_local
- name: Install hi-ml in editable mode
if: ${{ matrix.folder != 'hi-ml-azure' && matrix.folder != 'hi-ml' }}
run: |
cd hi-ml
# Install local package in editable mode
make pip_local
- name: Test with pytest, fast only
run: |
cd ${{ matrix.folder }}
# Install local package in editable mode
make pip_local
# Run fast tests
make pytest_fast
build-python:
runs-on: ubuntu-18.04
needs: [ pytest_fast ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: Build Distribution
run: |
cd ${{ matrix.folder }}
make build
- name: Upload package artifacts
uses: ./.github/actions/upload_package_artifacts
with:
folder: ${{ matrix.folder }}
test-artifact-pkg:
runs-on: ubuntu-18.04
needs: [ build-python ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
packageName: [ '*.whl', '*.tar.gz' ]
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: Download dependent package artifacts
id: download_dep
if: ${{ matrix.folder != 'hi-ml-azure' }}
uses: ./.github/actions/download_package_artifacts
with:
folder: hi-ml-azure
package_type: ${{ matrix.packageName }}
- name: Install dependencies
if: ${{ matrix.folder != 'hi-ml-azure' }}
run: |
cd hi-ml-azure
make pip_upgrade
# Install package
pip install ${{ steps.download_dep.outputs.package_filename }}
- name: Download package artifacts
id: download
if: ${{ matrix.folder != 'hi-ml-histopathology' }}
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
package_type: ${{ matrix.packageName }}
- name: Install artifact and test
run: |
cd ${{ matrix.folder }}
if [ ${{ matrix.folder }} != 'hi-ml-histopathology' ]; then
make pip_upgrade
# Install package
pip install ${{ steps.download.outputs.package_filename }}
fi
if [ ${{ matrix.packageName }} == '*.whl' ]; then
# Set env vars so wheel is sent to azureml as a private package
echo "HIML_AZURE_WHEEL_FILENAME=${{ steps.download.outputs.package_filename }}" >> $GITHUB_ENV
# Test with pytest
make pytest_and_coverage
else
# Test with pytest, fast only
make pytest_fast
fi
- name: Upload coverage report to Codecov
if: ${{ matrix.packageName == '*.whl' }}
uses: codecov/codecov-action@v2
with:
name: ${{ matrix.folder }}
test-project-folders:
runs-on: ubuntu-18.04
needs: [ build-python ]
strategy:
matrix:
folder: [ hi-ml-histopathology ]
packageName: [ '*.whl' ]
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: PIP upgrade
run: |
cd hi-ml-azure
make pip_upgrade
- name: Download hi-ml-azure
id: download_himlazure
uses: ./.github/actions/download_package_artifacts
with:
folder: hi-ml-azure
package_type: ${{ matrix.packageName }}
- name: Download hi-ml
id: download_himl
uses: ./.github/actions/download_package_artifacts
with:
folder: hi-ml
package_type: ${{ matrix.packageName }}
- name: Install dependencies
run: |
cd hi-ml-azure
pip install ${{ steps.download_himlazure.outputs.package_filename }}
cd ../hi-ml
pip install ${{ steps.download_himl.outputs.package_filename }}
- name: Run tests
run: |
cd ${{ matrix.folder }}
make pip_local
make pytest_and_coverage
- name: Upload coverage report to Codecov
if: ${{ matrix.packageName == '*.whl' }}
uses: codecov/codecov-action@v2
with:
name: ${{ matrix.folder }}
- name: Run GPU tests
run: |
branch_prefix="refs/heads/"
full_branch_name=$GITHUB_REF
branch_name_without_prefix=${full_branch_name#$branch_prefix}
python hi-ml-azure/run_pytest.py --mark=gpu --cluster=pr-gpu --conda_env=${{ matrix.folder }}/environment.yml --folder=${{ matrix.folder }} --experiment="$branch_name_without_prefix"
publish-testpypi-pkg:
runs-on: ubuntu-18.04
needs: [ test-artifact-pkg ]
if: "!startsWith(github.ref, 'refs/tags/v')"
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Download package artifacts
id: download
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Set envs
run: |
if [ ${{ matrix.folder }} = 'hi-ml' ]; then
echo "TESTPYPI_TOKEN=${{ secrets.TEST_PIPY_TOKEN }}" >> $GITHUB_ENV
elif [ ${{ matrix.folder }} = 'hi-ml-azure' ]; then
echo "TESTPYPI_TOKEN=${{ secrets.PYPI_TEST_AZURE_TOKEN }}" >> $GITHUB_ENV
fi
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ env.TESTPYPI_TOKEN }}
packages_dir: ${{ matrix.folder }}/dist/
repository_url: https://test.pypi.org/legacy/
verbose: true
- name: Show published TestPyPI package version
run: |
echo "Install this package version via:"
echo "pip install --extra-""index-url https://test.pypi.org/simple ${{ steps.download.outputs.package_version }}"
publish-pypi-pkg:
runs-on: ubuntu-18.04
needs: [ test-artifact-pkg ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Download package artifacts
id: download
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Set envs
run: |
if [ ${{ matrix.folder }} = 'hi-ml' ]; then
echo "PYPI_TOKEN=${{ secrets.PYPI_TOKEN }}" >> $GITHUB_ENV
elif [ ${{ matrix.folder }} = 'hi-ml-azure' ]; then
echo "PYPI_TOKEN=${{ secrets.PYPI_AZURE_TOKEN }}" >> $GITHUB_ENV
fi
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ env.PYPI_TOKEN }}
packages_dir: ${{ matrix.folder }}/dist/
test-pypi-pkg:
runs-on: ubuntu-18.04
needs: [ publish-pypi-pkg ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: Download package artifacts
id: download
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Install dependencies
if: ${{ matrix.folder != 'hi-ml-azure' }}
run: |
cd hi-ml-azure
# Install local package in editable mode
make pip_local
- name: Install PyPI package and test
run: |
cd ${{ matrix.folder }}
make pip_upgrade
while ! pip install ${{ steps.download.outputs.package_version }}
do
echo waiting for pypi
sleep 10
done
# Test with pytest, fast only
make pytest_fast