-
Notifications
You must be signed in to change notification settings - Fork 7
433 lines (370 loc) Β· 15.4 KB
/
pyatlan-pr.yaml
File metadata and controls
433 lines (370 loc) Β· 15.4 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
name: Pyatlan Pull Request Build
# This workflow runs both sync and async integration tests intelligently:
# - Legacy sync integration tests: Always run on every PR with code changes
# - Legacy async integration tests: Only run when AIO changes detected or "run-async-tests" label
# - V9 unit tests: Always run on every PR with code changes
# - V9 integration tests (sync + async): Only run when PR has the "run_pyatlan_v9_integration_tests" label
on:
pull_request:
workflow_dispatch:
jobs:
check-code-changes:
runs-on: ubuntu-latest
outputs:
has-code-changes: ${{ steps.filter.outputs.has-code-changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect code changes
id: filter
run: |
# For workflow_dispatch, always run everything
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "has-code-changes=true" >> $GITHUB_OUTPUT
echo "Manual trigger: running all tests"
exit 0
fi
# Get changed files
CHANGED=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
# Check if any changed file is actual code (not just CI/docs/config)
CODE_CHANGES=$(echo "$CHANGED" | grep -vE '^\.(github|claude|cursor)/|^docs/|^site/|^README|^HISTORY|^LICENSE|^NOTICE|^CODE_OF_CONDUCT|^CONTRIBUTING|^CLAUDE\.md|^\.gitignore|^\.pre-commit|^\.editorconfig|^mkdocs' || true)
if [ -n "$CODE_CHANGES" ]; then
echo "has-code-changes=true" >> $GITHUB_OUTPUT
echo "Code changes detected:"
echo "$CODE_CHANGES" | head -20
else
echo "has-code-changes=false" >> $GITHUB_OUTPUT
echo "No code changes detected, only CI/docs/config files:"
echo "$CHANGED"
fi
vulnerability-scan:
needs: [check-code-changes]
if: needs.check-code-changes.outputs.has-code-changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
# Specify version as a string
# https://github.com/actions/setup-python/issues/160"
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- uses: pypa/gh-action-pip-audit@v1.1.0
with:
# Since we used pytest for dev
# ("py" -> library is in maintenance mode)
# We can ignore this vulnerability here
# Reference: https://github.com/pytest-dev/py
ignore-vulns: |
PYSEC-2022-42969
GHSA-48p4-8xcf-vxj5
GHSA-pq67-6m6q-mj2v
summary: true
vulnerability-service: osv
inputs: .
check-aio-changes:
runs-on: ubuntu-latest
outputs:
run-async-tests: ${{ steps.check-conditions.outputs.run-async-tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for AIO changes or manual trigger
id: check-conditions
run: |
# Check if PR has the run-async-tests label
if echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q "run-async-tests"; then
echo "run-async-tests=true" >> $GITHUB_OUTPUT
echo "π·οΈ Manual trigger: Found 'run-async-tests' label"
exit 0
fi
# Check for changes in AIO-related paths
if git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -E "(pyatlan/.*aio/|tests/.*aio/)"; then
echo "run-async-tests=true" >> $GITHUB_OUTPUT
echo "π Change detection: Found AIO-related changes:"
aio_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -E "(pyatlan/.*aio/|tests/.*aio/)")
echo "$aio_files" | head -20
total_count=$(echo "$aio_files" | wc -l)
echo "π Total AIO files changed: $total_count"
else
echo "run-async-tests=false" >> $GITHUB_OUTPUT
echo "βοΈ No AIO changes detected and no manual trigger label found"
fi
check-v9-integration-label:
runs-on: ubuntu-latest
outputs:
run-v9-integration: ${{ steps.check-label.outputs.run-v9-integration }}
steps:
- name: Check for v9 integration test label
id: check-label
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "run-v9-integration=true" >> $GITHUB_OUTPUT
echo "Manual trigger: running v9 integration tests"
exit 0
fi
if echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q "run_pyatlan_v9_integration_tests"; then
echo "run-v9-integration=true" >> $GITHUB_OUTPUT
echo "Found 'run_pyatlan_v9_integration_tests' label"
else
echo "run-v9-integration=false" >> $GITHUB_OUTPUT
echo "No 'run_pyatlan_v9_integration_tests' label found, skipping v9 integration tests"
fi
qa-checks-and-unit-tests:
needs: [check-code-changes, vulnerability-scan]
if: needs.check-code-changes.outputs.has-code-changes == 'true'
runs-on: ubuntu-latest
outputs:
files: ${{ steps.distribute-integration-test-files.outputs.files }}
aio-files: ${{ steps.distribute-aio-test-files.outputs.aio-files }}
strategy:
matrix:
# Specify version as a string
# https://github.com/actions/setup-python/issues/160"
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: QA checks (ruff-format, ruff-lint, mypy)
run: uv run ./qa-checks
- name: Run unit tests
env: # Test tenant environment variables
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
# Run with `pytest-sugar` for enhancing the overall test report output
run: uv run pytest tests/unit --force-sugar -vv
- name: Prepare integration tests distribution
id: distribute-integration-test-files
run: |
test_ignore_file=tests/integration/.testignore.txt
files=$(ls tests/integration/test_*.py tests/integration/*_test.py | grep -v -f $test_ignore_file | tr '\n' ' ')
json_files=$(echo "${files[@]}" | jq -R -c 'split(" ")[:-1]')
echo "files=$json_files" >> $GITHUB_OUTPUT
- name: Prepare async integration tests distribution
id: distribute-aio-test-files
run: |
# Check if AIO test directory exists and has test files
if [ -d "tests/integration/aio" ]; then
aio_files=$(find tests/integration/aio -name "test_*.py" -o -name "*_test.py" | tr '\n' ' ')
if [ -n "$aio_files" ]; then
json_aio_files=$(echo "${aio_files[@]}" | jq -R -c 'split(" ")[:-1]')
echo "aio-files=$json_aio_files" >> $GITHUB_OUTPUT
else
echo "aio-files=[]" >> $GITHUB_OUTPUT
fi
else
echo "aio-files=[]" >> $GITHUB_OUTPUT
fi
integration-tests:
needs: [check-code-changes, vulnerability-scan, qa-checks-and-unit-tests]
if: needs.check-code-changes.outputs.has-code-changes == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_file: ${{fromJson(needs.qa-checks-and-unit-tests.outputs.files)}}
concurrency:
group: ${{ matrix.test_file }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
# Specify version as a string
# https://github.com/actions/setup-python/issues/160"
python-version: "3.9"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: Run integration tests
env: # Test tenant environment variables
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 10 # Maximum time per test job; otherwise, the job will fail
# Run the integration test file using `pytest-timer` plugin
# to display only the durations of the 10 slowest tests with `pytest-sugar`
command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv
async-integration-tests:
needs: [check-code-changes, vulnerability-scan, qa-checks-and-unit-tests, check-aio-changes]
runs-on: ubuntu-latest
# Only run if code changed AND (AIO changes detected or manual trigger)
if: needs.check-code-changes.outputs.has-code-changes == 'true' && needs.check-aio-changes.outputs.run-async-tests == 'true'
strategy:
fail-fast: false
matrix:
test_file: ${{fromJson(needs.qa-checks-and-unit-tests.outputs.aio-files)}}
concurrency:
group: async-${{ matrix.test_file }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
# Specify version as a string
# https://github.com/actions/setup-python/issues/160"
python-version: "3.9"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: Run async integration tests
env: # Test tenant environment variables
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 15 # Async tests may take longer, increased timeout
# Run the async integration test file using `pytest-timer` plugin
# to display only the durations of the 10 slowest tests with `pytest-sugar`
command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv
# =========================================================================
# V9 (msgspec) Jobs
# =========================================================================
v9-qa-checks-and-unit-tests:
needs: [check-code-changes, vulnerability-scan]
if: needs.check-code-changes.outputs.has-code-changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: QA checks (ruff-format, ruff-lint, mypy)
run: uv run ./qa-checks
- name: Run v9 unit tests
env:
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
run: uv run pytest tests_v9/unit --force-sugar -vv
v9-prepare-integration-tests:
needs: [check-code-changes, vulnerability-scan, check-v9-integration-label]
if: >-
needs.check-code-changes.outputs.has-code-changes == 'true' &&
needs.check-v9-integration-label.outputs.run-v9-integration == 'true'
runs-on: ubuntu-latest
outputs:
v9-files: ${{ steps.distribute-v9-files.outputs.v9-files }}
v9-aio-files: ${{ steps.distribute-v9-aio-files.outputs.v9-aio-files }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare v9 sync integration tests distribution
id: distribute-v9-files
run: |
files=$(find tests_v9/integration -maxdepth 1 \( -name "test_*.py" -o -name "*_test.py" \) | sort | tr '\n' ' ')
if [ -n "$files" ]; then
json_files=$(echo "${files[@]}" | jq -R -c 'split(" ")[:-1]')
else
json_files="[]"
fi
echo "v9-files=$json_files" >> $GITHUB_OUTPUT
echo "V9 sync integration test files: $json_files"
- name: Prepare v9 async integration tests distribution
id: distribute-v9-aio-files
run: |
if [ -d "tests_v9/integration/aio" ]; then
aio_files=$(find tests_v9/integration/aio -name "test_*.py" | sort | tr '\n' ' ')
if [ -n "$aio_files" ]; then
json_aio_files=$(echo "${aio_files[@]}" | jq -R -c 'split(" ")[:-1]')
else
json_aio_files="[]"
fi
else
json_aio_files="[]"
fi
echo "v9-aio-files=$json_aio_files" >> $GITHUB_OUTPUT
echo "V9 async integration test files: $json_aio_files"
v9-integration-tests:
needs: [v9-prepare-integration-tests]
if: needs.v9-prepare-integration-tests.outputs.v9-files != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_file: ${{fromJson(needs.v9-prepare-integration-tests.outputs.v9-files)}}
concurrency:
group: v9-${{ matrix.test_file }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: Run v9 integration test
env:
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 10
command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv
v9-async-integration-tests:
needs: [v9-prepare-integration-tests]
if: needs.v9-prepare-integration-tests.outputs.v9-aio-files != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_file: ${{fromJson(needs.v9-prepare-integration-tests.outputs.v9-aio-files)}}
concurrency:
group: v9-async-${{ matrix.test_file }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --group dev
- name: Run v9 async integration test
env:
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 15
command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv