Skip to content

Commit 8c170a9

Browse files
authored
Merge pull request #822 from plugwise/zeroconf
Follow Core PR 135653 for 2025.2.0 (moving ZeroconfServiceInfo)
2 parents e6d5634 + 78e7c5e commit 8c170a9

File tree

10 files changed

+202
-28
lines changed

10 files changed

+202
-28
lines changed

.github/workflows/hassfest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Validate with hassfest
22

3+
# Removed push not to duplicate
34
on:
45
workflow_dispatch:
5-
push:
66
pull_request:
77
schedule:
88
- cron: "0 0 * * *"

.github/workflows/test.yml

Lines changed: 182 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Test against HA-core (master/released)
4+
name: Test PR against HA-core
55

66
env:
7-
CACHE_VERSION: 29
7+
CACHE_VERSION: 30
88
DEFAULT_PYTHON: "3.13"
99

10+
# Do not run on 'push' (as the flow doesn't have access to the labels) - also disabled workflow_dispatch as such
11+
# Workaround could be something like
12+
# - name: Get PR labels
13+
# run: |
14+
# PR_LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
15+
# "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels")
16+
# echo "PR Labels: $PR_LABELS"
17+
1018
on:
11-
workflow_dispatch:
12-
push:
13-
# pull_request:
19+
pull_request:
20+
types:
21+
- opened
22+
- synchronize
23+
- labeled
24+
- unlabeled
1425

1526
jobs:
16-
# Run pre-commit
27+
shellcheck:
28+
name: Shellcheck
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4.2.2
32+
- name: Run ShellCheck
33+
uses: ludeeus/action-shellcheck@master
34+
1735
pre-commit:
1836
name: Validate pre-commit requirements
1937
runs-on: ubuntu-latest
@@ -50,22 +68,33 @@ jobs:
5068
run: |
5169
. venv/bin/activate
5270
pre-commit install-hooks
53-
- name: Run full pre-commit
71+
- name: Run all-files pre-commit excluding testing
5472
run: |
5573
. venv/bin/activate
5674
pre-commit run --all-files --show-diff-on-failure
5775
env: # While not problematic, save time on performing the local hooks as they are run from the complete script in the next job
5876
SKIP: local-test-core-prep,local-test-pip-prep,local-testing,local-quality
5977

6078
# Prepare default python version environment
61-
ha-core-prepare:
79+
ha-core-release:
6280
runs-on: ubuntu-latest
63-
name: Setup for HA-core (release)
81+
name: Setup for HA-core (release/master)
82+
continue-on-error: true
6483
needs:
6584
- pre-commit
85+
outputs:
86+
release_failed: ${{ steps.capture_release.outputs.failed }}
6687
steps:
6788
- name: Check out committed code
6889
uses: actions/checkout@v4.2.2
90+
- name: Determine Branch Test Mode
91+
id: determine_mode
92+
run: |
93+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then
94+
echo "STRICT_DEV=true" >> $GITHUB_ENV
95+
else
96+
echo "STRICT_DEV=false" >> $GITHUB_ENV
97+
fi
6998
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
7099
id: python
71100
uses: actions/setup-python@v5.4.0
@@ -75,7 +104,7 @@ jobs:
75104
id: cache-hacore
76105
uses: actions/cache@v4.2.0
77106
env:
78-
cache-name: cache-hacore
107+
cache-name: cache-hacore-release
79108
with:
80109
path: ./
81110
key: >-
@@ -88,14 +117,150 @@ jobs:
88117
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore
89118
${{ env.CACHE_VERSION}}-${{ runner.os }}
90119
${{ env.CACHE_VERSION}}
91-
- name: Test through HA-core (master/release)
120+
- name: Test through HA-core (master/release) - continue-on-error = ${{ env.STRICT_DEV == 'false' }}
121+
id: ha_core_release_tests
122+
continue-on-error: ${{ env.STRICT_DEV == 'true' }} # Allow master failures only if dev is strict
92123
run: |
93-
GITHUB_ACTIONS="" BRANCH="master" scripts/core-testing.sh
124+
echo "true" > result.txt
125+
GITHUB_ACTIONS="" scripts/core-testing.sh
126+
if [ $? -ne 0 ]; then
127+
echo "::warning::Release HA core incompatibility"
128+
echo "true" > result.txt
129+
else
130+
echo "Successfully tested against released HA-core"
131+
echo "false" > result.txt
132+
fi
133+
- name: Set output explicitly
134+
id: capture_release
135+
if: always()
136+
run: |
137+
FAILED=$(cat result.txt)
138+
echo "failed=$FAILED" >> "$GITHUB_OUTPUT"
94139
95-
shellcheck:
96-
name: Shellcheck
140+
ha-core-dev:
97141
runs-on: ubuntu-latest
142+
name: Setup for HA-core (dev)
143+
continue-on-error: true
144+
needs:
145+
- pre-commit
146+
outputs:
147+
dev_failed: ${{ steps.capture_dev.outputs.failed }}
98148
steps:
99-
- uses: actions/checkout@v4.2.2
100-
- name: Run ShellCheck
101-
uses: ludeeus/action-shellcheck@master
149+
- name: Check out committed code
150+
uses: actions/checkout@v4.2.2
151+
- name: Determine Branch Test Mode
152+
id: determine_mode
153+
run: |
154+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then
155+
echo "STRICT_DEV=true" >> $GITHUB_ENV
156+
else
157+
echo "STRICT_DEV=false" >> $GITHUB_ENV
158+
fi
159+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
160+
id: python
161+
uses: actions/setup-python@v5.4.0
162+
with:
163+
python-version: ${{ env.DEFAULT_PYTHON }}
164+
- name: Restore base HA-core Python ${{ env.DEFAULT_PYTHON }} environment
165+
id: cache-hacore
166+
uses: actions/cache@v4.2.0
167+
env:
168+
cache-name: cache-hacore-dev
169+
with:
170+
path: ./
171+
key: >-
172+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore-${{
173+
steps.python.outputs.python-version }}-${{
174+
hashFiles('./custom_components/plugwise/manifest.json') }}-${{
175+
hashFiles('./ha-core/.git/plugwise-tracking') }}
176+
restore-keys: |
177+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore-${{ steps.python.outputs.python-version }}-
178+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-hacore
179+
${{ env.CACHE_VERSION}}-${{ runner.os }}
180+
${{ env.CACHE_VERSION}}
181+
- name: Test through HA-core (dev) - continue-on-error = ${{ env.STRICT_DEV == 'false' }}
182+
id: ha_core_dev_tests
183+
continue-on-error: ${{ env.STRICT_DEV == 'false' }} # Allow dev failures unless strict
184+
run: |
185+
echo "true" > result.txt
186+
GITHUB_ACTIONS="" BRANCH="dev" scripts/core-testing.sh
187+
if [ $? -ne 0 ]; then
188+
echo "::warning::Development HA core incompatibility"
189+
echo "true" > result.txt
190+
else
191+
echo "Successfully tested against dev HA-core"
192+
echo "false" > result.txt
193+
fi
194+
- name: Set output explicitly
195+
id: capture_dev
196+
if: always()
197+
run: |
198+
FAILED=$(cat result.txt)
199+
echo "failed=$FAILED" >> "$GITHUB_OUTPUT"
200+
201+
final-comment:
202+
runs-on: ubuntu-latest
203+
needs: [ha-core-release, ha-core-dev]
204+
steps:
205+
- name: Determine Branch Test Mode
206+
id: determine_mode
207+
run: |
208+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then
209+
echo "STRICT_DEV=true" >> $GITHUB_ENV
210+
else
211+
echo "STRICT_DEV=false" >> $GITHUB_ENV
212+
fi
213+
- name: Create combined comment
214+
run: |
215+
# Get the results of the previous scripts
216+
STRICT_DEV=$STRICT_DEV
217+
DEV_TESTS_FAILED=${{ needs.ha-core-dev.outputs.dev_failed }}
218+
RELEASE_TESTS_FAILED=${{ needs.ha-core-release.outputs.release_failed }}
219+
FAIL_COUNT=0
220+
221+
if [[ $DEV_TESTS_FAILED == "true" ]]; then
222+
COMMENT_BODY=":x: **Error while testing for Development HA-core:**\n\n"
223+
else
224+
COMMENT_BODY=":warning: **Warning while testing for RELEASED HA-core:**\n\n"
225+
fi
226+
227+
if [[ $DEV_TESTS_FAILED == "true" ]]; then
228+
if [[ $STRICT_DEV == "true" ]]; then
229+
COMMENT_BODY+=":x: **Error:** Incompatible while testing against dev HA-core and required to pass.\n"
230+
FAIL_COUNT=2
231+
else
232+
COMMENT_BODY+=":warning: **Warning:** Incompatible while testing against dev HA-core.\n"
233+
FAIL_COUNT=1
234+
fi
235+
else
236+
COMMENT_BODY+=":heavy_check_mark: **Success:** No problem with testing against dev HA-core.\n"
237+
fi
238+
239+
if [[ $RELEASE_TESTS_FAILED == "true" ]]; then
240+
if [[ $STRICT_DEV == "false" ]]; then
241+
COMMENT_BODY+=":x: **Error:** Incompatible while testing against released HA-core and required to pass.\n"
242+
FAIL_COUNT=2
243+
else
244+
COMMENT_BODY+=":warning: **Warning:** Incompatible while testing against released HA-core.\n"
245+
FAIL_COUNT=1
246+
fi
247+
else
248+
COMMENT_BODY+=":heavy_check_mark: **Success:** No problem with testing against released HA-core.\n"
249+
fi
250+
251+
if [[ $FAIL_COUNT -eq 1 ]]; then
252+
echo "Comment and approve the pull request"
253+
curl -s -X POST \
254+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
255+
-H "Content-Type: application/json" \
256+
--data "{\"event\": \"APPROVE\", \"body\": \"$COMMENT_BODY\"}" \
257+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"
258+
fi
259+
if [[ $FAIL_COUNT -eq 2 ]]; then
260+
echo "Requesting changes on the pull request"
261+
curl -s -X POST \
262+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
263+
-H "Content-Type: application/json" \
264+
--data "{\"event\": \"REQUEST_CHANGES\", \"body\": \"$COMMENT_BODY\"}" \
265+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"
266+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ venv
88
*.orig
99
node_modules
1010
manual_clone_ha
11+
package-lock.json

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,30 @@ repos:
7575
hooks:
7676
- id: local-test-core-prep
7777
# yamllint disable-line rule:line-length
78-
name: "Home Assistant Core Testing - Cloning/updating HA core#master - patience!"
78+
name: "Home Assistant Core Testing - Cloning/updating HA core - patience!"
7979
# yamllint disable-line rule:line-length
80-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh core_prep'
80+
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh core_prep'
8181
language: script
8282
pass_filenames: false
8383
- id: local-test-pip-prep
8484
# yamllint disable-line rule:line-length
8585
name: "Home Assistant Core Testing - Installing dependencies - patience!"
8686
# yamllint disable-line rule:line-length
87-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh pip_prep'
87+
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh pip_prep'
8888
language: script
8989
pass_filenames: false
9090
- id: local-testing
9191
# yamllint disable-line rule:line-length
9292
name: "Home Assistant Core Testing - Performing Tests"
9393
# yamllint disable-line rule:line-length
94-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh testing'
94+
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh testing'
9595
language: script
9696
pass_filenames: false
9797
- id: local-quality
9898
# yamllint disable-line rule:line-length
9999
name: "Home Assistant Core Testing - Quality checks - might need patience"
100100
# yamllint disable-line rule:line-length
101-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh quality'
101+
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" BRANCH="${BRANCH:-}" scripts/core-testing.sh quality'
102102
language: script
103103
pass_filenames: false
104104
- repo: https://github.com/igorshubovych/markdownlint-cli

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
Versions from 0.40 and up
44

