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,35 @@ 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/restore@v4
89+ id : restore-pytest-cache
90+ with :
91+ path : .pytest_cache
92+ key : ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-v3
93+
94+ # Run nox session
7795 - name : Run nox
7896 env :
7997 NOX_SESSION : ${{ matrix.nox-session }}
80- run : nox -R -e "$NOX_SESSION"
98+ run : |
99+ if [ "$NOX_SESSION" = "pytest_min" ]; then
100+ nox -R -e "$NOX_SESSION" -- --ff -o cache_dir=.pytest_cache
101+ else
102+ nox -R -e "$NOX_SESSION"
103+ fi
81104 timeout-minutes : 10
82105
106+ # Save pytest cache only for pytest_min session
107+ - name : Save pytest cache
108+ if : always() && matrix.nox-session == 'pytest_min' && steps.cache-pytest-cache.outputs.cache-hit != 'true'
109+ uses : actions/cache/save@v4
110+ with :
111+ path : .pytest_cache
112+ key : ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-v3
113+
83114 # This job runs if all the `nox` matrix jobs ran and succeeded.
84115 # It is only used to have a single job that we can require in branch
85116 # protection rules, so we don't have to update the protection rules each time
0 commit comments