Skip to content

Re-work pre-commit (without the ci variant)#789

Merged
CoMPaTech merged 9 commits intomainfrom
precommit2
Dec 8, 2024
Merged

Re-work pre-commit (without the ci variant)#789
CoMPaTech merged 9 commits intomainfrom
precommit2

Conversation

@CoMPaTech
Copy link
Member

@CoMPaTech CoMPaTech commented Dec 8, 2024

Back to previous - run in worker

Summary by CodeRabbit

  • New Features

    • Introduced a pre-commit job to enhance code quality checks before preparing the environment.
  • Bug Fixes

    • Updated Python version in pre-commit configuration for improved compatibility.
  • Documentation

    • Removed CI status badges from the README for a cleaner presentation.
    • Added a new section in CHANGELOG to note ongoing improvements in the CI process.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

Walkthrough

The pull request introduces several modifications to the workflow and configuration files. A new job named pre-commit is added to the .github/workflows/test.yml, which runs pre-commit checks before the ha-core-prepare job. The Python version in the ha-core-prepare job is updated to v5.3.0, and the cache action version is updated to v4.2.0. Additionally, the .pre-commit-config.yaml file removes the ci configuration and updates the default Python version to 3.13. The README.md file removes pre-commit CI status badges.

Changes

File Change Summary
.github/workflows/test.yml Added pre-commit job, updated ha-core-prepare to depend on pre-commit, and updated action versions.
.pre-commit-config.yaml Removed ci section and updated default_language_version from python3.11 to python3.13.
README.md Removed pre-commit CI status badges for plugwise-beta and python-plugwise repositories.
CHANGELOG.md Added new section "Ongoing" noting internal adjustments in the CI process.

Possibly related PRs

  • Rework pre-commit prettier to biome #695: This PR modifies the .pre-commit-config.yaml file, which is directly related to the changes made in the main PR that also involves updates to the same configuration file.
  • Downstream from Core Plugwise #728: This PR updates the CHANGELOG.md to include a section about ongoing improvements in the CI process, which aligns with the main PR's focus on enhancing the testing workflow.
  • Improve config_flow coding #736: This PR includes changes to the tests/components/plugwise/test_config_flow.py file, which is relevant as the main PR also involves updates to the testing workflow and pre-commit checks.
  • Python 3.13 #781: This PR updates the Python version in the .github/workflows/test.yml, which is relevant to the main PR's changes that also involve updating the Python setup in the workflow file.

Suggested labels

enhancement, dependencies, downstreaming

Suggested reviewers

  • bouwew

Poem

In the garden of code, where rabbits play,
Pre-commit checks hop in, brightening the day.
With Python updated, our scripts now gleam,
Removing old badges, we streamline the dream.
Hopping along, with joy we declare,
Code quality's shining, with love and with care! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6edd177 and cea6ece.

📒 Files selected for processing (3)
  • .github/workflows/test.yml (2 hunks)
  • .pre-commit-config.yaml (2 hunks)
  • CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🧰 Additional context used
📓 Learnings (1)
.github/workflows/test.yml (2)
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#789
File: .github/workflows/test.yml:0-0
Timestamp: 2024-12-08T11:49:08.792Z
Learning: Python 3.13 is considered stable and acceptable to use as `DEFAULT_PYTHON` in the workflows.
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#789
File: .pre-commit-config.yaml:3-3
Timestamp: 2024-12-08T11:23:47.692Z
Learning: CoMPaTech considers Python 3.13 stable and prefers to use it in the project.
🔇 Additional comments (5)
.github/workflows/test.yml (3)

7-8: LGTM! Environment variables are properly configured.

The cache version bump is appropriate for the workflow changes, and Python 3.13 is confirmed as the desired version.


63-64: LGTM! HA core preparation job is properly updated.

The changes maintain consistency with the pre-commit job and use the latest action versions.

Also applies to: 70-70, 75-75


16-58: LGTM! Pre-commit job is well structured.

The job configuration follows best practices with proper:

  • Action versions
  • Cache configuration
  • Virtual environment handling
  • Pre-commit execution

Let's verify the setup script exists:

✅ Verification successful

