Repository navigation
314 lines (287 loc) · 14.2 KB
/
Copy pathpy-tests.yml
File metadata and controls
314 lines (287 loc) · 14.2 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
# 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
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
merge_group:
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
mode:
description: Workload to run manually
type: choice
options: [pull-request, merge-queue, nightly]
default: nightly
connectors:
description: CLI E2E connectors as a JSON array (nightly mode)
type: string
default: '["bigquery", "dbt_redshift", "metabase", "mssql", "mysql", "redash", "snowflake", "tableau", "redshift", "quicksight", "datalake_s3", "postgres", "oracle", "athena", "bigquery_multiple_project", "exasol", "powerbi"]'
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.mode || 'auto' }}
cancel-in-progress: true
jobs:
# Detect whether relevant paths changed before the matrix fans out.
changes:
name: Detect Changes
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
outputs:
python: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && 'true' || steps.filter.outputs.python }}
integration: ${{ steps.matrix.outputs.run-integration }}
versions: ${{ steps.matrix.outputs.versions }}
static-version: ${{ steps.matrix.outputs.static-version }}
coverage-version: ${{ steps.matrix.outputs.coverage-version }}
latest-version: ${{ steps.matrix.outputs.latest-version }}
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: ${{ github.event_name == 'merge_group' && '0' || '1' }}
filter: blob:none
persist-credentials: false
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4
id: filter
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
with:
base: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || '' }}
filters: |
python:
- 'ingestion/**'
- 'scripts/prepare_classification_models.py'
- '.github/actions/prepare-classification-models/**'
- '.github/actions/prepare-classification-model/**'
- '.github/workflows/warm-classification-models.yml'
- '.github/workflows/py-tests.yml'
- '.github/workflows/py-tests-shared.yml'
- '.github/workflows/py-cli-e2e-tests-v2.yml'
- '.github/workflows/py-cli-e2e-tests.yml'
- '.github/scripts/prepare_python_coverage.py'
- '.github/actions/setup-openmetadata-test-environment/action.yml'
- 'openmetadata-spec/**'
- 'openmetadata-service/src/main/java/org/openmetadata/service/resources/**'
- 'openmetadata-service/src/main/java/org/openmetadata/service/JsonPatchMessageBodyReader.java'
- 'openmetadata-service/src/main/java/org/openmetadata/service/JsonPatchProvider.java'
- 'openmetadata-service/src/main/java/org/openmetadata/service/ResourceRegistry.java'
- id: matrix
env:
CI_EVENT: ${{ github.event_name }}
TEST_MODE: ${{ inputs.mode }}
run: |
if [ "$CI_EVENT" = "workflow_dispatch" ]; then
case "$TEST_MODE" in
pull-request) CI_EVENT="pull_request" ;;
merge-queue) CI_EVENT="merge_group" ;;
nightly) CI_EVENT="schedule" ;;
*) echo "Invalid test mode: $TEST_MODE"; exit 1 ;;
esac
fi
python3 scripts/prepare_classification_models.py test-matrix --project ingestion --event "$CI_EVENT" \
| jq -r 'to_entries[] | "\(.key)=\(.value | if type == "array" or type == "boolean" then tojson else . end)"' >> "$GITHUB_OUTPUT"
prepare-spacy-model:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
runs-on: ubuntu-24.04
cache-mode: read
timeout-minutes: 15
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/prepare-classification-models
# Produces the one artifact docker/development/Dockerfile needs, so shards can skip Maven.
build-distribution:
name: Build Backend Distribution
needs: changes
if: ${{ needs.changes.outputs.python == 'true' && needs.changes.outputs.integration == 'true' }}
timeout-minutes: 45
runs-on: ubuntu-latest
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 JDK 21
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
java-version: '21'
distribution: 'temurin'
# Restore-only: pull_request / merge_group writes are scoped to refs no
# other run can read, so saving would only consume the repo's cache quota.
- name: Restore Maven dependencies
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# -am builds only openmetadata-dist's dependency closure, and -DonlyBackend is what
# drops openmetadata-ui from it. Removing either pulls the whole frontend build back
# in, which also needs the antlr4 CLI that this job deliberately does not install.
- name: Build backend distribution
run: mvn -DskipTests -DonlyBackend clean package -pl openmetadata-dist -am
shell: bash
- name: Upload backend distribution
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: openmetadata-backend-distribution
path: openmetadata-dist/target/openmetadata-*.tar.gz
if-no-files-found: error
compression-level: 0
retention-days: 1
python:
needs: [changes, prepare-spacy-model, build-distribution]
if: ${{ !cancelled() && needs.changes.result == 'success' && needs.prepare-spacy-model.result == 'success' && (needs.build-distribution.result == 'success' || (needs.changes.outputs.integration == 'false' && needs.build-distribution.result == 'skipped')) }}
uses: ./.github/workflows/py-tests-shared.yml
with:
python-versions: ${{ needs.changes.outputs.versions }}
static-python: ${{ needs.changes.outputs.static-version }}
latest-python: ${{ needs.changes.outputs.latest-version }}
coverage-python: ${{ needs.changes.outputs.coverage-version }}
run-integration: ${{ needs.changes.outputs.integration == 'true' }}
run-e2e-meta: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'nightly') }}
cli-e2e:
needs: [changes, prepare-spacy-model, build-distribution]
if: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'nightly')) }}
permissions:
contents: read
id-token: write
uses: ./.github/workflows/py-cli-e2e-tests.yml
secrets: inherit
with:
python-version: ${{ needs.changes.outputs.latest-version }}
connectors: ${{ inputs.connectors || '["bigquery", "dbt_redshift", "metabase", "mssql", "mysql", "redash", "snowflake", "tableau", "redshift", "quicksight", "datalake_s3", "postgres", "oracle", "athena", "bigquery_multiple_project", "exasol", "powerbi"]' }}
py-tests-status:
name: py-tests-status
needs: [changes, prepare-spacy-model, build-distribution, python, cli-e2e]
if: ${{ always() && !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- name: Verify the selected Python pipeline succeeded
env:
CHANGES_RESULT: ${{ needs.changes.result }}
PYTHON_CHANGED: ${{ needs.changes.outputs.python }}
MODELS_RESULT: ${{ needs.prepare-spacy-model.result }}
BUILD_RESULT: ${{ needs.build-distribution.result }}
RUN_INTEGRATION: ${{ needs.changes.outputs.integration }}
CLI_RESULT: ${{ needs.cli-e2e.result }}
RUN_CLI: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'nightly')) }}
PIPELINE_RESULT: ${{ needs.python.result }}
run: |
if [ "$CHANGES_RESULT" != "success" ]; then
echo "Python selection failed: $CHANGES_RESULT"
exit 1
fi
case "$PYTHON_CHANGED" in
true) expected="success" ;;
false) expected="skipped" ;;
*) echo "Invalid Python change result: $PYTHON_CHANGED"; exit 1 ;;
esac
expected_build="skipped"
if [ "$PYTHON_CHANGED" = "true" ] && [ "$RUN_INTEGRATION" = "true" ]; then
expected_build="success"
fi
expected_cli="skipped"
if [ "$RUN_CLI" = "true" ]; then
expected_cli="success"
fi
if [ "$BUILD_RESULT" != "$expected_build" ] || [ "$CLI_RESULT" != "$expected_cli" ]; then
echo "Unexpected Python results: build=$BUILD_RESULT (expected $expected_build) cli=$CLI_RESULT (expected $expected_cli)"
exit 1
fi
if [ "$MODELS_RESULT" != "$expected" ] || [ "$PIPELINE_RESULT" != "$expected" ]; then
echo "Expected $expected: models=$MODELS_RESULT pipeline=$PIPELINE_RESULT"
exit 1
fi
shell: bash
notify:
needs: [changes, prepare-spacy-model, build-distribution, python, cli-e2e, py-tests-status, sonar-cloud-coverage-upload]
if: ${{ always() && !cancelled() && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'nightly')) && (needs.py-tests-status.result == 'failure' || needs.sonar-cloud-coverage-upload.result == 'failure') }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Slack on nightly failure
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: chat.postMessage
token: ${{ secrets.COLLATE_BOT_SLACK_TOKEN }}
errors: true
payload: |
{
"channel": "C03EYBDDX17",
"text": "<!subteam^S0AH093PEQL> 🔥 *Python Tests Nightly* failed on `${{ github.ref_name }}` 🔥\nselection: ${{ needs.changes.result }} · models: ${{ needs.prepare-spacy-model.result }} · build: ${{ needs.build-distribution.result }} · tests: ${{ needs.python.result }} · CLI E2E: ${{ needs.cli-e2e.result }} · Sonar: ${{ needs.sonar-cloud-coverage-upload.result }}\nLogs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
sonar-cloud-coverage-upload:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [changes, python, cli-e2e]
if: ${{ !cancelled() && github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'nightly')) && contains(fromJSON('["success", "failure"]'), needs.python.result) }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ needs.changes.outputs.latest-version }}
- name: Install coverage dependencies
run: |
python3 -m venv env
env/bin/python -m pip install "coverage[toml]"
- name: Download coverage artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: '*coverage-*'
path: artifacts
- name: Download CLI test results
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: tests-*
path: test-artifacts
- name: Download unit and integration test results
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: py-*-test-results-*
path: test-artifacts
- name: Generate report
run: env/bin/python .github/scripts/prepare_python_coverage.py
shell: bash
- name: Push Results to Sonar
id: push-to-sonar
continue-on-error: true
uses: SonarSource/sonarqube-scan-action@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.INGESTION_SONAR_SECRET }}
with:
projectBaseDir: ingestion/
- name: Wait to retry Sonar upload
if: ${{ !cancelled() && steps.push-to-sonar.outcome == 'failure' }}
run: sleep 20s
shell: bash
- name: Retry Sonar upload
if: ${{ !cancelled() && steps.push-to-sonar.outcome == 'failure' }}
uses: SonarSource/sonarqube-scan-action@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.INGESTION_SONAR_SECRET }}
with:
projectBaseDir: ingestion/