Skip to content

Conversation

@CoMPaTech
Copy link
Member

@CoMPaTech CoMPaTech commented Jun 21, 2025

  • Deprecating pre-commit.ci
  • Reverting fully (instead of partially) to custom_component testing
    • This is also helpful for testing against stable and dev releases (which custom_component testing can't)
  • Re-aligning scripts and names
  • Updating core-testing from plugwise-beta
  • Preparing approach for split testing (not in this PR)

Summary by CodeRabbit

  • Chores

    • Updated and streamlined continuous integration workflows with refined triggers, caching, and job separation for enhanced efficiency.
    • Removed redundant setup and testing scripts to simplify project maintenance.
    • Modernized project metadata, linting, and testing configurations with expanded rules and integrations.
    • Updated dependencies and removed unnecessary testing packages.
    • Added maintenance notes to the changelog.
  • Refactor

    • Enhanced testing scripts with colorized output and parameterized component naming for better usability and maintainability.
    • Cleaned up import paths and formatting in code and test files to improve consistency.
  • Style

    • Reformatted code and scripts for improved readability and uniformity.

@CoMPaTech CoMPaTech self-assigned this Jun 21, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 21, 2025

Walkthrough

This update restructures CI workflows, enhances and consolidates linting and testing configurations, and refactors scripts for better maintainability and feedback. Several setup and test scripts are removed or replaced by a unified approach. Import paths in tests are updated, and project metadata is expanded. Minor formatting improvements are made in component code.

Changes

File(s) Change Summary
.github/workflows/test.yml Workflow restructured: improved caching, refined triggers, new jobs for cache, prepare, and release; job dependencies and env vars updated.
scripts/core-testing.sh Refactored: added color output, introduced REPO_NAME variable, unified env setup, updated tooling usage, improved maintainability.
scripts/python-venv.sh
scripts/setup.sh
scripts/setup_test.sh
scripts/tests_and_coverage.sh
Deleted: legacy setup and test scripts removed in favor of unified approach in core-testing.sh.
pyproject.toml Major update: expanded metadata, overhauled linting/testing config, integrated plugins, detailed ruff/pylint/pytest/isort settings.
.pre-commit-config.yaml Removed pre-commit.ci config section; updated biome-lint dependency version.
requirements_test.txt Removed pytest-homeassistant-custom-component from test dependencies.
CHANGELOG.md Added "Ongoing" section noting CI maintenance chores.
custom_components/plugwise_usb/init.py Refactored imports, improved logging formatting, no logic changes.
tests/components/plugwise_usb/conftest.py
tests/components/plugwise_usb/test_config_flow.py
Updated import paths from custom_components to homeassistant.components; minor fixture refactor.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub as GitHub Actions
    participant Cache as Cache Job
    participant Prepare as Prepare Job
    participant Release as HA-Core Release Job
    participant Script as core-testing.sh

    GitHub->>Cache: Trigger on PR events
    Cache-->>Prepare: Provide cache key/env
    Prepare-->>Release: Python env & pre-commit setup
    Release->>Script: Run core-testing.sh
    Script->>Release: Test results & status
Loading

Possibly related PRs

Suggested labels

documentation

Suggested reviewers

  • dirixmjm

Poem

In the warren where scripts once grew,
The rabbits have pruned and colored anew.
With caches and colors, the workflow hops,
Old scripts retired, new testing never stops.
Imports aligned, the garden neat—
CI carrots abound, what a treat! 🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
custom_components/plugwise_usb/__init__.py
tests/components/plugwise_usb/conftest.py
tests/components/plugwise_usb/test_config_flow.py

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adae7e2 and 0fa466f.

📒 Files selected for processing (13)
  • .github/workflows/test.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • custom_components/plugwise_usb/__init__.py (4 hunks)
  • pyproject.toml (2 hunks)
  • requirements_test.txt (0 hunks)
  • scripts/core-testing.sh (8 hunks)
  • scripts/python-venv.sh (0 hunks)
  • scripts/setup.sh (0 hunks)
  • scripts/setup_test.sh (0 hunks)
  • scripts/tests_and_coverage.sh (0 hunks)
  • tests/components/plugwise_usb/conftest.py (2 hunks)
  • tests/components/plugwise_usb/test_config_flow.py (1 hunks)
💤 Files with no reviewable changes (5)
  • requirements_test.txt
  • scripts/setup.sh
  • scripts/tests_and_coverage.sh
  • scripts/python-venv.sh
  • scripts/setup_test.sh
🚧 Files skipped from review as they are similar to previous changes (8)
  • .pre-commit-config.yaml
  • CHANGELOG.md
  • custom_components/plugwise_usb/init.py
  • tests/components/plugwise_usb/test_config_flow.py
  • tests/components/plugwise_usb/conftest.py
  • pyproject.toml
  • scripts/core-testing.sh
  • .github/workflows/test.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Prepare
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link

coderabbitai bot commented Jun 21, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CoMPaTech CoMPaTech marked this pull request as ready for review June 21, 2025 12:15
@CoMPaTech CoMPaTech requested a review from a team as a code owner June 21, 2025 12:15
@CoMPaTech CoMPaTech marked this pull request as draft June 21, 2025 12:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (8)
pyproject.toml (2)

30-31: Consider refining the Homepage URL
The “Homepage” entry points to the organization root. It may be clearer to link directly to this repository instead of the generic org page.


34-35: Keep the update notice in sync
The comment reminds contributors to port pylint ini options. Ensure it remains accurate when modifying this section in the future.

CHANGELOG.md (1)

5-7: Replace “Ongoing” with “Unreleased”
Adopting a standard “## [Unreleased]” section can improve clarity and align with common changelog conventions.

requirements_test.txt (1)

6-6: Pin direct-URL dependency carefully
The plugwise-usb URL is hard-pinned to 0.44.1. Ensure this is updated whenever the package version in manifest.json or pyproject.toml changes.

scripts/core-testing.sh (4)

10-12: Fix spelling in comment
betweehbetween in the repository-name comment to maintain professionalism.


48-50: Consider using command -v over which
command -v git and command -v jq are more portable than which.


52-54: Update outdated comment
The reference to python-plugwise is no longer accurate; adjust to describe the venv seed purpose for HA-core testing.


66-68: Remove redundant set -e
set -e is already in effect at the top of the script. Duplicate invocations can be removed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de5e546 and e3b12a5.

📒 Files selected for processing (14)
  • .github/actions/restore-venv/action.yml (1 hunks)
  • .github/workflows/test.yml (2 hunks)
  • .pre-commit-config.yaml (0 hunks)
  • CHANGELOG.md (1 hunks)
  • custom_components/plugwise_usb/__init__.py (4 hunks)
  • pyproject.toml (2 hunks)
  • requirements_test.txt (1 hunks)
  • scripts/core-testing.sh (7 hunks)
  • scripts/python-venv.sh (0 hunks)
  • scripts/setup.sh (0 hunks)
  • scripts/setup_test.sh (0 hunks)
  • scripts/tests_and_coverage.sh (0 hunks)
  • tests/components/plugwise_usb/conftest.py (2 hunks)
  • tests/components/plugwise_usb/test_config_flow.py (1 hunks)
💤 Files with no reviewable changes (5)
  • scripts/tests_and_coverage.sh
  • scripts/setup.sh
  • scripts/python-venv.sh
  • scripts/setup_test.sh
  • .pre-commit-config.yaml
🔇 Additional comments (31)
pyproject.toml (6)

22-25: Review classifiers update
Classifiers correctly specify Python 3.13, OS independence, and Topic “Home Automation,” matching the project’s scope.


42-51: Verify the Pylint init-hook path resolution
The init-hook dynamically locates default config files and appends a pylint/plugins directory. Confirm this resolves as expected in CI and local environments.


53-64: Pylint plugins loading
Loading Home Assistant–specific pylint plugins alongside core extensions makes sense. No collisions detected with Ruff’s linting scope.


67-73: Extension package allow-list
The list covers key native extensions. Double-check that this list is complete and up-to-date against your dependencies.


74-75: fail-on set to "I"
Failing on all informational messages (I) may be too strict. Verify this is intentional and doesn’t block routine development.


377-384: Pytest configuration
Test paths, logging format, and asyncio settings align with CI requirements. Asyncio “auto” mode should work—confirm no test regressions occurred.

tests/components/plugwise_usb/test_config_flow.py (1)

7-14: Imports updated for new integration path
Switching imports to homeassistant.components.plugwise_usb and tests.common.MockConfigEntry aligns with the refactored namespace. Import order also respects our isort settings.

tests/components/plugwise_usb/conftest.py (5)

9-9: Approve library exception import
Importing StickError directly from the plugwise_usb package ensures tests mock the correct underlying exception type.


12-12: Approve updated HA import path
Switching to homeassistant.components.plugwise_usb aligns with the integration’s new namespace in HA core.


15-15: Approve test utility import
Using tests.common.MockConfigEntry is correct now that the pytest-homeassistant-custom-component dependency has been removed.


18-18: Approve mock target string update
Updating STICK_IMPORT_MOCK to "homeassistant.components.plugwise_usb.config_flow.Stick" matches the relocated config flow module.


24-28: Verify patched setup entry path
The fixture now patches homeassistant.components.plugwise_usb.async_setup_entry. Confirm there are no remaining calls to the old custom_components path.

custom_components/plugwise_usb/__init__.py (4)

7-10: Approve import reordering
Grouping third-party plugwise_usb imports above Home Assistant imports follows PEP8 and improves readability.


55-60: Approve Stick instantiation cleanup
Removing the trailing type-ignore comment has no functional impact and keeps the code clean.


152-156: Approve service registration formatting
Reformatting the disable_production service registration to multi-line enhances clarity without altering behavior.


206-210: Approve consolidated logging calls
Converting the multi-line logger calls in async_remove_config_entry_device to single-line is purely stylistic and retains full context.

.github/workflows/test.yml (7)

7-10: Approve new environment variables
Adding CACHE_VERSION, PRE_COMMIT_HOME, and VENV supports the new restore-venv action and pre-commit caching.


12-19: Approve trigger documentation comments
Documenting the rationale for disabling push and workflow_dispatch improves maintainability.


21-27: Approve pull_request triggers
Restricting the workflow to PR events (opened, synchronize, labeled, unlabeled) aligns with label-based CI gating.


29-35: Approve cache job setup
The new cache job correctly computes a key based on OS, Python version, and file hashes for efficient venv reuse.


61-69: Approve restore-venv integration in prepare job
Using the custom .github/actions/restore-venv action here cleanly handles environment setup and cache restoration.


85-92: Approve restore-venv in ha-core-release job
Mirroring the cache reuse logic across both jobs ensures consistent setup for HA-core tests.


96-100: Approve core-testing invocation
Running scripts/core-testing.sh with GITHUB_ACTIONS="" and capturing the exit code is the correct pattern for this consolidated test script.

scripts/core-testing.sh (8)

4-9: Approve color code definitions
Defining CNORM, CFAIL, CINFO, and CWARN at the top enhances output readability.


25-25: Approve branch echo
Echoing the selected HA-core branch with color is a clear and useful diagnostic.


43-43: Approve pip_packages list
Centralizing required test deps in pip_packages remains a valid approach for selective module installation.


46-46: Approve preparatory echo
Printing a setup message with color cues helps trace the process in CI logs.


69-77: Approve venv bootstrap block
The in-script venv creation and activation logic imported from HA-core is well structured.


79-82: Approve uv installation fallback
Ensuring uv is present before using it maintains compatibility.


84-89: Approve pre-commit setup
Installing and enabling the pre-commit hook at runtime supports local development workflows.


91-91: Approve set +u usage
Disabling undefined-variable errors here is necessary for optional script arguments.

@CoMPaTech CoMPaTech marked this pull request as ready for review June 21, 2025 14:12
@CoMPaTech
Copy link
Member Author

@coderabbitai summary
@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jun 21, 2025

Tip

For best results, initiate chat on the files or code changes.

@CoMPaTech, here's the summary and review you requested:

Summary

This PR represents a comprehensive refactoring that reverts from custom component testing to testing against Home Assistant core, enabling testing against both stable and development releases. The key changes include:

🔄 CI/CD Restructuring:

  • Redesigned GitHub Actions workflow with improved caching strategy
  • New job structure: cacheprepareha-core-release
  • Refined trigger conditions focusing on PR events

🧹 Script Consolidation:

  • Unified testing approach via enhanced core-testing.sh
  • Removed 4 legacy scripts (python-venv.sh, setup.sh, setup_test.sh, tests_and_coverage.sh)
  • Added colorized output and parameterized component name (REPO_NAME)

⚙️ Configuration Overhaul:

  • Major pyproject.toml update with comprehensive linting/testing rules
  • Removed pre-commit.ci configuration
  • Updated test dependencies

📦 Namespace Alignment:

  • Import paths changed from custom_components.plugwise_usb to homeassistant.components.plugwise_usb
  • Aligns with Home Assistant core structure

Review

✅ Strengths:

  • Well-coordinated refactoring: All changes work together cohesively toward the stated goal
  • Improved maintainability: Script parameterization with REPO_NAME and unified approach
  • Enhanced user experience: Colorized script output provides better feedback
  • Comprehensive testing setup: Detailed linting rules and pytest configuration
  • Efficient caching: New workflow structure should improve CI performance

⚠️ Considerations:

  • Breaking change scope: This fundamentally alters the testing approach - ensure team alignment
  • Documentation gap: Consider updating README/docs to reflect the new testing methodology
  • Dependency management: Verify all required packages are properly specified after removing pytest-homeassistant-custom-component

🔍 Technical Implementation:

  • The workflow job dependencies are properly structured
  • Script error handling appears robust with explicit exit codes
  • Import path updates are consistent across test files
  • Configuration changes follow modern Python tooling best practices

This refactoring successfully achieves its objective of enabling dual testing against HA releases while modernizing the development workflow. The implementation quality is high and the changes appear production-ready.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (14)
.github/workflows/test.yml (3)

12-12: Clarify trigger comment
The note about disabling push and workflow_dispatch triggers is useful. Consider documenting how to manually invoke the workflow (e.g., via gh workflow run) or adding a README section.


29-34: Pin action versions for stability
Using floating tags like actions/checkout@v4 and actions/setup-python@v5 will automatically pick up minor/patch updates. To avoid unexpected breakages, consider pinning to a specific minor version (e.g., @v4.6.0).


63-68: Consolidate HA-core setup invocation
You invoke core-testing.sh twice: once via run-command in restore-venv and again in a separate step with GITHUB_ACTIONS="" scripts/core-testing.sh. This duplicates setup logic. Consider a single, explicit call to the script to streamline the job.

Also applies to: 81-86

scripts/core-testing.sh (11)

4-11: Fix typo in REPO_NAME comment
Line 10 comment reads “betweeh” and is missing a closing parenthesis. Update to:

# Repository name (for reuse between plugwise network and usb)

4-9: Improve terminal color handling
Hardcoded ANSI codes can break in non-TTY environments. Consider detecting color support (tput) or provide a --no-color flag to disable escapes when piping/logging.


25-25: Quote branch echo for safety
On line 25 you do echo -e "${CINFO}Working on HA-core branch ${core_branch}${CNORM}". Wrap ${core_branch} in quotes to avoid word splitting if it ever contains spaces.


43-43: Manage pip_packages dynamically
The pip_packages regex is hardcoded. This can drift from requirements_test_all.txt. Consider deriving this list programmatically from the component’s manifest or a config file.


46-51: Add checks for Python and pip
You verify git and jq, but the script also assumes python3 and pip/uv. Add tools checks (which python3, which pip3) to fail early if Python isn’t installed.


85-89: Pin pre-commit version
uv pip install --upgrade pre-commit may pull a breaking release. Pin to a tested version via requirements_test.txt or specify it in this command.


99-101: Improve argument parsing
Parsing $1/$2 with manual checks is brittle. Consider using getopts or a case statement for clear handling of core_prep, pip_prep, testing, and quality modes.


183-185: Use official bootstrap script directly
Parsing script/bootstrap via grep | sed is brittle. Invoke script/bootstrap with a --no-dev or --deps flag directly if available, or centralize bootstrap arguments.


188-196: Quote rm and cp paths
Lines removing and copying component directories should quote paths to safely handle special characters or spaces:

rm -rf "homeassistant/components/${REPO_NAME}" "tests/components/${REPO_NAME}"
cp -r "../custom_components/${REPO_NAME}" "./homeassistant/components/"

212-224: Streamline pip installs
You run multiple uv pip install commands for extras, basics, and module. Combine into a single pip install -r or use a constraints file to speed up setup and reduce redundancy.

Also applies to: 229-231


238-249: Simplify pytest invocation
Instead of manually capturing EXIT_CODE and re-exiting, rely on set -e to fail fast on test errors. Remove set +e and explicit exit $EXIT_CODE for clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8542b8d and 7328cfb.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • scripts/core-testing.sh (9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup for HA-core (release/master)
🔇 Additional comments (6)
.github/workflows/test.yml (4)

7-10: Ensure VENV and PRE_COMMIT_HOME align with scripts
You’ve added CACHE_VERSION, PRE_COMMIT_HOME, and VENV env vars for caching and venv layout. Confirm these values (venv, ~/.cache/pre-commit) exactly match the expectations in prepare-python-and-code and in core-testing.sh.


21-26: Review removal of manual and scheduled triggers
Restricting to pull_request events (opened, synchronize, labeled, unlabeled) removes ability to run on push or via dispatch. Ensure this matches your team’s needs, or re-enable workflow_dispatch/schedule if manual or nightly runs are required.


37-45: Validate cache key inputs
The cache key hashes pyproject.toml, requirements_test.txt, and .pre-commit-config.yaml. Since dependencies now live in pyproject.toml, ensure requirements_test.txt and the pre-commit config still exist and drive the cache. Update if paths or filenames changed.


49-55: Confirm inputs for prepare-python-and-code action
The plugwise/gh-actions/prepare-python-and-code@v1 action receives cache-key, fail-on-miss, python-version, venv-dir, and precommit-home. Validate that these map correctly to the action’s inputs after your refactoring.

scripts/core-testing.sh (2)

255-273: Document skipped linters
You skip pylint and mypy (lines 265 & 268). If intentional, add comments explaining why (e.g., awaiting core-level support). Otherwise, re-enable them to catch issues early.


279-295: Verify local vs CI paths
The block under if [ -z "${GITHUB_ACTIONS}" ] copies files back and runs hassfest. Make sure local dev workflows still function as expected; consider a --local flag or document this behavior.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (4)
scripts/core-testing.sh (4)

67-77: DRY up virtualenv setup
You still have duplicated venv creation logic here and later at lines 169–177. Extract into a function (e.g., ensure_venv) to centralize and reduce repetition.


164-164: Avoid writing into .git directory
Writing ${REPO_NAME}-tracking inside .git/ still persists here. As flagged earlier, move tracking files to a separate directory (e.g., .ha_tracking/) outside of Git metadata.


169-177: DRY up virtualenv setup (duplicate)
This block duplicates the environment setup at lines 67–77. Consolidate into one ensure_venv function.


179-181: DRY up uv installation (duplicate)
This UV presence check is redundant given the block at lines 79–82. Merge these checks in one place.

🧹 Nitpick comments (4)
.github/workflows/test.yml (1)

29-32: Refine cache job naming
The job name “Cache identify” is a bit misleading. Consider renaming to something like “Determine cache key” for clarity:

- name: Cache identify
+ name: Determine cache key
scripts/core-testing.sh (3)

10-12: Fix typo in repository comment
Correct the misspelling “betweeh” and close the parenthesis:

- # Repository name (for reuse betweeh plugwise network and usb
+ # Repository name (for reuse between plugwise network and usb)

79-82: DRY up uv installation
Similar UV installation logic appears twice (here and lines 179–181). Consolidate into a reusable function after extracting the venv logic.


188-195: Simplify component cleanup
Instead of rm -r ... || echo, consider using rm -rf to remove without errors:

- rm -r homeassistant/components/${REPO_NAME} tests/components/${REPO_NAME} || echo -e "${CWARN}already clean${CNORM}"
+ rm -rf homeassistant/components/${REPO_NAME} tests/components/${REPO_NAME}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7328cfb and 3affbec.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • scripts/core-testing.sh (8 hunks)
🔇 Additional comments (29)
.github/workflows/test.yml (11)

7-10: Validate DEFAULT_PYTHON version compatibility
You’re pinning DEFAULT_PYTHON to “3.13”. Please confirm that actions/setup-python@v5 (and any downstream dependencies) fully supports Python 3.13 today.


12-19: Skip: Informational comment on trigger disabling
These commented suggestions for handling PR labels don’t need changes in this PR.


21-27: Approved pull_request-only triggers
Restricting to pull_request events aligns with the new testing workflow.


37-40: Approved action version updates
Using actions/checkout@v4 and actions/setup-python@v5 is up-to-date and appropriate.


47-50: Cache preparation configuration looks good
Restoring the environment in a separate prepare job with fail-on-miss: false is smart.


53-59: Approved usage of prepare-python-and-code action
Parameterization with cache-key, venv-dir, and clone-core is clear and maintainable.


62-62: Approved clone-core flag
Explicitly enabling clone-core: "true" ensures we fetch the HA core.


64-66: Approved ha-core-release job definition
Splitting out ha-core-release with explicit dependencies is clear.


69-71: Approved job dependencies
Chaining ha-core-release on both cache and prepare is correct.


75-82: Approved cache restoration
Leveraging plugwise/gh-actions/restore-venv@v1 with pinned versions and inputs is consistent.


85-88: Skip: core-testing.sh invocation
The set +e combined with manual exit code propagation is intentional for better error reporting.

scripts/core-testing.sh (18)

4-9: Skip: Color definitions
ANSI color codes are valid and improve readability.


25-25: Skip: Branch info echo
The informational message correctly reflects core_branch.


43-43: Skip: pip_packages list
The list of test dependencies appears comprehensive.


46-51: Skip: Tool presence checks
Verifying git and jq upfront is appropriate.


114-121: Skip: Core reset logs
The colored logging for resetting and rebasing HA core is clear.


183-186: Skip: HA-core bootstrap pip
Using HA-core’s bootstrap script pip extraction is valid.


203-209: Skip: Translation setup
Running script.translations quietly is fine.


212-223: Skip: Pip modules installation
The staged installation of HA requirements and extras looks correct.


226-231: Skip: Manifest dependency install
Extracting and installing the required module from manifest.json via jq is concise.


238-244: Skip: Test commencement log
The debug parameter injection is clear and functional.


249-249: Skip: Pytest invocation
The pytest command with coverage and snapshot flags is appropriate.


255-263: Skip: Ruff autofix steps
Running ruff --fix on both component and tests is a good balance of automation and permission to overwrite.


265-271: Skip: Skipping pylint and mypy
Explicitly disabling these is intentional to speed up CI.


272-273: Skip: Markdown linting
Running markdownlint via pre-commit is fine.


281-286: Skip: Copy-back and manifest cleanup
This section only runs outside GitHub Actions; the logic is sound.


293-299: Skip: Hassfest requirement patching
The jq and sed operations for manifest adjustments are correct.


303-305: Skip: Hassfest validation
Running script.hassfest in GH Actions covers core validation.


314-320: Skip: Local commit-check block
The pre-commit gating for local runs is intentional for developer workflow.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/test.yml (1)

37-49: Remove outdated file from cache key
You’re still hashing .pre-commit-config.yaml in your cache key, but that file was removed in this PR. Please update the hashFiles() call to only include existing files.

🧹 Nitpick comments (3)
.github/workflows/test.yml (3)

12-18: Remove or relocate commented workaround
The block of commented-out curl steps clutters the workflow. If it’s no longer needed, remove it; otherwise, document it in a maintenance guide or README.


29-35: Consider clarifying cache job name
The job key is cache with a step name "Cache identify". For readability, you might rename the job or step to "Determine cache key" to better communicate its intent.


94-100: Pin ShellCheck action to a stable version
Using ludeeus/action-shellcheck@master risks breaking the build if the action’s default branch changes. Pin to a specific release tag or SHA for reproducibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83e1de4 and 1f1ccce.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .pre-commit-config.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup for HA-core (release/master)
🔇 Additional comments (5)
.github/workflows/test.yml (5)

4-4: Workflow name is clear
Naming the workflow as "Test against HA-core" accurately reflects its purpose.


7-10: Validate environment variables against HA requirements
Ensure that DEFAULT_PYTHON (3.13) aligns with the Home Assistant versions you intend to test, and that PRE_COMMIT_HOME and VENV paths are correct across all runners.


21-26: Restricting triggers to PR events is intentional
Limiting the workflow to specific pull request types (opened, synchronize, labeled, unlabeled) matches the desired behavior. No concerns here.


50-66: Prepare job setup looks good
Using plugwise/gh-actions/prepare-python-and-code@v1 with fail-on-miss: false elegantly handles cache misses. The inputs are clear.


68-92: Clarify the GITHUB_ACTIONS workaround
The line GITHUB_ACTIONS="" scripts/core-testing.sh works around GH Actions detection, but it would help future maintainers to add a brief comment explaining why this is necessary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
.github/workflows/test.yml (1)

46-49: Remove stale pre-commit config from cache key
You’re hashing .pre-commit-config.yaml which was removed in this PR, breaking the cache key computation.

Apply this diff:

- 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"
+ run: echo "cache-key=${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', 'ha_pyproject.toml') }}" >> "$GITHUB_OUTPUT"
pyproject.toml (1)

387-389: Coverage source mismatch with package directory
The [tool.coverage.run] source is set to "plugwise_usb-beta", but your package directory is plugwise_usb, so coverage won’t be collected.

Apply this diff:

- source = ["plugwise_usb-beta"]
+ source = ["plugwise_usb"]
scripts/core-testing.sh (1)

164-165: Avoid writing into .git directory
Writing tracking files under .git/ can corrupt Git metadata and will be ignored. Store trackers in a separate directory, for example .ha_tracking, outside of .git.

- git log -1 | head -1 > "${coredir}/.git/${REPO_NAME}-tracking"
+ mkdir -p "${coredir}/.ha_tracking"
+ git log -1 | head -1 > "${coredir}/.ha_tracking/${REPO_NAME}-tracking"
🧹 Nitpick comments (2)
scripts/core-testing.sh (2)

10-11: Fix typo in comment
There's a typo in the repository name comment (betweehbetween).

- # Repository name (for reuse betweeh plugwise network and usb
+ # Repository name (for reuse between Plugwise network and USB)

67-77: DRY up virtual environment setup
The venv creation and activation logic is duplicated in two places. Extract it into a function (e.g., ensure_venv) to centralize and reduce code duplication.

Also applies to: 168-176

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f1ccce and adae7e2.

📒 Files selected for processing (13)
  • .github/workflows/test.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • custom_components/plugwise_usb/__init__.py (4 hunks)
  • pyproject.toml (2 hunks)
  • requirements_test.txt (1 hunks)
  • scripts/core-testing.sh (8 hunks)
  • scripts/python-venv.sh (0 hunks)
  • scripts/setup.sh (0 hunks)
  • scripts/setup_test.sh (0 hunks)
  • scripts/tests_and_coverage.sh (0 hunks)
  • tests/components/plugwise_usb/conftest.py (2 hunks)
  • tests/components/plugwise_usb/test_config_flow.py (1 hunks)
💤 Files with no reviewable changes (4)
  • scripts/setup.sh
  • scripts/tests_and_coverage.sh
  • scripts/setup_test.sh
  • scripts/python-venv.sh
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • requirements_test.txt
  • tests/components/plugwise_usb/test_config_flow.py
  • .pre-commit-config.yaml
  • tests/components/plugwise_usb/conftest.py
  • custom_components/plugwise_usb/init.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Prepare

Copy link
Contributor

@bouwew bouwew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's working well when testing locally, nice job @CoMPaTech !

@sonarqubecloud
Copy link

Copy link
Contributor

@ArnoutD ArnoutD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current way of announced breaking changes and the fact that the dev version might break instead of apply'ing to the beta's which are coming through in pytest-homeassistant-custom-component the added amount of boiler plate is not worth the trouble. Testing is a lot easier and faster using the package and the required local disc space for development is smaller.

but I am still going to approve the change

@CoMPaTech
Copy link
Member Author

Duly noted @ArnoutD - as discussed on discord I'll follow-up with a split CI and pre-commit suggestion reinstating pytest custom component

@CoMPaTech CoMPaTech merged commit b853f17 into main Jun 23, 2025
10 checks passed
@CoMPaTech CoMPaTech deleted the cifix3 branch June 23, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants