fix: resolve test duration cache issues in CI workflows (#3506)
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled

This commit is contained in:
Greyson LaLonde
2025-09-12 08:38:47 -04:00
committed by GitHub
parent 1a70f1698e
commit 1f1ab14b07
2 changed files with 20 additions and 11 deletions

View File

@@ -22,6 +22,8 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper diff
- name: Restore global uv cache - name: Restore global uv cache
id: cache-restore id: cache-restore
@@ -49,22 +51,29 @@ jobs:
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
path: .test_durations_py* path: .test_durations_py*
key: test-durations-py${{ matrix.python-version }}- key: test-durations-py${{ matrix.python-version }}
restore-keys: |
test-durations-py${{ matrix.python-version }}-
- name: Run tests (group ${{ matrix.group }} of 8) - name: Run tests (group ${{ matrix.group }} of 8)
run: | run: |
PYTHON_VERSION_SAFE=$(echo "${{ matrix.python-version }}" | tr '.' '_') PYTHON_VERSION_SAFE=$(echo "${{ matrix.python-version }}" | tr '.' '_')
DURATION_FILE=".test_durations_py${PYTHON_VERSION_SAFE}" DURATION_FILE=".test_durations_py${PYTHON_VERSION_SAFE}"
if [ -f "$DURATION_FILE" ]; then # Temporarily always skip cached durations to fix test splitting
echo "Using cached test durations for optimal splitting" # When durations don't match, pytest-split runs duplicate tests instead of splitting
DURATIONS_ARG="--durations-path=${DURATION_FILE}" echo "Using even test splitting (duration cache disabled until fix merged)"
else DURATIONS_ARG=""
echo "No cached durations found, tests will be split evenly"
DURATIONS_ARG="" # Original logic (disabled temporarily):
fi # 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 \ uv run pytest \
--block-network \ --block-network \

View File

@@ -58,7 +58,7 @@ jobs:
uses: actions/cache/save@v4 uses: actions/cache/save@v4
with: with:
path: .test_durations_py* path: .test_durations_py*
key: test-durations-py${{ matrix.python-version }}-${{ github.sha }} key: test-durations-py${{ matrix.python-version }}
- name: Save uv caches - name: Save uv caches
if: steps.cache-restore.outputs.cache-hit != 'true' if: steps.cache-restore.outputs.cache-hit != 'true'