Repository navigation
438 lines (410 loc) · 17.1 KB
/
Copy pathpy-tests-shared.yml
File metadata and controls
438 lines (410 loc) · 17.1 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
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
# Copyright 2021 Collate
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: py-tests-shared
on:
workflow_call:
inputs:
python-versions:
description: JSON array of Python versions for unit and integration tests
required: true
type: string
static-python:
description: Lowest supported Python version for static checks
required: true
type: string
latest-python:
description: Highest supported Python version for nightly E2E meta tests
required: true
type: string
coverage-python:
description: Selected Python version for combined coverage
required: true
type: string
run-integration:
description: Run both database integration suites
type: boolean
default: false
run-e2e-meta:
description: Run offline E2E framework tests for nightly workloads
type: boolean
default: false
jobs:
py-static-checks:
name: Static Checks
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-openmetadata-test-environment
with:
python-version: ${{ inputs.static-python }}
classification-models: 'true'
install-server: 'false'
- name: Run Static Checks
run: |
set -o pipefail
source env/bin/activate
cd ingestion
nox --no-venv -s static-checks 2>&1 | tee static-checks-run.log
shell: bash
- name: Upload static check log
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: py-static-checks
path: ingestion/static-checks-run.log
if-no-files-found: warn
retention-days: 14
py-unit-tests:
name: Unit Tests
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: Setup Openmetadata Test Environment
uses: ./.github/actions/setup-openmetadata-test-environment
with:
python-version: ${{ matrix.py-version }}
classification-models: 'true'
install-server: 'false'
- name: Run offline E2E framework tests
if: ${{ matrix.py-version == inputs.latest-python && inputs.run-e2e-meta && hashFiles('ingestion/tests/cli_e2e_v2/meta/**') != '' }}
run: |
source env/bin/activate
cd ingestion
env -u OM_JWT_TOKEN OM_SERVER_URL=http://127.0.0.1:1/api \
python -m pytest tests/cli_e2e_v2/meta -q
shell: bash
- name: Run Unit Tests
id: unit-tests
run: |
set -o pipefail
source env/bin/activate
cd ingestion
set +e
nox --no-venv -s unit-tests 2>&1 | tee unit-test-run.log
test_exit_code=${PIPESTATUS[0]}
echo "$test_exit_code" > unit-test-exit-code.txt
exit "$test_exit_code"
shell: bash
- name: Classify Python unit test outcome
if: ${{ always() }}
env:
TEST_LANE: python-${{ matrix.py-version }}
TEST_PROFILE: python-unit
TEST_STEP_OUTCOME: ${{ steps.unit-tests.outcome }}
run: |
test_exit_code=""
if [[ -s ingestion/unit-test-exit-code.txt ]]; then
read -r test_exit_code < ingestion/unit-test-exit-code.txt
fi
python3 .github/scripts/classify_test_outcome.py \
--step-outcome "$TEST_STEP_OUTCOME" \
--exit-code "$test_exit_code" \
--report-glob 'ingestion/junit/test-results-*.xml' \
--diagnostic-glob 'ingestion/*-test-run.log' \
--output ingestion/ci-diagnostics/outcome.json
- name: Upload test results
if: ${{ always() }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: py-unit-test-results-${{ matrix.py-version }}
path: |
ingestion/junit/
ingestion/ci-diagnostics/outcome.json
ingestion/*-test-run.log
ingestion/unit-test-exit-code.txt
if-no-files-found: warn
retention-days: 14
compression-level: 1
- name: Upload coverage artifact
if: ${{ matrix.py-version == inputs.coverage-python && !cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-unit
path: ingestion/.coverage
include-hidden-files: true
py-integration-tests:
name: "Integration Tests (${{ matrix.database.name }}, ${{ matrix.shard.name }}, ${{ matrix.py-version }})"
if: ${{ inputs.run-integration }}
timeout-minutes: 180
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py-version: ${{ fromJSON(inputs.python-versions) }}
database:
- name: mysql
compose-args: "-m no-ui -s true -i false"
test-profile: python-integration
- name: postgres
compose-args: "-m no-ui -d postgresql -s true -i false"
test-profile: python-postgresql-integration
# shard-3 is the catch-all and is deliberately the lightest, so new directories land
# in slack rather than on the critical path. Moving one OUT of shard-1 or shard-2
# means removing its --ignore too, or it runs nowhere.
shard:
- name: "shard-1"
nox-args: >-
tests/integration/automations
tests/integration/data_quality
tests/integration/mysql
tests/integration/postgres
tests/integration/powerbi
tests/integration/sas
tests/integration/superset
- name: "shard-2"
needs-disk: true
nox-args: >-
tests/integration/alationsink
tests/integration/auto_classification
tests/integration/datalake
tests/integration/profiler
tests/integration/sources
tests/integration/sql_server
tests/integration/ssrs
- name: "shard-3"
nox-args: >-
--ignore=tests/integration/automations
--ignore=tests/integration/data_quality
--ignore=tests/integration/mysql
--ignore=tests/integration/postgres
--ignore=tests/integration/powerbi
--ignore=tests/integration/sas
--ignore=tests/integration/superset
--ignore=tests/integration/alationsink
--ignore=tests/integration/auto_classification
--ignore=tests/integration/datalake
--ignore=tests/integration/profiler
--ignore=tests/integration/sources
--ignore=tests/integration/sql_server
--ignore=tests/integration/ssrs
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@ceedf095f4ec1a097402bc6bd80831f2e1a6fde6
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: true
docker-images: false
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: Use runner data disk for Docker
if: matrix.shard.needs-disk
run: bash .github/scripts/configure_docker_storage.sh
# Must precede the setup action, which builds the server image from this tarball.
- name: Download backend distribution
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: openmetadata-backend-distribution
path: openmetadata-dist/target
- name: Setup Openmetadata Test Environment
uses: ./.github/actions/setup-openmetadata-test-environment
with:
python-version: ${{ matrix.py-version}}
classification-models: 'true'
args: ${{ matrix.database.compose-args }}
- name: Reclaim unused disk for the Exasol shard
if: matrix.shard.needs-disk
continue-on-error: true
run: |
{
echo "Before Exasol shard disk reclaim"
df -h
docker system df
sudo rm -rf /opt/hostedtoolcache/CodeQL
docker image prune --all --force || true
docker builder prune --all --force || true
echo "After Exasol shard disk reclaim"
df -h
docker system df
} 2>&1 | tee "${RUNNER_TEMP}/exasol-disk-reclaim.log"
shell: bash
- name: Run Integration Tests
id: integration-tests
run: |
set -o pipefail
source env/bin/activate
cd ingestion
read -r -a shard_args <<< "$NOX_ARGS"
nox --no-venv -s integration-tests -- --standalone --durations=5 "${shard_args[@]}" 2>&1 | tee integration-test-run.log
env:
NOX_ARGS: ${{ matrix.shard.nox-args }}
TESTCONTAINERS_RYUK_DISABLED: true
shell: bash
- name: Classify Python integration test outcome
if: ${{ always() }}
env:
TEST_LANE: ${{ matrix.database.name }}-${{ matrix.shard.name }}-python-${{ matrix.py-version }}
TEST_PROFILE: ${{ matrix.database.test-profile }}
TEST_STEP_OUTCOME: ${{ steps.integration-tests.outcome }}
run: |
python3 .github/scripts/classify_test_outcome.py \
--step-outcome "$TEST_STEP_OUTCOME" \
--report-glob 'ingestion/junit/test-results-*.xml' \
--diagnostic-glob 'ingestion/integration-test-run.log' \
--output ingestion/ci-diagnostics/outcome.json
- name: Upload coverage artifact
if: ${{ matrix.database.name == 'mysql' && matrix.py-version == inputs.coverage-python && !cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-integration-${{ matrix.shard.name }}
path: ingestion/.coverage
include-hidden-files: true
- name: Upload test results
if: ${{ always() }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: py-${{ matrix.database.name }}-integration-test-results-${{ matrix.shard.name }}-${{ matrix.py-version }}
path: |
ingestion/junit/
ingestion/ci-diagnostics/outcome.json
ingestion/integration-test-run.log
if-no-files-found: warn
retention-days: 14
compression-level: 1
- name: Collect runner and service diagnostics
if: ${{ failure() || cancelled() }}
continue-on-error: true
run: |
diagnostics="${RUNNER_TEMP}/python-ci-diagnostics"
rm -rf "$diagnostics"
mkdir -p "$diagnostics"
df -h > "$diagnostics/disk-usage.txt" 2>&1 || true
free -h > "$diagnostics/memory-usage.txt" 2>&1 || true
docker info > "$diagnostics/docker-info.txt" 2>&1 || true
docker system df > "$diagnostics/docker-disk-usage.txt" 2>&1 || true
docker ps --all --no-trunc > "$diagnostics/docker-containers.txt" 2>&1 || true
if [ -d docker/development ]; then
(cd docker/development && docker compose ps --all) > "$diagnostics/docker-compose-ps.txt" 2>&1 || true
(cd docker/development && docker compose logs --no-color --tail 2000) > "$diagnostics/docker-compose.log" 2>&1 || true
fi
coredumpctl --no-pager list > "$diagnostics/coredumps.txt" 2>&1 || true
coredumpctl --no-pager info >> "$diagnostics/coredumps.txt" 2>&1 || true
find "$GITHUB_WORKSPACE" /tmp /var/crash -maxdepth 3 -type f \
\( -name 'core' -o -name 'core.*' -o -name '*.core' -o -name '*.dmp' -o -name '*.crash' \) \
-printf '%p %s bytes\n' >> "$diagnostics/core-files.txt" 2>/dev/null || true
if [ -f "${RUNNER_TEMP}/exasol-disk-reclaim.log" ]; then
cp "${RUNNER_TEMP}/exasol-disk-reclaim.log" "$diagnostics/"
fi
shell: bash
- name: Upload runner and service diagnostics
if: ${{ failure() || cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: py-${{ matrix.database.name }}-integration-diagnostics-${{ matrix.shard.name }}-${{ matrix.py-version }}
path: ${{ runner.temp }}/python-ci-diagnostics/
if-no-files-found: warn
retention-days: 14
compression-level: 1
- name: Clean Up
if: ${{ always() }}
continue-on-error: true
run: |
cd ./docker/development
docker compose down --remove-orphans || true
sudo rm -rf "${PWD}/docker-volume"
verify:
name: Verify Expected Jobs
needs: [py-unit-tests, py-static-checks, py-integration-tests]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Verify all expected Python jobs completed
env:
RUN_INTEGRATION: ${{ inputs.run-integration }}
UNIT_RESULT: ${{ needs.py-unit-tests.result }}
STATIC_RESULT: ${{ needs.py-static-checks.result }}
INTEGRATION_RESULT: ${{ needs.py-integration-tests.result }}
run: |
expected_integration="skipped"
if [ "$RUN_INTEGRATION" = "true" ]; then
expected_integration="success"
fi
if [ "$INTEGRATION_RESULT" != "$expected_integration" ] \
|| [ "$UNIT_RESULT" != "success" ] || [ "$STATIC_RESULT" != "success" ]; then
echo "Expected Python jobs did not succeed: integration=$INTEGRATION_RESULT unit=$UNIT_RESULT static=$STATIC_RESULT"
exit 1
fi
shell: bash
py-combine-coverage:
needs: [py-unit-tests, py-integration-tests]
if: ${{ always() && needs.py-unit-tests.result == 'success' && contains(fromJSON('["success", "skipped"]'), needs.py-integration-tests.result) }}
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha || github.sha }}
fetch-depth: 1
filter: blob:none
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ inputs.coverage-python }}
- name: Install uv
run: pip install uv
shell: bash
- name: Install coverage
run: |
python3 -m venv env
source env/bin/activate
uv pip install "coverage[toml]" nox
shell: bash
- name: Download coverage artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: coverage-*
path: ingestion/coverage-data/
- name: Prepare coverage files
run: |
cd ingestion
shopt -s nullglob
# download-artifact extracts a lone match (unit-only PR runs) straight into path, not path/<name>/
for f in coverage-data/coverage-unit/.coverage coverage-data/.coverage; do
[ -f "$f" ] && mv "$f" .coverage.unit
done
for dir in coverage-data/coverage-integration-*/; do
shard=$(basename "$dir" | sed 's/coverage-integration-//')
[ -f "$dir/.coverage" ] && mv "$dir/.coverage" ".coverage.integration-$shard"
done
shell: bash
- name: Combine coverage
run: |
source env/bin/activate
cd ingestion
nox --no-venv -s combine-coverage
shell: bash