Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/hassfest.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Validate with hassfest

# Removed push not to duplicate
on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
Expand Down
199 changes: 182 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

pre-commit:
name: Validate pre-commit requirements
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,22 +68,33 @@ 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
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

# 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/[email protected]
- 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/[email protected]
Expand All @@ -75,7 +104,7 @@ jobs:
id: cache-hacore
uses: actions/[email protected]
env:
cache-name: cache-hacore
cache-name: cache-hacore-release
with:
path: ./
key: >-
Expand All @@ -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/[email protected]
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
- name: Check out committed code
uses: actions/[email protected]
- 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/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base HA-core Python ${{ env.DEFAULT_PYTHON }} environment
id: cache-hacore
uses: actions/[email protected]
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ venv
*.orig
node_modules
manual_clone_ha
package-lock.json
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/plugwise/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
)
import voluptuous as vol

from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import (
SOURCE_USER,
ConfigEntry,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/plugwise/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
}
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"sensor",
"switch"
],
"homeassistant": "2024.12.0b2",
"homeassistant": "2025.2.0",
"render_readme": true
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/components/plugwise/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Loading