feat(tests): add duration caching for pytest-split

- Cache test durations for optimized splitting
This commit is contained in:
Greyson LaLonde
2025-09-11 15:16:05 -04:00
committed by GitHub
parent 79d65e55a1
commit 8883fb656b
2 changed files with 91 additions and 0 deletions

View File

@@ -45,14 +45,34 @@ jobs:
- name: Install the project
run: uv sync --all-groups --all-extras
- name: Restore test durations
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 }}-
- 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
uv run pytest \
--block-network \
--timeout=30 \
-vv \
--splits 8 \
--group ${{ matrix.group }} \
$DURATIONS_ARG \
--durations=10 \
-n auto \
--maxfail=3