5656 # Restore cached Python environment
5757 - name : Restore Python virtual environment
5858 id : cache-venv
59- uses : actions/cache@v4.0.2
59+ uses : actions/cache/restore @v4.0.2
6060 with :
6161 path : venv
6262 key :
7272 . venv/bin/activate
7373 python -m pip install -U pip setuptools wheel
7474 pip install -U -r requirements_test.txt
75+ # Save cached Python environment (explicit because cancel-in-progress: true)
76+ - name : Save Python virtual environment
77+ if : steps.cache-venv.outputs.cache-hit != 'true'
78+ id : cache-venv
79+ uses : actions/cache/save@v4.0.2
80+ with :
81+ path : venv
82+ key :
83+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
84+ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
85+ ' requirements_test.txt' , 'requirements_test_min.txt',
86+ ' requirements_test_pre_commit.txt' ) }}
7587
7688 # Cache primer packages
7789 - name : Download last 'main' run info
@@ -140,7 +152,7 @@ jobs:
140152 echo "commitstring=$output" >> $GITHUB_OUTPUT
141153 - name : Restore projects cache
142154 id : cache-projects
143- uses : actions/cache@v4.0.2
155+ uses : actions/cache/restore @v4.0.2
144156 with :
145157 path : tests/.pylint_primer_tests/
146158 key : >-
@@ -151,6 +163,14 @@ jobs:
151163 run : |
152164 . venv/bin/activate
153165 python tests/primer/__main__.py prepare --clone
166+ - name : Save projects cache
167+ if : steps.cache-projects.outputs.cache-hit != 'true'
168+ uses : actions/cache/save@v4.0.2
169+ with :
170+ path : tests/.pylint_primer_tests/
171+ key : >-
172+ ${{ runner.os }}-${{ matrix.python-version }}-${{
173+ steps.commitstring.outputs.commitstring }}-primer
154174 - name : Check cache
155175 run : |
156176 . venv/bin/activate
0 commit comments