From 5a0cb58277c56b5aada45371c38df4f1ab478c16 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 20:20:21 +0100 Subject: [PATCH 1/5] Rework to prek + gh-actions v2 --- .github/workflows/core_next.yml | 5 ++--- .github/workflows/test.yml | 17 ++++++++--------- .markdownlint.yaml | 2 -- .pre-commit-config.yaml | 8 ++++---- .pymarkdown | 1 + CHANGELOG.md | 3 +++ scripts/core-testing.sh | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 .markdownlint.yaml create mode 100644 .pymarkdown diff --git a/.github/workflows/core_next.yml b/.github/workflows/core_next.yml index d623a015b..e54848167 100644 --- a/.github/workflows/core_next.yml +++ b/.github/workflows/core_next.yml @@ -5,9 +5,8 @@ name: Validate plugwise-beta against HA-core dev env: # Uses a different key/restore key than test.yml - CACHE_VERSION: 2 + CACHE_VERSION: 3 DEFAULT_PYTHON: "3.13" - PRE_COMMIT_HOME: ~/.cache/pre-commit VENV: venv on: @@ -49,7 +48,7 @@ jobs: needs: cache name: Prepare steps: - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse uses: plugwise/gh-actions/prepare-python-and-code@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3b9be6f5..ebf2c9b66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,9 +4,8 @@ name: Test PR against HA-core env: - CACHE_VERSION: 1 + CACHE_VERSION: 3 DEFAULT_PYTHON: "3.13" - PRE_COMMIT_HOME: ~/.cache/pre-commit VENV: venv # Do not run on 'push' (as the flow doesn't have access to the labels) - also disabled workflow_dispatch as such @@ -83,7 +82,7 @@ jobs: needs: cache name: Prepare steps: - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse uses: plugwise/gh-actions/prepare-python-and-code@v1 with: @@ -97,14 +96,14 @@ jobs: # Prepare default python version environment ha-core-release-prepare: runs-on: ubuntu-latest - name: Prepare and validate pre-commit + name: Prepare and validate prek (pre-commit) needs: - cache - prepare steps: - name: Check out committed code uses: actions/checkout@v6 - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse uses: plugwise/gh-actions/prepare-python-and-code@v1 with: @@ -112,11 +111,11 @@ jobs: fail-on-miss: false # First time create cache (if not already exists) python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - - name: Run all-files pre-commit excluding testing + - name: Run all-files prek (pre-commit) excluding testing run: | # shellcheck disable=SC1091 # ingesting virtualenv source venv-${{ needs.cache.outputs.python-version }}/bin/activate - pre-commit run --all-files --show-diff-on-failure + prek run --all-files --show-diff-on-failure env: # While not problematic, save time on performing the local hooks as they are run from the complete script in the next job SKIP: local-test-core-prep,local-test-pip-prep,local-testing,local-quality @@ -135,7 +134,7 @@ jobs: steps: - name: Check out committed code uses: actions/checkout@v6.0.1 - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse uses: plugwise/gh-actions/prepare-python-and-code@v1 with: @@ -176,7 +175,7 @@ jobs: steps: - name: Check out committed code uses: actions/checkout@v6.0.1 - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse uses: plugwise/gh-actions/prepare-python-and-code@v1 with: diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index 320406db4..000000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,2 +0,0 @@ -default: true -MD013: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d40126d29..713d3576f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -116,8 +116,8 @@ repos: entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh quality' language: script pass_filenames: false - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.47.0 + - repo: https://github.com/jackdewinter/pymarkdown + rev: v0.9.34 hooks: - - id: markdownlint - name: "Linting Markdown" + - id: pymarkdown + name: MarkDown Lint diff --git a/.pymarkdown b/.pymarkdown new file mode 100644 index 000000000..7cdbe9000 --- /dev/null +++ b/.pymarkdown @@ -0,0 +1 @@ +{ "plugins": { "md013": { "enabled": false } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index e95865381..a8352c2b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Versions from 0.40 and up ## Ongoing - Implement Core PR [#159626](https://github.com/home-assistant/core/pull/159626) via PR [#994](https://github.com/plugwise/plugwise-beta/pull/994) +- Chores + - Introduce prek (for pre-commit) & align with v2 gh-actions + - Replace node-based markdownlint with pythonesk library ## v0.62.2 diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index 1764c52e2..ef48e1360 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -95,10 +95,10 @@ fi # /20250613 # Install commit requirements -uv pip install --upgrade pre-commit +uv pip install --upgrade prek # Install pre-commit hook -pre-commit install +prek install # i.e. args used for functions, not directions set +u @@ -276,8 +276,8 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "quality" ] ; then echo -e "${CINFO}... mypy ...${CNORM}" script/run-in-env.sh mypy homeassistant/components/${REPO_NAME}/*.py || exit cd .. - echo -e "${CINFO}... markdownlint ...${CNORM}" - pre-commit run --all-files --hook-stage manual markdownlint + echo -e "${CINFO}... pymarkdownlint ...${CNORM}" + prek run --all-files --hook-stage manual pymarkdown fi # quality # Copying back not necessary in actions From 78a285bdfe806b47c98687744293616f446fd1c9 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 20:29:59 +0100 Subject: [PATCH 2/5] CRAI suggestions and CI findings --- .github/workflows/core_next.yml | 1 - .github/workflows/test.yml | 1 - scripts/core-testing.sh | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/core_next.yml b/.github/workflows/core_next.yml index e54848167..d29d4666b 100644 --- a/.github/workflows/core_next.yml +++ b/.github/workflows/core_next.yml @@ -56,7 +56,6 @@ jobs: fail-on-miss: false # First time create cache (if not already exists) python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} clone-core: "true" - name: Test against HA-core DEV (for active or upcoming RC/Beta) run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebf2c9b66..b015afc8d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,7 +90,6 @@ jobs: fail-on-miss: false # First time create cache (if not already exists) python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} clone-core: "true" # Prepare default python version environment diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index ef48e1360..9de80dd42 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -66,6 +66,10 @@ venv_and_uv() { echo -e "${CINFO}Ensure uv presence${CWARN}" python3 -m pip install uv fi + if ! [ -x "$(command -v prek)" ]; then + echo -e "${CINFO}Ensure prek presence${CWARN}" + uv pip install prek + fi if ! uv pip list | grep -q bcrypt; then script/setup fi From 60985108bce5b5f55fbe40f56abb0340867dde81 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 20:34:53 +0100 Subject: [PATCH 3/5] Switch to v2 for gh-actions --- .github/workflows/core_next.yml | 2 +- .github/workflows/test.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/core_next.yml b/.github/workflows/core_next.yml index d29d4666b..3af4f4479 100644 --- a/.github/workflows/core_next.yml +++ b/.github/workflows/core_next.yml @@ -50,7 +50,7 @@ jobs: steps: - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b015afc8d..f099aeb9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,7 +84,7 @@ jobs: steps: - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) @@ -104,7 +104,7 @@ jobs: uses: actions/checkout@v6 - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) @@ -135,7 +135,7 @@ jobs: uses: actions/checkout@v6.0.1 - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) @@ -176,7 +176,7 @@ jobs: uses: actions/checkout@v6.0.1 - name: Prepare code checkout and python/prek/pre-commit setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) From ec8ba416a6647660b7e8ffcba81645c99f85cd33 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 14 Jan 2026 17:19:46 +0100 Subject: [PATCH 4/5] CP review --- CHANGELOG.md | 2 +- requirements_commit.txt | 1 + scripts/core-testing.sh | 8 +++----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8352c2b4..7ba93814b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Versions from 0.40 and up - Implement Core PR [#159626](https://github.com/home-assistant/core/pull/159626) via PR [#994](https://github.com/plugwise/plugwise-beta/pull/994) - Chores - Introduce prek (for pre-commit) & align with v2 gh-actions - - Replace node-based markdownlint with pythonesk library + - Replace node-based markdownlint with pythonic library ## v0.62.2 diff --git a/requirements_commit.txt b/requirements_commit.txt index e69de29bb..83a0309ee 100644 --- a/requirements_commit.txt +++ b/requirements_commit.txt @@ -0,0 +1 @@ +prek>=0.2.27 diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index 9de80dd42..dd618c25c 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -68,7 +68,7 @@ venv_and_uv() { fi if ! [ -x "$(command -v prek)" ]; then echo -e "${CINFO}Ensure prek presence${CWARN}" - uv pip install prek + uv pip install -r requirements_commit.txt fi if ! uv pip list | grep -q bcrypt; then script/setup @@ -99,9 +99,7 @@ fi # /20250613 # Install commit requirements -uv pip install --upgrade prek - -# Install pre-commit hook +uv pip install -r requirements_commit.txt prek install # i.e. args used for functions, not directions @@ -280,7 +278,7 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "quality" ] ; then echo -e "${CINFO}... mypy ...${CNORM}" script/run-in-env.sh mypy homeassistant/components/${REPO_NAME}/*.py || exit cd .. - echo -e "${CINFO}... pymarkdownlint ...${CNORM}" + echo -e "${CINFO}... pymarkdown ...${CNORM}" prek run --all-files --hook-stage manual pymarkdown fi # quality From 93b8403d4553985d44168d59d0368ad5df91b03b Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 14 Jan 2026 18:17:58 +0100 Subject: [PATCH 5/5] Fix path --- scripts/core-testing.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index dd618c25c..cf5f3ab13 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -68,7 +68,7 @@ venv_and_uv() { fi if ! [ -x "$(command -v prek)" ]; then echo -e "${CINFO}Ensure prek presence${CWARN}" - uv pip install -r requirements_commit.txt + uv pip install -r "${my_path}/requirements_commit.txt" fi if ! uv pip list | grep -q bcrypt; then script/setup @@ -99,7 +99,7 @@ fi # /20250613 # Install commit requirements -uv pip install -r requirements_commit.txt +uv pip install -r "${my_path}/requirements_commit.txt" prek install # i.e. args used for functions, not directions