5+
## v0.56.1
6+
7+
- Config_flow: follow [Core PR](https://github.com/home-assistant/core/pull/135653) movement of ZeroconfServiceInfo
8+
- Github actions: added `require-dev-pass` label to invert testing from passing HA Core release to HA Core dev
9+
- The actions will now indicate and request changes or approve depending on the testing outcome
10+
- When developing a PR for `dev` not just release pre-fix your `git commit` and `scripts/core-testing` with `BRANCH=dev`
11+
- When creating the PR set the `require-dev-pass` label accordingly
12+
513
## v0.56.0
614

715
- Internal: Fixes for the CI process

custom_components/plugwise/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
)
1818
import voluptuous as vol
1919

20-
from homeassistant.components.zeroconf import ZeroconfServiceInfo
2120
from homeassistant.config_entries import (
2221
SOURCE_USER,
2322
ConfigEntry,
@@ -42,6 +41,7 @@
4241
from homeassistant.core import HomeAssistant, callback
4342
from homeassistant.helpers import config_validation as cv
4443
from homeassistant.helpers.aiohttp_client import async_get_clientsession
44+
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
4545

4646
from .const import (
4747
ANNA_WITH_ADAM,

custom_components/plugwise/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"iot_class": "local_polling",
99
"loggers": ["plugwise"],
1010
"requirements": ["plugwise==1.7.0"],
11-
"version": "0.56.0",
11+
"version": "0.56.1",
1212
"zeroconf": ["_plugwise._tcp.local."]
1313
}

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"sensor",
1010
"switch"
1111
],
12-
"homeassistant": "2024.12.0b2",
12+
"homeassistant": "2025.2.0",
1313
"render_readme": true
1414
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "plugwise-beta"
3-
version = "0.55.4"
3+
version = "0.56.1"
44
description = "Plugwise beta custom-component"
55
readme = "README.md"
66
requires-python = ">=3.12"

tests/components/plugwise/test_config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
DEFAULT_PORT,
2020
DOMAIN,
2121
)
22-
from homeassistant.components.zeroconf import ZeroconfServiceInfo
2322
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF, ConfigFlowResult
2423
from homeassistant.const import (
2524
CONF_HOST,
@@ -33,6 +32,7 @@
3332
)
3433
from homeassistant.core import HomeAssistant
3534
from homeassistant.data_entry_flow import FlowResultType
35+
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
3636
from packaging.version import Version
3737

3838
from tests.common import MockConfigEntry

0 commit comments

Comments
 (0)