Repository navigation
167 lines (152 loc) · 5.7 KB
/
Copy pathtests.yml
File metadata and controls
167 lines (152 loc) · 5.7 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
name: Run Tests
on: [pull_request]
permissions:
contents: read
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3
id: filter
with:
# Exclusion-only patterns match every non-excluded file under the
# default "some" quantifier. Require all patterns (including "**")
# so docs/markdown/Actions-only PRs correctly set code=false.
predicate-quantifier: every
filters: |
code:
- '**'
- '!docs/**'
- '!**/*.md'
- '!.github/**'
tests-matrix:
name: tests (${{ matrix.python-version }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
group: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0 # Fetch all history for proper diff
- name: Restore global uv cache
id: cache-restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/uv
~/.local/share/uv
.venv
key: uv-main-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-main-py${{ matrix.python-version }}-
- name: Install uv
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
version: "0.13.4"
python-version: ${{ matrix.python-version }}
enable-cache: false
- name: Install the project
run: uv sync --all-groups --all-extras
- name: Restore test durations
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .test_durations_*
# Never an exact hit; restore-keys picks the newest saved durations.
key: test-durations-py${{ matrix.python-version }}-${{ github.run_id }}
restore-keys: |
test-durations-py${{ matrix.python-version }}-
# pytest-randomly shuffles before pytest-split slices, so every group job must
# share one seed; per-job seeds make the 8 groups overlap and skip about a third.
- name: Run tests (group ${{ matrix.group }} of 8)
run: |
PY=$(echo "${{ matrix.python-version }}" | tr '.' '_')
cd lib/crewai
DURATIONS_ARG=""
[ -f "../../.test_durations_crewai_py${PY}" ] && DURATIONS_ARG="--durations-path=../../.test_durations_crewai_py${PY}"
uv run pytest \
-vv \
--splits 8 \
--group ${{ matrix.group }} \
--randomly-seed=${{ github.run_id }} \
$DURATIONS_ARG \
--durations=10 \
--maxfail=3
- name: Run tool tests (group ${{ matrix.group }} of 8)
run: |
PY=$(echo "${{ matrix.python-version }}" | tr '.' '_')
cd lib/crewai-tools
DURATIONS_ARG=""
[ -f "../../.test_durations_tools_py${PY}" ] && DURATIONS_ARG="--durations-path=../../.test_durations_tools_py${PY}"
uv run pytest \
-vv \
--splits 8 \
--group ${{ matrix.group }} \
--randomly-seed=${{ github.run_id }} \
$DURATIONS_ARG \
--durations=10 \
--maxfail=3
- name: Run CLI, core and files tests (group ${{ matrix.group }} of 8)
run: |
PY=$(echo "${{ matrix.python-version }}" | tr '.' '_')
DURATIONS_ARG=""
[ -f ".test_durations_misc_py${PY}" ] && DURATIONS_ARG="--durations-path=.test_durations_misc_py${PY}"
uv run pytest lib/cli/tests lib/crewai-core/tests lib/crewai-files/tests \
-vv \
--splits 8 \
--group ${{ matrix.group }} \
--randomly-seed=${{ github.run_id }} \
$DURATIONS_ARG \
--durations=10 \
--maxfail=3
- name: Save uv caches
if: steps.cache-restore.outputs.cache-hit != 'true' && matrix.group == 1
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/uv
~/.local/share/uv
.venv
key: uv-main-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
# Report the required check names (tests 3.10–3.13) when the matrix is skipped.
# Branch protection expects these names; a skipped matrix never reports them.
tests-skip:
name: tests (${{ matrix.python-version }})
needs: changes
if: needs.changes.outputs.code != 'true'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- name: Skip non-code change
run: echo "Non-code change, skipping tests"
# Summary job to provide single status for branch protection
tests:
name: tests
runs-on: ubuntu-latest
needs: [changes, tests-matrix, tests-skip]
if: always()
steps:
- name: Check results
run: |
if [ "${{ needs.changes.outputs.code }}" != "true" ]; then
echo "Non-code change, skipping tests"
exit 0
fi
if [ "${{ needs.tests-matrix.result }}" == "success" ]; then
echo "All tests passed"
else
echo "Tests failed"
exit 1
fi