-
Notifications
You must be signed in to change notification settings - Fork 1.3k
346 lines (295 loc) · 10.5 KB
/
ux-tests.yml
File metadata and controls
346 lines (295 loc) · 10.5 KB
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
name: Tests
# Two test tiers:
#
# 1. unit-tests — Fast (~30s), no infrastructure. Runs test/unit/ and test/cmd/
# on every push. Catches logic bugs in decorators, CLI, parsers, etc.
#
# 2. ux-tests — Full integration across 4 backends (local, argo, airflow, sfn).
# Needs devstack (minikube + tilt). Catches orchestrator/deployer bugs.
#
# Both tiers auto-discover tests by directory — new test files are picked up
# automatically without editing this workflow.
#
# Coverage is collected from each job, then combined in a final report.
on:
push:
branches:
- master
- "npow/**" # run on this dev branch during development
pull_request:
branches:
- master
workflow_dispatch:
jobs:
unit-tests:
name: "Unit Tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-py3.9-${{ hashFiles('setup.py', 'setup.cfg') }}
restore-keys: pip-py3.9-
- name: Install Metaflow and test dependencies
run: |
pip install --upgrade pip
pip install -e ".[dev]" pytest-timeout pytest-cov
- name: Run unit and command tests
run: |
python -m pytest \
test/unit/ test/cmd/ test/plugins/ \
--ignore=test/unit/spin \
-v \
--tb=short \
--timeout=120 \
--cov=metaflow \
--cov-report=term-missing \
--cov-report=xml:coverage.xml \
--cov-branch \
--junit-xml=junit-unit.xml
- name: Upload coverage data
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-unit
path: |
.coverage
coverage.xml
if-no-files-found: ignore
include-hidden-files: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-unit
path: junit-unit.xml
if-no-files-found: ignore
- name: Publish test results
if: always()
uses: dorny/test-reporter@v1
with:
name: "Test Results — Unit"
path: junit-unit.xml
reporter: java-junit
fail-on-error: false
ux-tests:
name: "${{ matrix.backend }}"
strategy:
fail-fast: false
matrix:
include:
- backend: local
services: "minio,postgresql,metadata-service"
workers: 4
- backend: argo-kubernetes
services: "minio,postgresql,metadata-service,argo-workflows"
workers: 2
- backend: airflow-kubernetes
services: "minio,postgresql,metadata-service,airflow"
workers: 2
- backend: sfn-batch
services: "minio,postgresql,metadata-service,localbatch,ddb-local,sfn-local"
workers: 4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-py3.9-${{ hashFiles('setup.py', 'setup.cfg') }}
restore-keys: pip-py3.9-
- name: Install Metaflow and test dependencies
run: |
pip install --upgrade pip
pip install -e ".[dev]" pytest-xdist pytest-timeout pytest-cov
pip install "git+https://github.com/npow/localbatch.git@main#egg=localbatch"
- name: Set up minikube
uses: medyagh/setup-minikube@latest
with:
driver: docker
cpus: 2
memory: 6144
- name: Restore minikube image cache
id: image-cache
uses: actions/cache/restore@v4
with:
path: /tmp/minikube-image-cache
key: minikube-images-${{ matrix.backend }}-${{ hashFiles('devtools/Tiltfile') }}
restore-keys: minikube-images-${{ matrix.backend }}-
- name: Pre-load cached images into minikube
if: steps.image-cache.outputs.cache-hit == 'true'
run: devtools/ci/load-minikube-images.sh
- name: Cache Helm repos
uses: actions/cache@v4
with:
path: ~/.cache/helm
key: helm-${{ hashFiles('devtools/Tiltfile') }}
restore-keys: helm-
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Install Tilt
run: |
# Pin to the same version as devtools/Makefile to avoid extension API breaks
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh \
| VERSION=v0.33.11 bash
- name: Start devstack
working-directory: devtools
run: ci/start-devstack.sh
env:
SERVICES: ${{ matrix.services }}
- name: Wait for test image to be loaded into minikube
if: matrix.backend != 'local' && matrix.backend != 'sfn-batch'
run: |
tilt wait --for=condition=Ready uiresource/build-test-image --timeout=300s
- name: Save minikube images to cache
if: steps.image-cache.outputs.cache-hit != 'true'
run: devtools/ci/save-minikube-images.sh
- name: Store minikube image cache
if: steps.image-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: /tmp/minikube-image-cache
key: minikube-images-${{ matrix.backend }}-${{ hashFiles('devtools/Tiltfile') }}
- name: Start minikube tunnel
run: |
sudo minikube tunnel &
sleep 5
- name: Forward devstack ports to Docker bridge (sfn-batch only)
if: matrix.backend == 'sfn-batch'
run: devtools/ci/forward-bridge-ports.sh
- name: Wait for Airflow REST API
if: matrix.backend == 'airflow-kubernetes'
run: devtools/ci/wait-airflow-api.sh
- name: Clean up completed pods (argo/airflow only)
if: matrix.backend == 'argo-kubernetes' || matrix.backend == 'airflow-kubernetes'
run: |
kubectl delete pods --field-selector=status.phase=Succeeded --all-namespaces 2>/dev/null || true
kubectl delete pods --field-selector=status.phase=Failed --all-namespaces 2>/dev/null || true
- name: Run UX tests — ${{ matrix.backend }}
run: |
AWS_SHARED_CREDENTIALS_FILE="" \
PYTHONPATH=$PWD \
python -m pytest \
test/ux/core/ \
--only-backend "${{ matrix.backend }}" \
-n ${{ matrix.workers }} \
-v \
--tb=short \
--timeout=1800 \
--cov=metaflow \
--cov-report=term-missing \
--cov-report=xml:coverage.xml \
--cov-report=html:htmlcov \
--cov-branch \
--junit-xml=junit-${{ matrix.backend }}.xml
- name: Upload coverage data
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.backend }}
path: |
.coverage
coverage.xml
htmlcov/
if-no-files-found: ignore
include-hidden-files: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-${{ matrix.backend }}
path: junit-${{ matrix.backend }}.xml
if-no-files-found: ignore
- name: Publish test results
if: always()
uses: dorny/test-reporter@v1
with:
name: "Test Results — ${{ matrix.backend }}"
path: junit-${{ matrix.backend }}.xml
reporter: java-junit
fail-on-error: false
- name: Dump sfn-batch diagnostics on failure
if: failure() && matrix.backend == 'sfn-batch'
run: devtools/ci/dump-sfn-diagnostics.sh
- name: Dump Airflow diagnostics on failure
if: failure() && matrix.backend == 'airflow-kubernetes'
run: devtools/ci/dump-airflow-diagnostics.sh
- name: Show Tilt logs on failure
if: failure()
run: cat /tmp/tilt.log | tail -200 || true
- name: Upload Tilt logs
if: always()
uses: actions/upload-artifact@v4
with:
name: tilt-logs-${{ matrix.backend }}
path: /tmp/tilt.log
if-no-files-found: ignore
coverage-report:
name: "Coverage Report"
needs: [unit-tests, ux-tests]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install coverage
run: pip install coverage[toml]
- name: Download coverage data from all backends
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: coverage-artifacts/
- name: Download test results from all backends
uses: actions/download-artifact@v4
with:
pattern: junit-*
path: junit-artifacts/
- name: Publish combined test results
uses: dorny/test-reporter@v1
with:
name: "Test Results — All Backends"
path: "junit-artifacts/**/*.xml"
reporter: java-junit
fail-on-error: false
- name: Combine coverage data
run: devtools/ci/combine-coverage.sh
- name: Generate combined HTML report
run: |
coverage html -d combined-htmlcov/ --title="Metaflow UX Test Coverage"
coverage xml -o combined-coverage.xml
- name: Post coverage summary
run: |
echo "## Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
coverage report --sort=miss >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
total=$(coverage report | tail -1 | awk '{print $NF}')
echo "**Total coverage: $total**" >> $GITHUB_STEP_SUMMARY
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: combined-coverage.xml
name: ux-combined
- name: Upload combined coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-combined
path: |
combined-htmlcov/
combined-coverage.xml