Skip to content

Commit b853f17

Browse files
authored
Merge pull request #266 from plugwise/cifix3
Revert custom component testing in favor for (also) testing against dev
2 parents c6f50d9 + 0fa466f commit b853f17

File tree

14 files changed

+787
-385
lines changed

14 files changed

+787
-385
lines changed

.github/workflows/test.yml

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,94 @@
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 using pytest-homeassistant-custom-component
4+
name: Test against HA-core
55

66
env:
7-
CACHE_VERSION: 10
7+
CACHE_VERSION: 11
88
DEFAULT_PYTHON: "3.13"
9+
PRE_COMMIT_HOME: ~/.cache/pre-commit
10+
VENV: venv
11+
12+
# Do not run on 'push' (as the flow doesn't have access to the labels) - also disabled workflow_dispatch as such
13+
# Workaround could be something like
14+
# - name: Get PR labels
15+
# run: |
16+
# PR_LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
17+
# "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels")
18+
# echo "PR Labels: $PR_LABELS"
919

1020
on:
11-
workflow_dispatch:
12-
push:
13-
schedule:
14-
- cron: "0 0 * * 0"
15-
# pull_request:
21+
pull_request:
22+
types:
23+
- opened
24+
- synchronize
25+
- labeled
26+
- unlabeled
1627

1728
jobs:
18-
# Prepare default python version environment
19-
ha-core-prepare:
29+
# Determine cache key once
30+
cache:
2031
runs-on: ubuntu-latest
21-
name: Setup for HA-core
32+
name: Cache identify
33+
outputs:
34+
cache-key: ${{ steps.set-key.outputs.cache-key }}
2235
steps:
2336
- name: Check out committed code
24-
uses: actions/checkout@v4.2.2
37+
uses: actions/checkout@v4
2538
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
2639
id: python
27-
uses: actions/setup-python@v5.6.0
40+
uses: actions/setup-python@v5
2841
with:
2942
python-version: ${{ env.DEFAULT_PYTHON }}
30-
- name: Prepare virtual env for testing
31-
run: |
32-
scripts/setup_test.sh
33-
- name: Test
34-
run: |
35-
scripts/tests_and_coverage.sh test_and_coverage
36-
- name: Quality
43+
- name: Fetch HA pyproject
44+
id: core-version
45+
run: wget -O ha_pyproject.toml "https://raw.githubusercontent.com/home-assistant/core/refs/heads/dev/pyproject.toml"
46+
- name: Compute cache key
47+
id: set-key
48+
run: echo "cache-key=${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml', 'ha_pyproject.toml') }}" >> "$GITHUB_OUTPUT"
49+
50+
# Prepare default python version environment
51+
prepare:
52+
runs-on: ubuntu-latest
53+
needs: cache
54+
name: Prepare
55+
steps:
56+
- name: Prepare code checkout and python/pre-commit setup
57+
id: cache-reuse
58+
uses: plugwise/gh-actions/prepare-python-and-code@v1
59+
with:
60+
cache-key: ${{ needs.cache.outputs.cache-key }}
61+
fail-on-miss: false # First time create cache (if not already exists)
62+
python-version: ${{ env.DEFAULT_PYTHON }}
63+
venv-dir: ${{ env.VENV }}
64+
precommit-home: ${{ env.PRE_COMMIT_HOME }}
65+
clone-core: "true"
66+
67+
# Prepare default python version environment
68+
ha-core-release:
69+
runs-on: ubuntu-latest
70+
name: Setup for HA-core (release/master)
71+
needs:
72+
- cache
73+
- prepare
74+
steps:
75+
- name: Check out committed code
76+
uses: actions/checkout@v4
77+
- name: Restore cached environment
78+
id: cache-reuse
79+
uses: plugwise/gh-actions/restore-venv@v1
80+
with:
81+
cache-key: ${{ needs.cache.outputs.cache-key }}
82+
python-version: ${{ env.DEFAULT_PYTHON }}
83+
venv-dir: ${{ env.VENV }}
84+
precommit-home: ${{ env.PRE_COMMIT_HOME }}
85+
- name: Test through HA-core (master/release)
86+
id: ha_core_release_tests
3787
run: |
38-
scripts/tests_and_coverage.sh linting
88+
set +e
89+
GITHUB_ACTIONS="" scripts/core-testing.sh
90+
EXIT_CODE=$?
91+
exit $EXIT_CODE
3992
4093
shellcheck:
4194
name: Shellcheck

