5959 # 15 is the latest version
6060 # - 15.2 is the latest (as of 9 Feb 2023)
6161 POSTGRESQL_VERSIONS : " ['postgres:12.14','postgres:15.2']"
62- PRE_COMMIT_CACHE : ~/.cache/pre-commit
6362 UV_CACHE_DIR : /tmp/uv-cache
6463 APT_CACHE_BASE : /home/runner/work/apt
6564 APT_CACHE_DIR : /home/runner/work/apt/cache
8382 integrations_glob : ${{ steps.info.outputs.integrations_glob }}
8483 integrations : ${{ steps.integrations.outputs.changes }}
8584 apt_cache_key : ${{ steps.generate_apt_cache_key.outputs.key }}
86- pre-commit_cache_key : ${{ steps.generate_pre-commit_cache_key.outputs.key }}
8785 python_cache_key : ${{ steps.generate_python_cache_key.outputs.key }}
8886 requirements : ${{ steps.core.outputs.requirements }}
8987 mariadb_groups : ${{ steps.info.outputs.mariadb_groups }}
@@ -111,11 +109,6 @@ jobs:
111109 hashFiles('requirements_all.txt') }}-${{
112110 hashFiles('homeassistant/package_constraints.txt') }}-${{
113111 hashFiles('script/gen_requirements_all.py') }}" >> $GITHUB_OUTPUT
114- - name : Generate partial pre-commit restore key
115- id : generate_pre-commit_cache_key
116- run : >-
117- echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{
118- hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
119112 - name : Generate partial apt restore key
120113 id : generate_apt_cache_key
121114 run : |
@@ -244,8 +237,8 @@ jobs:
244237 echo "skip_coverage: ${skip_coverage}"
245238 echo "skip_coverage=${skip_coverage}" >> $GITHUB_OUTPUT
246239
247- pre-commit :
248- name : Prepare pre-commit base
240+ prek :
241+ name : Run prek checks
249242 runs-on : *runs-on-ubuntu
250243 needs : [info]
251244 if : |
@@ -254,147 +247,23 @@ jobs:
254247 && github.event.inputs.audit-licenses-only != 'true'
255248 steps :
256249 - *checkout
257- - &setup-python-default
258- name : Set up Python ${{ env.DEFAULT_PYTHON }}
259- id : python
260- uses : &actions-setup-python actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
261- with :
262- python-version : ${{ env.DEFAULT_PYTHON }}
263- check-latest : true
264- - name : Restore base Python virtual environment
265- id : cache-venv
266- uses : &actions-cache actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
267- with :
268- path : venv
269- key : &key-pre-commit-venv >-
270- ${{ runner.os }}-${{ runner.arch }}-${{ steps.python.outputs.python-version }}-venv-${{
271- needs.info.outputs.pre-commit_cache_key }}
272- - name : Create Python virtual environment
273- if : steps.cache-venv.outputs.cache-hit != 'true'
274- run : |
275- python -m venv venv
276- . venv/bin/activate
277- python --version
278- pip install "$(grep '^uv' < requirements.txt)"
279- uv pip install "$(cat requirements_test.txt | grep pre-commit)"
280- - name : Restore pre-commit environment from cache
281- id : cache-precommit
282- uses : *actions-cache
283- with :
284- path : ${{ env.PRE_COMMIT_CACHE }}
285- lookup-only : true
286- key : &key-pre-commit-env >-
287- ${{ runner.os }}-${{ runner.arch }}-${{ steps.python.outputs.python-version }}-${{
288- needs.info.outputs.pre-commit_cache_key }}
289- - name : Install pre-commit dependencies
290- if : steps.cache-precommit.outputs.cache-hit != 'true'
291- run : |
292- . venv/bin/activate
293- pre-commit install-hooks
294-
295- lint-ruff-format :
296- name : Check ruff-format
297- runs-on : *runs-on-ubuntu
298- needs : &needs-pre-commit
299- - info
300- - pre-commit
301- steps :
302- - *checkout
303- - *setup-python-default
304- - &cache-restore-pre-commit-venv
305- name : Restore base Python virtual environment
306- id : cache-venv
307- uses : &actions-cache-restore actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
308- with :
309- path : venv
310- fail-on-cache-miss : true
311- key : *key-pre-commit-venv
312- - &cache-restore-pre-commit-env
313- name : Restore pre-commit environment from cache
314- id : cache-precommit
315- uses : *actions-cache-restore
316- with :
317- path : ${{ env.PRE_COMMIT_CACHE }}
318- fail-on-cache-miss : true
319- key : *key-pre-commit-env
320- - name : Run ruff-format
321- run : |
322- . venv/bin/activate
323- pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure
324- env :
325- RUFF_OUTPUT_FORMAT : github
326-
327- lint-ruff :
328- name : Check ruff
329- runs-on : *runs-on-ubuntu
330- needs : *needs-pre-commit
331- steps :
332- - *checkout
333- - *setup-python-default
334- - *cache-restore-pre-commit-venv
335- - *cache-restore-pre-commit-env
336- - name : Run ruff
337- run : |
338- . venv/bin/activate
339- pre-commit run --hook-stage manual ruff-check --all-files --show-diff-on-failure
340- env :
341- RUFF_OUTPUT_FORMAT : github
342-
343- lint-other :
344- name : Check other linters
345- runs-on : *runs-on-ubuntu
346- needs : *needs-pre-commit
347- steps :
348- - *checkout
349- - *setup-python-default
350- - *cache-restore-pre-commit-venv
351- - *cache-restore-pre-commit-env
352-
353250 - name : Register yamllint problem matcher
354251 run : |
355252 echo "::add-matcher::.github/workflows/matchers/yamllint.json"
356- - name : Run yamllint
357- run : |
358- . venv/bin/activate
359- pre-commit run --hook-stage manual yamllint --all-files --show-diff-on-failure
360-
361253 - name : Register check-json problem matcher
362254 run : |
363255 echo "::add-matcher::.github/workflows/matchers/check-json.json"
364- - name : Run check-json
365- run : |
366- . venv/bin/activate
367- pre-commit run --hook-stage manual check-json --all-files --show-diff-on-failure
368-
369- - name : Run prettier (fully)
370- if : needs.info.outputs.test_full_suite == 'true'
371- run : |
372- . venv/bin/activate
373- pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure
374-
375- - name : Run prettier (partially)
376- if : needs.info.outputs.test_full_suite == 'false'
377- shell : bash
378- run : |
379- . venv/bin/activate
380- shopt -s globstar
381- pre-commit run --hook-stage manual prettier --show-diff-on-failure --files {homeassistant,tests}/components/${{ needs.info.outputs.integrations_glob }}/{*,**/*}
382-
383256 - name : Register check executables problem matcher
384257 run : |
385258 echo "::add-matcher::.github/workflows/matchers/check-executables-have-shebangs.json"
386- - name : Run executables check
387- run : |
388- . venv/bin/activate
389- pre-commit run --hook-stage manual check-executables-have-shebangs --all-files --show-diff-on-failure
390-
391259 - name : Register codespell problem matcher
392260 run : |
393261 echo "::add-matcher::.github/workflows/matchers/codespell.json"
394- - name : Run codespell
395- run : |
396- . venv/bin/activate
397- pre-commit run --show-diff-on-failure --hook-stage manual codespell --all-files
262+ - name : Run prek
263+ uses : j178/prek-action@91fd7d7cf70ae1dee9f4f44e7dfa5d1073fe6623 # v1.0.11
264+ env :
265+ PREK_SKIP : no-commit-to-branch,mypy,pylint,gen_requirements_all,hassfest,hassfest-metadata,hassfest-mypy-config
266+ RUFF_OUTPUT_FORMAT : github
398267
399268 lint-hadolint :
400269 name : Check ${{ matrix.file }}
@@ -434,7 +303,7 @@ jobs:
434303 - &setup-python-matrix
435304 name : Set up Python ${{ matrix.python-version }}
436305 id : python
437- uses : * actions-setup-python
306+ uses : & actions-setup-python actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
438307 with :
439308 python-version : ${{ matrix.python-version }}
440309 check-latest : true
@@ -447,7 +316,7 @@ jobs:
447316 env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT
448317 - name : Restore base Python virtual environment
449318 id : cache-venv
450- uses : * actions-cache
319+ uses : & actions-cache actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
451320 with :
452321 path : venv
453322 key : &key-python-venv >-
@@ -562,7 +431,7 @@ jobs:
562431 steps :
563432 - &cache-restore-apt
564433 name : Restore apt cache
565- uses : * actions-cache-restore
434+ uses : & actions-cache-restore actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
566435 with :
567436 path : *path-apt-cache
568437 fail-on-cache-miss : true
@@ -579,7 +448,13 @@ jobs:
579448 -o Dir::State::Lists=${{ env.APT_LIST_CACHE_DIR }} \
580449 libturbojpeg
581450 - *checkout
582- - *setup-python-default
451+ - &setup-python-default
452+ name : Set up Python ${{ env.DEFAULT_PYTHON }}
453+ id : python
454+ uses : *actions-setup-python
455+ with :
456+ python-version : ${{ env.DEFAULT_PYTHON }}
457+ check-latest : true
583458 - &cache-restore-python-default
584459 name : Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment
585460 id : cache-venv
@@ -782,9 +657,7 @@ jobs:
782657 - base
783658 - gen-requirements-all
784659 - hassfest
785- - lint-other
786- - lint-ruff
787- - lint-ruff-format
660+ - prek
788661 - mypy
789662 steps :
790663 - *cache-restore-apt
@@ -823,9 +696,7 @@ jobs:
823696 - base
824697 - gen-requirements-all
825698 - hassfest
826- - lint-other
827- - lint-ruff
828- - lint-ruff-format
699+ - prek
829700 - mypy
830701 - prepare-pytest-full
831702 if : |
@@ -949,9 +820,7 @@ jobs:
949820 - base
950821 - gen-requirements-all
951822 - hassfest
952- - lint-other
953- - lint-ruff
954- - lint-ruff-format
823+ - prek
955824 - mypy
956825 if : |
957826 needs.info.outputs.lint_only != 'true'
@@ -1066,9 +935,7 @@ jobs:
1066935 - base
1067936 - gen-requirements-all
1068937 - hassfest
1069- - lint-other
1070- - lint-ruff
1071- - lint-ruff-format
938+ - prek
1072939 - mypy
1073940 if : |
1074941 needs.info.outputs.lint_only != 'true'
@@ -1202,9 +1069,7 @@ jobs:
12021069 - base
12031070 - gen-requirements-all
12041071 - hassfest
1205- - lint-other
1206- - lint-ruff
1207- - lint-ruff-format
1072+ - prek
12081073 - mypy
12091074 if : |
12101075 needs.info.outputs.lint_only != 'true'
0 commit comments