1717 # pull_request:
1818
1919jobs :
20+ # Determine cache key once
21+ cache :
22+ runs-on : ubuntu-latest
23+ name : Cache identify
24+ outputs :
25+ cache-key : ${{ steps.set-key.outputs.cache-key }}
26+ steps :
27+ - name : Compute cache key
28+ id : set-key
29+ run : echo "${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT"
30+
2031 # Prepare default python version environment
2132 prepare :
2233 runs-on : ubuntu-latest
3344 id : cache-reuse
3445 uses : ./.github/actions/restore-venv
3546 with :
36- python-version : ${{ steps.python.outputs.python-version }}
37- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
38- venv-directory : ${{ env.VENV }}
39- precommit-home : ${{ env.PRE_COMMIT_HOME }}
47+ cache-key : ${{ needs.cache.outputs.cache-key }}
4048 fail-on-miss : false # First time create cache (if not already exists)
4149
4250 ruff :
5765 id : cache-reuse
5866 uses : ./.github/actions/restore-venv
5967 with :
60- python-version : ${{ steps.python.outputs.python-version }}
61- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
62- venv-directory : ${{ env.VENV }}
63- precommit-home : ${{ env.PRE_COMMIT_HOME }}
68+ cache-key : ${{ needs.cache.outputs.cache-key }}
6469 - name : Ruff (check)
6570 run : |
6671 . venv/bin/activate
@@ -97,10 +102,7 @@ jobs:
97102 id : cache-reuse
98103 uses : ./.github/actions/restore-venv
99104 with :
100- python-version : ${{ steps.python.outputs.python-version }}
101- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
102- venv-directory : ${{ env.VENV }}
103- precommit-home : ${{ env.PRE_COMMIT_HOME }}
105+ cache-key : ${{ needs.cache.outputs.cache-key }}
104106 - name : Verify commit
105107 run : |
106108 . venv/bin/activate
@@ -137,9 +139,7 @@ jobs:
137139 uses : ./.github/actions/restore-venv
138140 with :
139141 python-version : ${{ matrix.python-version }}
140- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-matrix-${{ matrix.python--version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
141- venv-directory : ${{ env.VENV }}
142- precommit-home : ${{ env.PRE_COMMIT_HOME }}
142+ cache-key : ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }}
143143 fail-on-miss : false # First time create cache (if not already exists)
144144 - name : Run all tests
145145 run : |
@@ -174,10 +174,7 @@ jobs:
174174 id : cache-reuse
175175 uses : ./.github/actions/restore-venv
176176 with :
177- python-version : ${{ steps.python.outputs.python-version }}
178- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
179- venv-directory : ${{ env.VENV }}
180- precommit-home : ${{ env.PRE_COMMIT_HOME }}
177+ cache-key : ${{ needs.cache.outputs.cache-key }}
181178 - name : Run mypy
182179 run : |
183180 . venv/bin/activate
@@ -223,10 +220,7 @@ jobs:
223220 id : cache-reuse
224221 uses : ./.github/actions/restore-venv
225222 with :
226- python-version : ${{ steps.python.outputs.python-version }}
227- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
228- venv-directory : ${{ env.VENV }}
229- precommit-home : ${{ env.PRE_COMMIT_HOME }}
223+ cache-key : ${{ needs.cache.outputs.cache-key }}
230224 - name : Download all coverage artifacts
231225 uses : actions/download-artifact@v4
232226 - name : Combine coverage results
@@ -264,14 +258,15 @@ jobs:
264258 id : cache-reuse
265259 uses : ./.github/actions/restore-venv
266260 with :
267- python-version : ${{ steps.python.outputs.python-version }}
268- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
269- venv-directory : ${{ env.VENV }}
270- precommit-home : ${{ env.PRE_COMMIT_HOME }}
261+ cache-key : ${{ needs.cache.outputs.cache-key }}
271262 - name : Install pypa/build
272- run : uv pip install build --user
263+ run : |
264+ . venv/bin/activate
265+ uv pip install build --user
273266 - name : Build a binary wheel and a source tarball
274- run : python3 -m build
267+ run : |
268+ . venv/bin/activate
269+ python3 -m build
275270 - name : Publish distribution 📦 to Test PyPI
276271 uses : pypa/gh-action-pypi-publish@release/v1
277272 continue-on-error : true
@@ -298,10 +293,7 @@ jobs:
298293 id : cache-reuse
299294 uses : ./.github/actions/restore-venv
300295 with :
301- python-version : ${{ steps.python.outputs.python-version }}
302- cache-key : ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
303- venv-directory : ${{ env.VENV }}
304- precommit-home : ${{ env.PRE_COMMIT_HOME }}
296+ cache-key : ${{ needs.cache.outputs.cache-key }}
305297 - name : Run complexity report (click to view details)
306298 run : |
307299 . venv/bin/activate
0 commit comments