.pre-commit-config.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# For pre-commit.ci
2-
ci:
3-
# Defer autoupdate to quarterly (there is no 'off' button) to have renovate pick up first
4-
autoupdate_schedule: quarterly
5-
skip: [test-core-prep, test-pip-prep, testing, quality]
6-
submodules: true
7-
81
default_language_version:
92
# force all unspecified python hooks to run python3
103
python: python3.13
@@ -62,7 +55,7 @@ repos:
6255
rev: v2.0.2
6356
hooks:
6457
- id: biome-lint
65-
additional_dependencies: ["@biomejs/biome@1.8.3"]
58+
additional_dependencies: ["@biomejs/biome@2.0.4"]
6659
name: "Verifying/updating code with biome (improved prettier)"
6760
- repo: https://github.com/cdce8p/python-typing-update
6861
rev: v0.7.2

CHANGELOG.md

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

33
## Versions from 0.4x
44

5+
### Ongoing
6+
7+
- Maintenance chores (CI fixing)
8+
59
### v0.55.1 - 2025-06-22
610

711
- Show energy-reset button for Plus devices via plugwise_usb [v0.44.5](https://github.com/plugwise/python-plugwise-usb/releases/tag/v0.44.5)

custom_components/plugwise_usb/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import logging
55
from typing import Any, TypedDict
66

7+
from plugwise_usb import Stick
8+
from plugwise_usb.api import NodeEvent
9+
from plugwise_usb.exceptions import NodeError, StickError
10+
711
from homeassistant.components.device_tracker import ATTR_MAC
812
from homeassistant.core import HomeAssistant, ServiceCall, callback
913
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
1014
from homeassistant.helpers import device_registry as dr, entity_registry as er
1115
from homeassistant.helpers.storage import STORAGE_DIR
12-
from plugwise_usb import Stick
13-
from plugwise_usb.api import NodeEvent
14-
from plugwise_usb.exceptions import NodeError, StickError
1516

1617
from .const import (
1718
CONF_USB_PATH,
@@ -50,7 +51,7 @@ def _async_migrate_entity_entry(
5051
hass, config_entry.entry_id, _async_migrate_entity_entry
5152
)
5253

53-
api_stick = Stick(config_entry.data[CONF_USB_PATH]) # type: ignore
54+
api_stick = Stick(config_entry.data[CONF_USB_PATH])
5455
api_stick.cache_folder = hass.config.path(
5556
STORAGE_DIR, f"plugwisecache-{config_entry.entry_id}"
5657
)
@@ -136,7 +137,10 @@ async def disable_production(call: ServiceCall) -> bool:
136137
DOMAIN, SERVICE_ENABLE_PRODUCTION, enable_production, SERVICE_USB_DEVICE_SCHEMA
137138
)
138139
hass.services.async_register(
139-
DOMAIN, SERVICE_DISABLE_PRODUCTION, disable_production, SERVICE_USB_DEVICE_SCHEMA
140+
DOMAIN,
141+
SERVICE_DISABLE_PRODUCTION,
142+
disable_production,
143+
SERVICE_USB_DEVICE_SCHEMA,
140144
)
141145

142146
# Initiate background nodes discovery task
@@ -184,14 +188,10 @@ async def async_remove_config_entry_device(
184188
try:
185189
await api_stick.unregister_node(mac)
186190
except NodeError:
187-
_LOGGER.error(
188-
"Plugwise device %s removal failed with NodeError", mac
189-
)
191+
_LOGGER.error("Plugwise device %s removal failed with NodeError", mac)
190192
return False
191193

192-
_LOGGER.debug(
193-
"Plugwise device %s successfully removed", mac
194-
)
194+
_LOGGER.debug("Plugwise device %s successfully removed", mac)
195195
return True
196196

197197
return False

0 commit comments

Comments
 (0)