mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-27 13:22:36 +00:00
Run 3.10, 3.11, 3.12, 3.13 on every PR — we need to catch version-specific breakage before merge. Removes the configure job since the matrix is now static. Still 16 jobs (4×4) vs 32.
100 lines
2.8 KiB
YAML
100 lines
2.8 KiB
YAML
name: Run Tests
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: tests-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
tests:
|
|
name: tests (${{ matrix.python-version }}, ${{ matrix.group }}/4)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
python-version: ['3.10', '3.11', '3.12', '3.13']
|
|
group: [1, 2, 3, 4]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
version: "0.8.4"
|
|
python-version: ${{ matrix.python-version }}
|
|
enable-cache: true
|
|
|
|
- name: Install the project
|
|
run: uv sync --all-groups --all-extras --frozen
|
|
|
|
- name: Restore test durations
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: .test_durations_py*
|
|
key: test-durations-py${{ matrix.python-version }}
|
|
|
|
- name: Run tests (group ${{ matrix.group }} of 4)
|
|
run: |
|
|
PYTHON_VERSION_SAFE=$(echo "${{ matrix.python-version }}" | tr '.' '_')
|
|
DURATION_FILE="../../.test_durations_py${PYTHON_VERSION_SAFE}"
|
|
|
|
DURATIONS_ARG=""
|
|
if [ -f "$DURATION_FILE" ]; then
|
|
if git diff "origin/${{ github.base_ref }}...HEAD" --name-only 2>/dev/null | grep -q "^lib/.*/tests/.*\.py$"; then
|
|
echo "::notice::Test files changed — using even splitting"
|
|
else
|
|
echo "::notice::Using cached test durations for optimal splitting"
|
|
DURATIONS_ARG="--durations-path=${DURATION_FILE}"
|
|
fi
|
|
else
|
|
echo "::notice::No cached durations — using even splitting"
|
|
fi
|
|
|
|
cd lib/crewai && uv run --frozen pytest \
|
|
-vv \
|
|
--splits 4 \
|
|
--group ${{ matrix.group }} \
|
|
$DURATIONS_ARG \
|
|
--splitting-algorithm least_duration \
|
|
--durations=10 \
|
|
--maxfail=3
|
|
|
|
- name: Run tool tests (group ${{ matrix.group }} of 4)
|
|
run: |
|
|
cd lib/crewai-tools && uv run --frozen pytest \
|
|
-vv \
|
|
--splits 4 \
|
|
--group ${{ matrix.group }} \
|
|
--durations=10 \
|
|
--maxfail=3
|
|
|
|
# Gate jobs matching required status checks in branch protection
|
|
tests-gate:
|
|
name: tests (${{ matrix.python-version }})
|
|
needs: [tests]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.10', '3.11', '3.12', '3.13']
|
|
steps:
|
|
- name: Check test results
|
|
run: |
|
|
if [ "${{ needs.tests.result }}" = "success" ]; then
|
|
echo "All tests passed"
|
|
else
|
|
echo "Tests failed: ${{ needs.tests.result }}"
|
|
exit 1
|
|
fi
|