Skip to content

Commit 61a4e47

Browse files
committed
CI: Run previously failed tests first
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent cf54baa commit 61a4e47

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ jobs:
6161
python -m pip install -e .[dev-noxfile]
6262
pip freeze
6363
64+
# Restore pytest cache only for pytest_min session to use the cache
65+
- name: Restore pytest cache
66+
if: ${{ matrix.nox-session == 'pytest_min' }}
67+
uses: actions/cache/restore@v4
68+
id: restore-pytest-cache
69+
with:
70+
path: .pytest_cache
71+
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-no-cache
72+
restore-keys: |
73+
${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-
74+
6475
- name: Create nox venv
6576
env:
6677
NOX_SESSION: ${{ matrix.nox-session }}
@@ -74,12 +85,26 @@ jobs:
7485
pip freeze
7586
deactivate
7687
88+
# Run nox session
7789
- name: Run nox
7890
env:
7991
NOX_SESSION: ${{ matrix.nox-session }}
80-
run: nox -R -e "$NOX_SESSION"
92+
run: |
93+
if [ "$NOX_SESSION" = "pytest_min" ]; then
94+
nox -R -e "$NOX_SESSION" -- --ff -o cache_dir=.pytest_cache
95+
else
96+
nox -R -e "$NOX_SESSION"
97+
fi
8198
timeout-minutes: 10
8299

100+
# Save pytest cache only for pytest_min session and only on failure
101+
- name: Save pytest cache
102+
if: always() && matrix.nox-session == 'pytest_min'
103+
uses: actions/cache/save@v4
104+
with:
105+
path: .pytest_cache
106+
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-${{ github.run_number }}
107+
83108
# This job runs if all the `nox` matrix jobs ran and succeeded.
84109
# It is only used to have a single job that we can require in branch
85110
# protection rules, so we don't have to update the protection rules each time

0 commit comments

Comments
 (0)