Skip to content

Commit 0e9003d

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

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ 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@v4
68+
with:
69+
path: .pytest_cache
70+
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}
71+
6472
- name: Create nox venv
6573
env:
6674
NOX_SESSION: ${{ matrix.nox-session }}
@@ -74,12 +82,34 @@ jobs:
7482
pip freeze
7583
deactivate
7684
85+
# Restore pytest cache only for pytest_min session
86+
- name: Restore pytest cache
87+
if: ${{ matrix.nox-session == 'pytest_min' }}
88+
uses: actions/cache@v4
89+
with:
90+
path: .pytest_cache
91+
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}
92+
93+
# Run nox session
7794
- name: Run nox
7895
env:
7996
NOX_SESSION: ${{ matrix.nox-session }}
80-
run: nox -R -e "$NOX_SESSION"
97+
run: |
98+
if [ "$NOX_SESSION" = "pytest_min" ]; then
99+
nox -R -e "$NOX_SESSION" -- --ff -o cache_dir=.pytest_cache
100+
else
101+
nox -R -e "$NOX_SESSION"
102+
fi
81103
timeout-minutes: 10
82104

105+
# Save pytest cache only for pytest_min session
106+
- name: Save pytest cache
107+
if: always() && matrix.nox-session == 'pytest_min'
108+
uses: actions/cache@v4
109+
with:
110+
path: .pytest_cache
111+
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}
112+
83113
# This job runs if all the `nox` matrix jobs ran and succeeded.
84114
# It is only used to have a single job that we can require in branch
85115
# protection rules, so we don't have to update the protection rules each time

0 commit comments

Comments
 (0)