diff --git a/.github/workflows/core_next.yml b/.github/workflows/core_next.yml index d623a015b..3af4f4479 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,15 +48,14 @@ 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 + 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) 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 d3b9be6f5..f099aeb9a 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,40 +82,39 @@ 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 + 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) 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 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 + 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) 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,9 +133,9 @@ 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 + 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,9 +174,9 @@ 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 + 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/.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..7ba93814b 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 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 1764c52e2..cf5f3ab13 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 -r "${my_path}/requirements_commit.txt" + fi if ! uv pip list | grep -q bcrypt; then script/setup fi @@ -95,10 +99,8 @@ fi # /20250613 # Install commit requirements -uv pip install --upgrade pre-commit - -# Install pre-commit hook -pre-commit install +uv pip install -r "${my_path}/requirements_commit.txt" +prek install # i.e. args used for functions, not directions set +u @@ -276,8 +278,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}... pymarkdown ...${CNORM}" + prek run --all-files --hook-stage manual pymarkdown fi # quality # Copying back not necessary in actions