8000
Skip to content

Fix pre-commit CI failures by skipping local hooks that require virtual environment - #9476

Merged
jesserockz merged 6 commits into
devfrom
precommit_ci
Jul 13, 2025
Merged

Fix pre-commit CI failures by skipping local hooks that require virtual environment#9476
jesserockz merged 6 commits into
devfrom
precommit_ci

Conversation

@bdraco
@bdraco bdraco commented Jul 13, 2025
Copy link
Copy Markdown
Member

What does this implement/fix?

This PR fixes pre-commit CI failures by adding a ci: configuration section to .pre-commit-config.yaml that skips hooks which have compatibility issues with the pre-commit CI environment:

  1. pylint and clang-tidy-hash - These local hooks require a virtual environment which is not available in pre-commit CI
  2. yamllint - Has issues with the special formatting used in .clang-format and .clang-tidy files

The configuration also changes the autoupdate schedule from monthly to weekly to keep dependencies current.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

  • Fixes pre-commit CI pipeline failures

Pull request in esphome-docs with documentation (if applicable):

  • N/A (CI configuration change only)

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# N/A - This is a CI configuration change

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Additional Notes

The error was occurring because pre-commit CI runs in a containerized environment without access to the local virtual environment that script/run-in-env.py expects. By adding the .pre-commit-ci.yaml configuration file with the skip directive, we ensure:

  1. Local developers can still run all hooks including pylint and clang-tidy-hash
  2. Pre-commit CI skips only the problematic local hooks that require virtual environment setup
  3. All other hooks (ruff, flake8, yamllint, clang-format, etc.) continue to run in pre-commit CI

@probot-esphome probot-esphome Bot added the small-pr PR < 30 lines label Jul 13, 2025
@codecov-commenter
codecov-commenter commented Jul 13, 2025
Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.69%. Comparing base (9e002cd) to head (4793ccd).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #9476   +/-   ##
=======================================
  Coverage   59.69%   59.69%           
=======================================
  Files          50       50           
  Lines       10261    10261           
  Branches     1379     1379           
=======================================
  Hits         6125     6125           
  Misses       3777     3777           
  Partials      359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco
bdraco marked this pull request as ready for review July 13, 2025 22:31
Copilot AI review requested due to automatic review settings July 13, 2025 22:31
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a CI configuration block to skip hooks that fail in the containerized pre-commit CI environment and updates the autoupdate settings.

  • Introduces a ci: section in .pre-commit-config.yaml to skip pylint, clang-tidy-hash, and yamllint hooks on CI.
  • Sets the autoupdate commit message and changes the schedule from monthly to weekly.
  • Ensures other hooks continue running unchanged.
Comments suppressed due to low confidence (1)

.pre-commit-config.yaml:7

  • The schedule is set to weekly, but the PR description indicates you intended daily. If daily updates are desired, update this value to daily.
  autoupdate_schedule: weekly

@jesserockz
jesserockz merged commit 5416cee into dev Jul 13, 2025
22 checks passed
@jesserockz
jesserockz deleted the precommit_ci branch July 13, 2025 22:44
@jesserockz jesserockz added this to the 2025.7.0b3 milestone Jul 14, 2025
jesserockz pushed a commit that referenced this pull request Jul 14, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

small-pr PR < 30 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0