forked from PrefectHQ/prefect
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (96 loc) · 3.69 KB
/
integration-package-tests.yaml
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
name: Integrations Packages Tests
on:
pull_request:
paths:
- .github/workflows/integration-package-tests.yaml
- "src/**/*.py"
types: [opened, reopened, synchronize, labeled, unlabeled]
push:
branches:
- main
paths:
- "src/integrations/*/**.py"
jobs:
prepare-matrix:
# These tests will only run if the integration paths are affected, or someone has
# added the `integrations` label to the PR
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Generate matrix
id: set-matrix
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'test-all-integrations') }}" == 'true' ]]; then
# All of the integration packages were changed since 2.19.2, so this is a
# standin for saying "all integrations"
COMMIT_RANGE="2.19.2..${{ github.event.pull_request.head.sha }}"
elif [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
COMMIT_RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
else
COMMIT_RANGE="${{ github.event.before }}..${{ github.event.after }}"
fi
python scripts/generate_integration_package_tests_matrix.py "$COMMIT_RANGE" > matrix.json
cat matrix.json
echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
run-tests:
timeout-minutes: 20
name: Run Tests for ${{ matrix.package }} on Python ${{ matrix.python-version }}
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
fail-fast: false
steps:
- name: Display current test matrix
run: echo '${{ toJSON(matrix) }}'
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup_python
with:
python-version: ${{ matrix.python-version }}
- name: UV Cache
# Manually cache the uv cache directory
# until setup-python supports it:
# https://github.com/actions/setup-python/issues/822
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles(format('src/integrations/{0}/pyproject.toml', matrix.package)) }}
- name: Install dependencies
working-directory: src/integrations/${{ matrix.package }}
# install uv, the package, and bleeding edge prefect
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
uv pip install --upgrade --system ../../../
- name: Run tests
if: matrix.package != 'prefect-ray'
env:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
working-directory: src/integrations/${{ matrix.package }}
run: >
pytest tests
--numprocesses auto
--maxprocesses 6
--dist worksteal
# Run prefect-ray tests sequentially to avoid Ray cluster issues
- name: Run tests for prefect-ray
if: matrix.package == 'prefect-ray'
env:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
working-directory: src/integrations/${{ matrix.package }}
run: >
pytest tests