|
1 | 1 | name: Pyatlan Pull Request Build
|
2 | 2 |
|
| 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 | + |
3 | 10 | on:
|
4 | 11 | pull_request:
|
5 | 12 | workflow_dispatch:
|
@@ -39,11 +46,42 @@ jobs:
|
39 | 46 | vulnerability-service: osv
|
40 | 47 | inputs: .
|
41 | 48 |
|
| 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 | + git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -E "(pyatlan/.*aio/|tests/.*aio/)" | head -10 |
| 74 | + else |
| 75 | + echo "run-async-tests=false" >> $GITHUB_OUTPUT |
| 76 | + echo "⏭️ No AIO changes detected and no manual trigger label found" |
| 77 | + fi |
| 78 | +
|
42 | 79 | qa-checks-and-unit-tests:
|
43 | 80 | needs: [vulnerability-scan]
|
44 | 81 | runs-on: ubuntu-latest
|
45 | 82 | outputs:
|
46 | 83 | files: ${{ steps.distribute-integration-test-files.outputs.files }}
|
| 84 | + aio-files: ${{ steps.distribute-aio-test-files.outputs.aio-files }} |
47 | 85 | strategy:
|
48 | 86 | matrix:
|
49 | 87 | # Specify version as a string
|
@@ -83,6 +121,22 @@ jobs:
|
83 | 121 | json_files=$(echo "${files[@]}" | jq -R -c 'split(" ")[:-1]')
|
84 | 122 | echo "files=$json_files" >> $GITHUB_OUTPUT
|
85 | 123 |
|
| 124 | + - name: Prepare async integration tests distribution |
| 125 | + id: distribute-aio-test-files |
| 126 | + run: | |
| 127 | + # Check if AIO test directory exists and has test files |
| 128 | + if [ -d "tests/integration/aio" ]; then |
| 129 | + aio_files=$(find tests/integration/aio -name "test_*.py" -o -name "*_test.py" | tr '\n' ' ') |
| 130 | + if [ -n "$aio_files" ]; then |
| 131 | + json_aio_files=$(echo "${aio_files[@]}" | jq -R -c 'split(" ")[:-1]') |
| 132 | + echo "aio-files=$json_aio_files" >> $GITHUB_OUTPUT |
| 133 | + else |
| 134 | + echo "aio-files=[]" >> $GITHUB_OUTPUT |
| 135 | + fi |
| 136 | + else |
| 137 | + echo "aio-files=[]" >> $GITHUB_OUTPUT |
| 138 | + fi |
| 139 | +
|
86 | 140 | integration-tests:
|
87 | 141 | needs: [vulnerability-scan, qa-checks-and-unit-tests]
|
88 | 142 | runs-on: ubuntu-latest
|
@@ -121,3 +175,45 @@ jobs:
|
121 | 175 | # Run the integration test file using `pytest-timer` plugin
|
122 | 176 | # to display only the durations of the 10 slowest tests with `pytest-sugar`
|
123 | 177 | command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar
|
| 178 | + |
| 179 | + |
| 180 | + async-integration-tests: |
| 181 | + needs: [vulnerability-scan, qa-checks-and-unit-tests, check-aio-changes] |
| 182 | + runs-on: ubuntu-latest |
| 183 | + # Only run if AIO changes detected or manual trigger |
| 184 | + if: needs.check-aio-changes.outputs.run-async-tests == 'true' |
| 185 | + strategy: |
| 186 | + fail-fast: false |
| 187 | + matrix: |
| 188 | + test_file: ${{fromJson(needs.qa-checks-and-unit-tests.outputs.aio-files)}} |
| 189 | + concurrency: |
| 190 | + group: async-${{ matrix.test_file }} |
| 191 | + |
| 192 | + steps: |
| 193 | + - name: Checkout code |
| 194 | + uses: actions/checkout@v4 |
| 195 | + |
| 196 | + - name: Set up Python 3.9 |
| 197 | + uses: actions/setup-python@v5 |
| 198 | + with: |
| 199 | + # Specify version as a string |
| 200 | + # https://github.com/actions/setup-python/issues/160" |
| 201 | + python-version: "3.9" |
| 202 | + |
| 203 | + - name: Install uv |
| 204 | + uses: astral-sh/setup-uv@v6 |
| 205 | + |
| 206 | + - name: Install dependencies |
| 207 | + run: uv sync --group dev |
| 208 | + |
| 209 | + - name: Run async integration tests |
| 210 | + env: # Test tenant environment variables |
| 211 | + ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }} |
| 212 | + ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }} |
| 213 | + uses: nick-fields/retry@v3 |
| 214 | + with: |
| 215 | + max_attempts: 3 |
| 216 | + timeout_minutes: 15 # Async tests may take longer, increased timeout |
| 217 | + # Run the async integration test file using `pytest-timer` plugin |
| 218 | + # to display only the durations of the 10 slowest tests with `pytest-sugar` |
| 219 | + command: uv run pytest ${{ matrix.test_file }} -p name_of_plugin --timer-top-n 10 --force-sugar |
0 commit comments