Pre-commit job configuration is verified and ready to use

The setup script exists at scripts/setup.sh and has the correct executable permissions, confirming that the workflow will be able to execute it properly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify setup script exists and is executable
if [ -f "scripts/setup.sh" ]; then
  echo "Setup script exists"
  if [ -x "scripts/setup.sh" ]; then
    echo "Setup script is executable"
  else
    echo "Setup script is not executable"
  fi
else
  echo "Setup script not found"
fi

Length of output: 171

.pre-commit-config.yaml (2)

3-3: LGTM! Python version is consistent.

The Python version aligns with the workflow configuration.


76-100: LGTM! Hook renaming improves clarity.

The 'local-' prefix better indicates these are repository-specific hooks. The functionality remains unchanged with proper formatting and configuration.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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 or @coderabbitai title 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.

Copy link
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (1)
.github/workflows/test.yml (1)

65-65: LGTM: Action version updates

Good practice using specific versions. Consider setting up dependabot to automatically update these actions.

Also applies to: 70-70

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 255499e and c4fc344.

📒 Files selected for processing (3)
  • .github/workflows/test.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • README.md (0 hunks)
💤 Files with no reviewable changes (1)
  • README.md
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/test.yml

45-45: property "cache-precommit" is not defined in object type {cache-hacore: {conclusion: string; outcome: string; outputs: {string => string}}; python: {conclusion: string; outcome: string; outputs: {string => string}}}

(expression)

🔇 Additional comments (1)
.github/workflows/test.yml (1)

58-59: LGTM: Correct job dependency

The dependency ensures pre-commit checks run before core preparation.

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
.github/workflows/test.yml (1)

Pull request checks are covered by the hassfest workflow

After reviewing all workflow files, I found that while the pull_request trigger is commented out in test.yml, there is a separate workflow file hassfest.yml that runs on pull requests. This workflow performs validation using Home Assistant's hassfest tool, which is essential for component validation. However, pre-commit checks and core testing are not running on pull requests, which could allow some issues to slip through until the code is pushed.

  • .github/workflows/hassfest.yml: Runs on pull requests, push, workflow_dispatch, and daily schedule
  • .github/workflows/test.yml: Only runs on push and workflow_dispatch
  • .github/workflows/test-beta.yml: Runs on workflow_dispatch and weekly schedule
🔗 Analysis chain

Line range hint 10-13: Verify workflow triggers configuration

The workflow is configured to run on workflow_dispatch and push, but the pull_request trigger is commented out. This means the pre-commit checks won't run automatically on PRs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are other workflows that handle pull requests
rg -l "on:.*pull_request:" .github/workflows/

Length of output: 47


Script:

#!/bin/bash
# Let's check for workflow files and their content to understand the CI setup
fd -e yml -e yaml . .github/workflows/ --exec cat {}

Length of output: 6369

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c4fc344 and 6edd177.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (2 hunks)
🔇 Additional comments (3)
.github/workflows/test.yml (3)

48-51: Well-configured pre-commit execution

Good configuration with --all-files and --show-diff-on-failure flags for comprehensive checking and easy debugging.


57-58: Good practices in job configuration

Positive changes include:

  • Adding dependency on pre-commit job for proper sequencing
  • Using specific action versions (v5.3.0, v4.2.0) instead of major versions
  • Consistent cache configuration between jobs

Also applies to: 64-64, 69-69


44-47: ⚠️ Potential issue

Fix critical issues in pre-commit cache and venv handling

The virtual environment needs to be created before it can be activated, and pre-commit needs to be installed.

 - name: Install pre-commit dependencies
   run: |
+    python -m venv venv
     . venv/bin/activate
+    pip install pre-commit
     pre-commit install-hooks

@CoMPaTech
Copy link
Member Author

Only pre-commit.ci should fail now

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2024

@CoMPaTech CoMPaTech marked this pull request as ready for review December 8, 2024 11:55
@CoMPaTech CoMPaTech requested a review from a team as a code owner December 8, 2024 11:55
@CoMPaTech
Copy link
Member Author

Pre-commit.CI turned off for beta and progress (so the USBs and module are still todo)

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.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants