44name : Latest commit
55
66env :
7- CACHE_VERSION : 6
7+ CACHE_VERSION : 1
88 DEFAULT_PYTHON : " 3.14"
9- PRE_COMMIT_HOME : ${{ github.workspace }} /.cache/pre-commit
9+ PRE_COMMIT_HOME : ~ /.cache/pre-commit
1010 VENV : venv
1111
1212on :
3737 run : wget -O ha_pyproject.toml "https://raw.githubusercontent.com/home-assistant/core/refs/heads/dev/pyproject.toml"
3838 - name : Compute cache key
3939 id : set-key
40- run : echo "cache-key=${{ runner.os }}-venv-cache- ${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT"
40+ run : echo "cache-key=${{ runner.os }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT"
4141
4242 # Prepare default python version environment
4343 prepare :
4949 id : cache-reuse
5050 uses : plugwise/gh-actions/prepare-python-and-code@v1
5151 with :
52+ cache-key : ${{ needs.cache.outputs.cache-key }}
5253 fail-on-miss : false # First time create cache (if not already exists)
53- python-version : ${{ needs.python .outputs.python-version }}
54+ python-version : ${{ needs.cache .outputs.python-version }}
5455 venv-dir : ${{ env.VENV }}
5556 precommit-home : ${{ env.PRE_COMMIT_HOME }}
5657
@@ -70,23 +71,23 @@ jobs:
7071 uses : plugwise/gh-actions/restore-venv@v1
7172 with :
7273 cache-key : ${{ needs.cache.outputs.cache-key }}
73- python-version : ${{ needs.python .outputs.python-version }}
74+ python-version : ${{ needs.cache .outputs.python-version }}
7475 venv-dir : ${{ env.VENV }}
7576 precommit-home : ${{ env.PRE_COMMIT_HOME }}
7677 - name : Ruff (with fix)
7778 run : |
78- . venv/bin/activate
79+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
7980 ruff check plugwise_usb/ tests/
8081 - name : If needed, commit ruff changes to the pull request
8182 if : failure()
8283 run : |
83- . venv/bin/activate
84+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
8485 ruff format plugwise_usb/ tests/
8586 git config --global user.name 'autoruff'
8687 git config --global user.email '[email protected] ' 8788 git remote set-url origin https://x-access-token:${{ secrets.PAT_CT_PYPLUSB }}@github.com/$GITHUB_REPOSITORY
8889 git checkout $GITHUB_HEAD_REF
89- git commit -am "fixup: ${GITHUB_REF##*/} Python code reformatted using Ruff"
90+ git commit -am "fixup: ${GITHUB_REF##*/} Python code fixed using Ruff"
9091 git push origin ${GITHUB_REF##*/}
9192
9293 commitcheck :
@@ -103,24 +104,24 @@ jobs:
103104 uses : actions/checkout@v5
104105 - name : Restore cached environment
105106 id : cache-reuse
106- uses : plugwise/ghactions /restore-venv@v1
107+ uses : plugwise/gh-actions /restore-venv@v1
107108 with :
108109 cache-key : ${{ needs.cache.outputs.cache-key }}
109- python-version : ${{ needs.python .outputs.python-version }}
110+ python-version : ${{ needs.cache .outputs.python-version }}
110111 venv-dir : ${{ env.VENV }}
111112 precommit-home : ${{ env.PRE_COMMIT_HOME }}
112113 - name : Verify commit
113114 run : |
114- . venv/bin/activate
115+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
115116 pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint
116117# - name: Biome lint
117118# run: |
118- # . venv/bin/activate
119+ # . venv-${{ needs.cache.outputs.python-version }} /bin/activate
119120# mkdir -p ./tmp && curl -sL "https://github.com/biomejs/biome/releases/latest/download/biome-linux-x64" -o ./tmp/biome && chmod +x ./tmp/biome
120121# pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual biome
121122 - name : Lint markdown files
122123 run : |
123- . venv/bin/activate
124+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
124125 pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint
125126
126127 pytest :
@@ -136,18 +137,23 @@ jobs:
136137 steps :
137138 - name : Check out committed code
138139 uses : actions/checkout@v5
140+ - name : Set up Python ${{ matrix.python-version }}
141+ id : python
142+ uses : actions/setup-python@v6
143+ with :
144+ python-version : ${{ matrix.python-version }}
139145 - name : Restore cached environment
140146 id : cache-reuse
141- uses : plugwise/ghactions /restore-venv@v1
147+ uses : plugwise/gh-actions /restore-venv@v1
142148 with :
143149 fail-on-miss : false # First time create cache (if not already exists)
144- cache-key : ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }}
145- python-version : ${{ matrix .python-version }} # Force to installed python minor
150+ cache-key : ${{ needs.cache.outputs.cache-key }}
151+ python-version : ${{ steps.python.outputs .python-version }} # Force to installed python minor
146152 venv-dir : ${{ env.VENV }}
147153 precommit-home : ${{ env.PRE_COMMIT_HOME }}
148154 - name : Run all tests
149155 run : |
150- . venv/bin/activate
156+ . venv-${{ steps.python.outputs.python-version }} /bin/activate
151157 pytest --log-level info tests/*.py --cov='.'
152158 - name : Upload coverage artifact
153159 uses : actions/upload-artifact@v4
@@ -172,16 +178,16 @@ jobs:
172178 persist-credentials : false
173179 - name : Restore cached environment
174180 id : cache-reuse
175- uses : ./.github/ actions/restore-venv
181+ uses : plugwise/gh- actions/restore-venv@v1
176182 with :
177183 cache-key : ${{ needs.cache.outputs.cache-key }}
178- python-version : ${{ needs.python .outputs.python-version }}
184+ python-version : ${{ needs.cache .outputs.python-version }}
179185 venv-dir : ${{ env.VENV }}
180186 precommit-home : ${{ env.PRE_COMMIT_HOME }}
181187 - name : Run mypy
182188 run : |
183- . venv/bin/activate
184- uv pip list | grep -i mypy
189+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
190+ pip list | grep -i mypy
185191 mypy plugwise_usb/
186192
187193 # Check shellscripts
@@ -220,7 +226,7 @@ jobs:
220226 uses : plugwise/gh-actions/restore-venv@v1
221227 with :
222228 cache-key : ${{ needs.cache.outputs.cache-key }}
223- python-version : ${{ needs.python .outputs.python-version }}
229+ python-version : ${{ needs.cache .outputs.python-version }}
224230 venv-dir : ${{ env.VENV }}
225231 precommit-home : ${{ env.PRE_COMMIT_HOME }}
226232 - name : Download all coverage artifacts
@@ -231,7 +237,7 @@ jobs:
231237 path : ${{ github.workspace }}/artifacts
232238 - name : Combine coverage results
233239 run : |
234- . venv/bin/activate
240+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
235241 coverage combine artifacts/.coverage*
236242 #coverage report --fail-under=80 ## plugwise is at 94, set to 80 for plugwise_usb
237243 echo "***"
@@ -308,11 +314,11 @@ jobs:
308314 uses : plugwise/gh-actions/restore-venv@v1
309315 with :
310316 cache-key : ${{ needs.cache.outputs.cache-key }}
311- python-version : ${{ needs.python .outputs.python-version }}
317+ python-version : ${{ needs.cache .outputs.python-version }}
312318 venv-dir : ${{ env.VENV }}
313319 precommit-home : ${{ env.PRE_COMMIT_HOME }}
314320 - name : Run complexity report (click to view details)
315321 run : |
316- . venv/bin/activate
322+ . venv-${{ needs.cache.outputs.python-version }} /bin/activate
317323 echo "Showing complexity higher or equal to 'C'"
318324 radon cc plugwise_usb/ tests/ -s -nc --no-assert
0 commit comments