11name : Pyatlan Pull Request Build
22
3+ # This workflow runs both sync and async integration tests intelligently:
4+ # - Sync integration tests: Always run on every PR
5+ # - Async integration tests: Only run when:
6+ # 1. Changes detected in pyatlan/*/aio/ or tests/*/aio/ paths
7+ # 2. PR has the "run-async-tests" label (manual trigger)
8+ # This prevents adding 12+ minutes to every PR while ensuring async tests run when needed.
9+
310on :
411 pull_request :
512 workflow_dispatch :
@@ -39,11 +46,45 @@ jobs:
3946 vulnerability-service : osv
4047 inputs : .
4148
49+ check-aio-changes :
50+ runs-on : ubuntu-latest
51+ outputs :
52+ run-async-tests : ${{ steps.check-conditions.outputs.run-async-tests }}
53+ steps :
54+ - name : Checkout code
55+ uses : actions/checkout@v4
56+ with :
57+ fetch-depth : 0
58+
59+ - name : Check for AIO changes or manual trigger
60+ id : check-conditions
61+ run : |
62+ # Check if PR has the run-async-tests label
63+ if echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q "run-async-tests"; then
64+ echo "run-async-tests=true" >> $GITHUB_OUTPUT
65+ echo "π·οΈ Manual trigger: Found 'run-async-tests' label"
66+ exit 0
67+ fi
68+
69+ # Check for changes in AIO-related paths
70+ if git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -E "(pyatlan/.*aio/|tests/.*aio/)"; then
71+ echo "run-async-tests=true" >> $GITHUB_OUTPUT
72+ echo "π Change detection: Found AIO-related changes:"
73+ aio_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -E "(pyatlan/.*aio/|tests/.*aio/)")
74+ echo "$aio_files" | head -20
75+ total_count=$(echo "$aio_files" | wc -l)
76+ echo "π Total AIO files changed: $total_count"
77+ else
78+ echo "run-async-tests=false" >> $GITHUB_OUTPUT
79+ echo "βοΈ No AIO changes detected and no manual trigger label found"
80+ fi
81+
4282 qa-checks-and-unit-tests :
4383 needs : [vulnerability-scan]
4484 runs-on : ubuntu-latest
4585 outputs :
4686 files : ${{ steps.distribute-integration-test-files.outputs.files }}
87+ aio-files : ${{ steps.distribute-aio-test-files.outputs.aio-files }}
4788 strategy :
4889 matrix :
4990 # Specify version as a string
73114 ATLAN_API_KEY : ${{ secrets.ATLAN_API_KEY }}
74115 ATLAN_BASE_URL : ${{ secrets.ATLAN_BASE_URL }}
75116 # Run with `pytest-sugar` for enhancing the overall test report output
76- run : uv run pytest tests/unit --force-sugar
117+ run : uv run pytest tests/unit --force-sugar -vv
77118
78119 - name : Prepare integration tests distribution
79120 id : distribute-integration-test-files
@@ -83,6 +124,22 @@ jobs:
83124 json_files=$(echo "${files[@]}" | jq -R -c 'split(" ")[:-1]')
84125 echo "files=$json_files" >> $GITHUB_OUTPUT
85126
127+ - name : Prepare async integration tests distribution
128+ id : distribute-aio-test-files
129+ run : |
130+ # Check if AIO test directory exists and has test files
131+ if [ -d "tests/integration/aio" ]; then
132+ aio_files=$(find tests/integration/aio -name "test_*.py" -o -name "*_test.py" | tr '\n' ' ')
133+ if [ -n "$aio_files" ]; then
134+ json_aio_files=$(echo "${aio_files[@]}" | jq -R -c 'split(" ")[:-1]')
135+ echo "aio-files=$json_aio_files" >> $GITHUB_OUTPUT
136+ else
137+ echo "aio-files=[]" >> $GITHUB_OUTPUT
138+ fi
139+ else
140+ echo "aio-files=[]" >> $GITHUB_OUTPUT
141+ fi
142+
86143 integration-tests :
87144 needs : [vulnerability-scan, qa-checks-and-unit-tests]
88145 runs-on : ubuntu-latest
@@ -120,4 +177,46 @@ jobs:
120177 timeout_minutes : 10 # Maximum time per test job; otherwise, the job will fail
121178 # Run the integration test file using `pytest-timer` plugin
122179 # to display only the durations of the 10 slowest tests with `pytest-sugar`
123- command : uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar
180+ command : uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv
181+
182+
183+ async-integration-tests :
184+ needs : [vulnerability-scan, qa-checks-and-unit-tests, check-aio-changes]
185+ runs-on : ubuntu-latest
186+ # Only run if AIO changes detected or manual trigger
187+ if : needs.check-aio-changes.outputs.run-async-tests == 'true'
188+ strategy :
189+ fail-fast : false
190+ matrix :
191+ test_file : ${{fromJson(needs.qa-checks-and-unit-tests.outputs.aio-files)}}
192+ concurrency :
193+ group : async-${{ matrix.test_file }}
194+
195+ steps :
196+ - name : Checkout code
197+ uses : actions/checkout@v4
198+
199+ - name : Set up Python 3.9
200+ uses : actions/setup-python@v5
201+ with :
202+ # Specify version as a string
203+ # https://github.com/actions/setup-python/issues/160"
204+ python-version : " 3.9"
205+
206+ - name : Install uv
207+ uses : astral-sh/setup-uv@v6
208+
209+ - name : Install dependencies
210+ run : uv sync --group dev
211+
212+ - name : Run async integration tests
213+ env : # Test tenant environment variables
214+ ATLAN_API_KEY : ${{ secrets.ATLAN_API_KEY }}
215+ ATLAN_BASE_URL : ${{ secrets.ATLAN_BASE_URL }}
216+ uses : nick-fields/retry@v3
217+ with :
218+ max_attempts : 3
219+ timeout_minutes : 15 # Async tests may take longer, increased timeout
220+ # Run the async integration test file using `pytest-timer` plugin
221+ # to display only the durations of the 10 slowest tests with `pytest-sugar`
222+ command : uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar -vv
0 commit comments