Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

fix: resolve test duration cache issues in CI workflows (#3506)

Greyson LaLonde1f1ab14b07c4
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 0f4c1ae31..a1b864305 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -22,6 +22,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # Fetch all history for proper diff
- name: Restore global uv cache
id: cache-restore
@@ -49,22 +51,29 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .test_durations_py*
- key: test-durations-py${{ matrix.python-version }}-
- restore-keys: |
- test-durations-py${{ matrix.python-version }}-
+ key: test-durations-py${{ matrix.python-version }}
- name: Run tests (group ${{ matrix.group }} of 8)
run: |
PYTHON_VERSION_SAFE=$(echo "${{ matrix.python-version }}" | tr '.' '_')
DURATION_FILE=".test_durations_py${PYTHON_VERSION_SAFE}"
- if [ -f "$DURATION_FILE" ]; then
- echo "Using cached test durations for optimal splitting"
- DURATIONS_ARG="--durations-path=${DURATION_FILE}"
- else
- echo "No cached durations found, tests will be split evenly"
- DURATIONS_ARG=""
- fi
+ # Temporarily always skip cached durations to fix test splitting
+ # When durations don't match, pytest-split runs duplicate tests instead of splitting
+ echo "Using even test splitting (duration cache disabled until fix merged)"
+ DURATIONS_ARG=""
+
+ # Original logic (disabled temporarily):
+ # if [ ! -f "$DURATION_FILE" ]; then
+ # echo "No cached durations found, tests will be split evenly"
+ # DURATIONS_ARG=""
+ # elif git diff origin/${{ github.base_ref }}...HEAD --name-only 2>/dev/null | grep -q "^tests/.*\.py$"; then
+ # echo "Test files have changed, skipping cached durations to avoid mismatches"
+ # DURATIONS_ARG=""
+ # else
+ # echo "No test changes detected, using cached test durations for optimal splitting"
+ # DURATIONS_ARG="--durations-path=${DURATION_FILE}"
+ # fi
uv run pytest \
--block-network \
diff --git a/.github/workflows/update-test-durations.yml b/.github/workflows/update-test-durations.yml
index daa1decfd..13f1ecd69 100644
--- a/.github/workflows/update-test-durations.yml
+++ b/.github/workflows/update-test-durations.yml
@@ -58,7 +58,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: .test_durations_py*
- key: test-durations-py${{ matrix.python-version }}-${{ github.sha }}
+ key: test-durations-py${{ matrix.python-version }}
- name: Save uv caches
if: steps.cache-restore.outputs.cache-hit != 'true'