diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml index 4c135f719..6f49d7603 100644 --- a/.github/workflows/hassfest.yaml +++ b/.github/workflows/hassfest.yaml @@ -1,8 +1,8 @@ name: Validate with hassfest +# Removed push not to duplicate on: workflow_dispatch: - push: pull_request: schedule: - cron: "0 0 * * *" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b9635b01..086845966 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,19 +1,37 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Test against HA-core (master/released) +name: Test PR against HA-core env: - CACHE_VERSION: 29 + CACHE_VERSION: 30 DEFAULT_PYTHON: "3.13" +# Do not run on 'push' (as the flow doesn't have access to the labels) - also disabled workflow_dispatch as such +# Workaround could be something like +# - name: Get PR labels +# run: | +# PR_LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ +# "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels") +# echo "PR Labels: $PR_LABELS" + on: - workflow_dispatch: - push: -# pull_request: + pull_request: + types: + - opened + - synchronize + - labeled + - unlabeled jobs: - # Run pre-commit + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + pre-commit: name: Validate pre-commit requirements runs-on: ubuntu-latest @@ -50,7 +68,7 @@ jobs: run: | . venv/bin/activate pre-commit install-hooks - - name: Run full pre-commit + - name: Run all-files pre-commit excluding testing run: | . venv/bin/activate pre-commit run --all-files --show-diff-on-failure @@ -58,14 +76,25 @@ jobs: SKIP: local-test-core-prep,local-test-pip-prep,local-testing,local-quality # Prepare default python version environment - ha-core-prepare: + ha-core-release: runs-on: ubuntu-latest - name: Setup for HA-core (release) + name: Setup for HA-core (release/master) + continue-on-error: true needs: - pre-commit + outputs: + release_failed: ${{ steps.capture_release.outputs.failed }} steps: - name: Check out committed code uses: actions/checkout@v4.2.2 + - name: Determine Branch Test Mode + id: determine_mode + run: | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then + echo "STRICT_DEV=true" >> $GITHUB_ENV + else + echo "STRICT_DEV=false" >> $GITHUB_ENV + fi - name: Set up Python ${{ env.DEFAULT_PYTHON }} id: python uses: actions/setup-python@v5.4.0 @@ -75,7 +104,7 @@ jobs: id: cache-hacore uses: actions/cache@v4.2.0 env: - cache-name: cache-hacore + cache-name: cache-hacore-release with: path: ./ key: >- @@ -88,14 +117,150 @@ jobs: ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore ${{ env.CACHE_VERSION}}-${{ runner.os }} ${{ env.CACHE_VERSION}} - - name: Test through HA-core (master/release) + - name: Test through HA-core (master/release) - continue-on-error = ${{ env.STRICT_DEV == 'false' }} + id: ha_core_release_tests + continue-on-error: ${{ env.STRICT_DEV == 'true' }} # Allow master failures only if dev is strict run: | - GITHUB_ACTIONS="" BRANCH="master" scripts/core-testing.sh + echo "true" > result.txt + GITHUB_ACTIONS="" scripts/core-testing.sh + if [ $? -ne 0 ]; then + echo "::warning::Release HA core incompatibility" + echo "true" > result.txt + else + echo "Successfully tested against released HA-core" + echo "false" > result.txt + fi + - name: Set output explicitly + id: capture_release + if: always() + run: | + FAILED=$(cat result.txt) + echo "failed=$FAILED" >> "$GITHUB_OUTPUT" - shellcheck: - name: Shellcheck + ha-core-dev: runs-on: ubuntu-latest + name: Setup for HA-core (dev) + continue-on-error: true + needs: + - pre-commit + outputs: + dev_failed: ${{ steps.capture_dev.outputs.failed }} steps: - - uses: actions/checkout@v4.2.2 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master + - name: Check out committed code + uses: actions/checkout@v4.2.2 + - name: Determine Branch Test Mode + id: determine_mode + run: | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then + echo "STRICT_DEV=true" >> $GITHUB_ENV + else + echo "STRICT_DEV=false" >> $GITHUB_ENV + fi + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.4.0 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base HA-core Python ${{ env.DEFAULT_PYTHON }} environment + id: cache-hacore + uses: actions/cache@v4.2.0 + env: + cache-name: cache-hacore-dev + with: + path: ./ + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('./custom_components/plugwise/manifest.json') }}-${{ + hashFiles('./ha-core/.git/plugwise-tracking') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore-${{ steps.python.outputs.python-version }}- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore + ${{ env.CACHE_VERSION}}-${{ runner.os }} + ${{ env.CACHE_VERSION}} + - name: Test through HA-core (dev) - continue-on-error = ${{ env.STRICT_DEV == 'false' }} + id: ha_core_dev_tests + continue-on-error: ${{ env.STRICT_DEV == 'false' }} # Allow dev failures unless strict + run: | + echo "true" > result.txt + GITHUB_ACTIONS="" BRANCH="dev" scripts/core-testing.sh + if [ $? -ne 0 ]; then + echo "::warning::Development HA core incompatibility" + echo "true" > result.txt + else + echo "Successfully tested against dev HA-core" + echo "false" > result.txt + fi + - name: Set output explicitly + id: capture_dev + if: always() + run: | + FAILED=$(cat result.txt) + echo "failed=$FAILED" >> "$GITHUB_OUTPUT" + + final-comment: + runs-on: ubuntu-latest + needs: [ha-core-release, ha-core-dev] + steps: + - name: Determine Branch Test Mode + id: determine_mode + run: | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then + echo "STRICT_DEV=true" >> $GITHUB_ENV + else + echo "STRICT_DEV=false" >> $GITHUB_ENV + fi + - name: Create combined comment + run: | + # Get the results of the previous scripts + STRICT_DEV=$STRICT_DEV + DEV_TESTS_FAILED=${{ needs.ha-core-dev.outputs.dev_failed }} + RELEASE_TESTS_FAILED=${{ needs.ha-core-release.outputs.release_failed }} + FAIL_COUNT=0 + + if [[ $DEV_TESTS_FAILED == "true" ]]; then + COMMENT_BODY=":x: **Error while testing for Development HA-core:**\n\n" + else + COMMENT_BODY=":warning: **Warning while testing for RELEASED HA-core:**\n\n" + fi + + if [[ $DEV_TESTS_FAILED == "true" ]]; then + if [[ $STRICT_DEV == "true" ]]; then + COMMENT_BODY+=":x: **Error:** Incompatible while testing against dev HA-core and required to pass.\n" + FAIL_COUNT=2 + else + COMMENT_BODY+=":warning: **Warning:** Incompatible while testing against dev HA-core.\n" + FAIL_COUNT=1 + fi + else + COMMENT_BODY+=":heavy_check_mark: **Success:** No problem with testing against dev HA-core.\n" + fi + + if [[ $RELEASE_TESTS_FAILED == "true" ]]; then + if [[ $STRICT_DEV == "false" ]]; then + COMMENT_BODY+=":x: **Error:** Incompatible while testing against released HA-core and required to pass.\n" + FAIL_COUNT=2 + else + COMMENT_BODY+=":warning: **Warning:** Incompatible while testing against released HA-core.\n" + FAIL_COUNT=1 + fi + else + COMMENT_BODY+=":heavy_check_mark: **Success:** No problem with testing against released HA-core.\n" + fi + + if [[ $FAIL_COUNT -eq 1 ]]; then + echo "Comment and approve the pull request" + curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + --data "{\"event\": \"APPROVE\", \"body\": \"$COMMENT_BODY\"}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" + fi + if [[ $FAIL_COUNT -eq 2 ]]; then + echo "Requesting changes on the pull request" + curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + --data "{\"event\": \"REQUEST_CHANGES\", \"body\": \"$COMMENT_BODY\"}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" + fi diff --git a/.gitignore b/.gitignore index 755e1c48a..b5a07cf2e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ venv *.orig node_modules manual_clone_ha +package-lock.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af883a0f4..b4f2c3d58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -75,30 +75,30 @@ repos: hooks: - id: local-test-core-prep # yamllint disable-line rule:line-length - name: "Home Assistant Core Testing - Cloning/updating HA core#master - patience!" + name: "Home Assistant Core Testing - Cloning/updating HA core - patience!" # yamllint disable-line rule:line-length - entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh core_prep' + entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh core_prep' language: script pass_filenames: false - id: local-test-pip-prep # yamllint disable-line rule:line-length name: "Home Assistant Core Testing - Installing dependencies - patience!" # yamllint disable-line rule:line-length - entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh pip_prep' + entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh pip_prep' language: script pass_filenames: false - id: local-testing # yamllint disable-line rule:line-length name: "Home Assistant Core Testing - Performing Tests" # yamllint disable-line rule:line-length - entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh testing' + entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh testing' language: script pass_filenames: false - id: local-quality # yamllint disable-line rule:line-length name: "Home Assistant Core Testing - Quality checks - might need patience" # yamllint disable-line rule:line-length - entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh quality' + 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 241347531..f3685362d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Versions from 0.40 and up +## v0.56.1 + +- Config_flow: follow [Core PR](https://github.com/home-assistant/core/pull/135653) movement of ZeroconfServiceInfo +- Github actions: added `require-dev-pass` label to invert testing from passing HA Core release to HA Core dev + - The actions will now indicate and request changes or approve depending on the testing outcome + - When developing a PR for `dev` not just release pre-fix your `git commit` and `scripts/core-testing` with `BRANCH=dev` + - When creating the PR set the `require-dev-pass` label accordingly + ## v0.56.0 - Internal: Fixes for the CI process diff --git a/custom_components/plugwise/config_flow.py b/custom_components/plugwise/config_flow.py index 46ad0ca93..b9c71e6ab 100644 --- a/custom_components/plugwise/config_flow.py +++ b/custom_components/plugwise/config_flow.py @@ -17,7 +17,6 @@ ) import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ( SOURCE_USER, ConfigEntry, @@ -42,6 +41,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession +from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo from .const import ( ANNA_WITH_ADAM, diff --git a/custom_components/plugwise/manifest.json b/custom_components/plugwise/manifest.json index fa46b5df1..34b624dfc 100644 --- a/custom_components/plugwise/manifest.json +++ b/custom_components/plugwise/manifest.json @@ -8,6 +8,6 @@ "iot_class": "local_polling", "loggers": ["plugwise"], "requirements": ["plugwise==1.7.0"], - "version": "0.56.0", + "version": "0.56.1", "zeroconf": ["_plugwise._tcp.local."] } diff --git a/hacs.json b/hacs.json index 2c6f7e9b7..6bd477de7 100644 --- a/hacs.json +++ b/hacs.json @@ -9,6 +9,6 @@ "sensor", "switch" ], - "homeassistant": "2024.12.0b2", + "homeassistant": "2025.2.0", "render_readme": true } diff --git a/pyproject.toml b/pyproject.toml index c424c0f66..273910fc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "plugwise-beta" -version = "0.55.4" +version = "0.56.1" description = "Plugwise beta custom-component" readme = "README.md" requires-python = ">=3.12" diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 06e25438d..fb2924018 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -19,7 +19,6 @@ DEFAULT_PORT, DOMAIN, ) -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF, ConfigFlowResult from homeassistant.const import ( CONF_HOST, @@ -33,6 +32,7 @@ ) from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo from packaging.version import Version from tests.common import MockConfigEntry