@@ -28,21 +28,13 @@ jobs:
2828 uses : actions/setup-python@v5
2929 with :
3030 python-version : ${{ env.DEFAULT_PYTHON }}
31- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
31+ - name : Ensure/restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
3232 id : cache-venv
3333 uses : actions/cache@v4
3434 with :
3535 path : venv
36- key : >-
37- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
38- steps.python.outputs.python-version }}-${{
39- hashFiles('requirements_test.txt') }}-${{
40- hashFiles('setup.py') }}
41- restore-keys : |
42- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }}-
43- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}
44- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
45- - name : Create Python virtual environment
36+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
37+ - name : Create Python virtual environment (from cache)
4638 if : steps.cache-venv.outputs.cache-hit != 'true'
4739 run : |
4840 pip install virtualenv --upgrade
@@ -51,15 +43,14 @@ jobs:
5143 pip install uv
5244 uv pip install -U pip setuptools wheel
5345 uv pip install -r requirements_test.txt -r requirements_commit.txt
54- - name : Restore pre-commit environment from cache
46+ - name : Ensure/restore python and pre-commit environment ( from cache)
5547 id : cache-precommit
5648 uses : actions/cache@v4
5749 with :
58- path : ${{ env.PRE_COMMIT_HOME }}
59- key : |
60- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
61- restore-keys : |
62- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-
50+ path : |
51+ venv
52+ ${{ env.PRE_COMMIT_HOME }}
53+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
6354 - name : Install pre-commit dependencies
6455 if : steps.cache-precommit.outputs.cache-hit != 'true'
6556 run : |
@@ -80,20 +71,19 @@ jobs:
8071 uses : actions/setup-python@v5
8172 with :
8273 python-version : ${{ env.DEFAULT_PYTHON }}
83- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
74+ - name : Ensure/restore pre-commit and Python ${{ env.DEFAULT_PYTHON }} virtual environment
8475 id : cache-venv
8576 uses : actions/cache@v4
8677 with :
87- path : venv
78+ path : |
79+ venv
80+ ${{ env.PRE_COMMIT_HOME }}
8881 key : >-
89- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
90- steps.python.outputs.python-version }}-${{
91- hashFiles('requirements_test.txt') }}-${{
92- hashFiles('setup.py') }}
82+ ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
9383 - name : Fail job if Python cache restore failed
9484 if : steps.cache-venv.outputs.cache-hit != 'true'
9585 run : |
96- echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache"
86+ echo "Failed to restore pre-commit and Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache"
9787 exit 1
9888 - name : Ruff (check)
9989 run : |
@@ -126,32 +116,18 @@ jobs:
126116 uses : actions/setup-python@v5
127117 with :
128118 python-version : ${{ env.DEFAULT_PYTHON }}
129- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
119+ - name : Restore pre-commit and Python ${{ env.DEFAULT_PYTHON }} virtual environment
130120 id : cache-venv
131121 uses : actions/cache@v4
132122 with :
133- path : venv
134- key : >-
135- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
136- steps.python.outputs.python-version }}-${{
137- hashFiles('requirements_test.txt') }}-${{
138- hashFiles('setup.py') }}
123+ path : |
124+ venv
125+ ${{ env.PRE_COMMIT_HOME }}
126+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
139127 - name : Fail job if Python cache restore failed
140128 if : steps.cache-venv.outputs.cache-hit != 'true'
141129 run : |
142- echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache"
143- exit 1
144- - name : Restore pre-commit environment from cache
145- id : cache-precommit
146- uses : actions/cache@v4
147- with :
148- path : ${{ env.PRE_COMMIT_HOME }}
149- key : |
150- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
151- - name : Fail job if cache restore failed
152- if : steps.cache-venv.outputs.cache-hit != 'true'
153- run : |
154- echo "Failed to restore pre-commit environment from cache"
130+ echo "Failed to restore pre-commit and Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache"
155131 exit 1
156132 - name : Verify commit
157133 run : |
@@ -182,19 +158,12 @@ jobs:
182158 uses : actions/setup-python@v5
183159 with :
184160 python-version : ${{ matrix.python-version }}
185- - name : Restore full Python ${{ matrix.python-version }} virtual environment
161+ - name : Restore Python ${{ matrix.python-version }} virtual environment
186162 id : cache-venv
187163 uses : actions/cache@v4
188164 with :
189165 path : venv
190- key : >-
191- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{
192- matrix.python-version }}-${{ hashFiles('requirements_test.txt')
193- }}-${{ hashFiles('setup.py') }}
194- restore-keys : |
195- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }}
196- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}
197- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}-
166+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
198167 - name : Create full Python ${{ matrix.python-version }} virtual environment
199168 if : steps.cache-venv.outputs.cache-hit != 'true'
200169 run : |
@@ -228,10 +197,7 @@ jobs:
228197 uses : actions/cache@v4
229198 with :
230199 path : venv
231- key : >-
232- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{
233- matrix.python-version }}-${{ hashFiles('requirements_test.txt')
234- }}-${{ hashFiles('setup.py') }}
200+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
235201 - name : Fail job if Python cache restore failed
236202 if : steps.cache-venv.outputs.cache-hit != 'true'
237203 run : |
@@ -263,16 +229,12 @@ jobs:
263229 uses : actions/setup-python@v5
264230 with :
265231 python-version : ${{ env.DEFAULT_PYTHON }}
266- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
232+ - name : Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
267233 id : cache-venv
268234 uses : actions/cache@v4
269235 with :
270236 path : venv
271- key : >-
272- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
273- steps.python.outputs.python-version }}-${{
274- hashFiles('requirements_test.txt') }}-${{
275- hashFiles('setup.py') }}
237+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
276238 - name : Fail job if Python cache restore failed
277239 if : steps.cache-venv.outputs.cache-hit != 'true'
278240 run : |
@@ -321,16 +283,12 @@ jobs:
321283 uses : actions/setup-python@v5
322284 with :
323285 python-version : ${{ env.DEFAULT_PYTHON }}
324- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
286+ - name : Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
325287 id : cache-venv
326288 uses : actions/cache@v4
327289 with :
328290 path : venv
329- key : >-
330- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
331- steps.python.outputs.python-version }}-${{
332- hashFiles('requirements_test.txt') }}-${{
333- hashFiles('setup.py') }}
291+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
334292 - name : Fail job if Python cache restore failed
335293 if : steps.cache-venv.outputs.cache-hit != 'true'
336294 run : |
@@ -366,16 +324,12 @@ jobs:
366324 uses : actions/setup-python@v5
367325 with :
368326 python-version : ${{ env.DEFAULT_PYTHON }}
369- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
327+ - name : Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
370328 id : cache-venv
371329 uses : actions/cache@v4
372330 with :
373331 path : venv
374- key : >-
375- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
376- steps.python.outputs.python-version }}-${{
377- hashFiles('requirements_test.txt') }}-${{
378- hashFiles('setup.py') }}
332+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
379333 - name : Fail job if Python cache restore failed
380334 if : steps.cache-venv.outputs.cache-hit != 'true'
381335 run : |
@@ -409,16 +363,12 @@ jobs:
409363 uses : actions/setup-python@v5
410364 with :
411365 python-version : ${{ env.DEFAULT_PYTHON }}
412- - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
366+ - name : Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
413367 id : cache-venv
414368 uses : actions/cache@v4
415369 with :
416370 path : venv
417- key : >-
418- usb-${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
419- steps.python.outputs.python-version }}-${{
420- hashFiles('requirements_test.txt') }}-${{
421- hashFiles('setup.py') }}
371+ key : ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt') }}
422372 - name : Fail job if Python cache restore failed
423373 if : steps.cache-venv.outputs.cache-hit != 'true'
424374 run : |
0 commit comments