-
Notifications
You must be signed in to change notification settings - Fork 58
454 lines (377 loc) · 12.3 KB
/
hi-ml-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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
name: HI-ML HI-ML-Azure PR
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
paths:
- "hi-ml-azure/**"
- "hi-ml/**"
- ".github/workflows/hi-ml-pr.yml"
# Cancel previous runs of this workflow that are still in progress.
concurrency:
group: ${{ github.ref }}/hi-ml-pr
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
permissions:
# This is required for requesting the Azure login token
id-token: write
# This is required for actions/checkout
contents: read
env:
pythonVersion: 3.9
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_DIST_ARTIFACT_SUFFIX: '-dist'
HIML_PACKAGE_NAME_ARTIFACT_SUFFIX: '-package_name'
HIML_VERSION_ARTIFACT_SUFFIX: '-latest_version'
# Set the AML experiment name for all AML jobs submitted during tests. Github.ref looks like
# "refs/pull/123/merge" for PR builds.
HIML_EXPERIMENT_NAME: ${{ github.ref }}
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
PYPI_TEST_API_TOKEN: ${{ secrets.PYPI_TEST_API_TOKEN }}
jobs:
cancel-azureml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Cancel previous AzureML runs
uses: ./.github/actions/cancel_azureml_jobs
himl-flake8:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.pythonVersion }}
- name: flake8
run: |
make pip_test
make flake8
himl-mypy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.pythonVersion }}
- name: mypy
run: |
make pip_test
make mypy
# himl-pyright:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v3
# with:
# lfs: true
# - uses: actions/setup-node@v3
# with:
# node-version: '14'
# - uses: conda-incubator/setup-miniconda@v2
# - name: pyright
# shell: bash -l {0}
# run: |
# conda info
# make pyright
himl-pytest-fast:
runs-on: ubuntu-20.04
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
# 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@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
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: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Test with pytest, fast only
run: |
cd ${{ matrix.folder }}
make pip_test
# Install local package in editable mode
make pip_local
# Run fast tests
make pytest_fast
himl-build-python:
runs-on: ubuntu-20.04
needs: [ himl-pytest-fast ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
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 }}
himl-test-artifact-pkg:
runs-on: ubuntu-20.04
needs: [ himl-build-python, cancel-azureml ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
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
- 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
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Install artifact and test
run: |
cd ${{ matrix.folder }}
make pip_upgrade
# Install package
pip install ${{ steps.download.outputs.package_filename }}
# Set env vars so wheel is sent to azureml as a private package
# This had to be deprecated because the upload always uses SAS tokens encrypted with the now disabled storage account key
# echo "HIML_AZURE_WHEEL_FILENAME=${{ steps.download.outputs.package_filename }}" >> $GITHUB_ENV
# Test with pytest
make pytest_and_coverage
- name: Upload coverage report to Codecov
# Coverage should also be uploaded if tests still fail
if: always()
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.folder }}
himl_smoke_helloworld_v1:
runs-on: ubuntu-20.04
needs: [ cancel-azureml ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: ./.github/actions/prepare_himl_python_env
with:
python-version: ${{ env.pythonVersion }}
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Run smoke_helloworld_v1
run: |
cd hi-ml
make smoke_helloworld_v1
himl_smoke_helloworld_v2:
runs-on: ubuntu-20.04
needs: [ cancel-azureml ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: ./.github/actions/prepare_himl_python_env
with:
python-version: ${{ env.pythonVersion }}
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Run smoke_helloworld_v2
run: |
cd hi-ml
make smoke_helloworld_v2
himl_smoke_helloworld_v1_2nodes:
runs-on: ubuntu-20.04
needs: [ cancel-azureml ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: ./.github/actions/prepare_himl_python_env
with:
python-version: ${{ env.pythonVersion }}
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Run smoke_helloworld_v1_2nodes
run: |
cd hi-ml
make smoke_helloworld_v1_2nodes
himl_smoke_helloworld_v2_2nodes:
runs-on: ubuntu-20.04
needs: [ cancel-azureml ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: ./.github/actions/prepare_himl_python_env
with:
python-version: ${{ env.pythonVersion }}
- name: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Run smoke_helloworld_v2_2nodes
run: |
cd hi-ml
make smoke_helloworld_v2_2nodes
himl-smoke-tests-completed:
# This job is just a placeholder to ensure that all smoke tests have completed before
# publishing the package. Reference this job rather than the individual smoke tests.
runs-on: ubuntu-20.04
needs: [
himl_smoke_helloworld_v1,
himl_smoke_helloworld_v2,
himl_smoke_helloworld_v1_2nodes,
himl_smoke_helloworld_v2_2nodes,
]
steps:
- name: Smoke tests completed
run: |
echo "All hi-ml smoke tests have passed"
himl-publish-testpypi-pkg:
runs-on: ubuntu-20.04
needs: [ himl-test-artifact-pkg, himl-mypy, himl-flake8, himl-smoke-tests-completed ]
if: "!startsWith(github.ref, 'refs/tags/v')"
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Download package artifacts
id: download
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ env.PYPI_TEST_API_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 }}"
himl-publish-pypi-pkg:
runs-on: ubuntu-20.04
needs: [ himl-test-artifact-pkg, himl-mypy, himl-flake8, himl-smoke-tests-completed ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Download package artifacts
id: download
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ env.PYPI_API_TOKEN }}
packages_dir: ${{ matrix.folder }}/dist/
himl-test-pypi-pkg:
runs-on: ubuntu-20.04
needs: [ himl-publish-pypi-pkg ]
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v4
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: Azure login using OpenID Connect
uses: ./.github/actions/azure-login
- name: Install PyPI package and test
run: |
cd ${{ matrix.folder }}
make pip_upgrade
make pip_test
while ! pip install ${{ steps.download.outputs.package_version }}
do
echo waiting for pypi
sleep 10
done
# Test with pytest, fast only
make pytest_fast
hi-ml-pr-completed:
runs-on: ubuntu-20.04
if: "!startsWith(github.ref, 'refs/tags/v')"
needs: [ himl-publish-testpypi-pkg ]
steps:
- name: Final PR Job
run: |
echo "All hi-ml PR jobs have passed"