mirror of
https://github.com/esphome/esphome.git
synced 2025-07-25 12:46:42 +00:00
Add pre-commit hooks to fix common formatting issues causing CI failures (#9494)
This commit is contained in:
parent
619e2d69c0
commit
b2a8b0a22f
@ -1 +1 @@
|
||||
a3cdfc378d28b53b416a1d5bf0ab9077ee18867f0d39436ea8013cf5a4ead87a
|
||||
a3cdfc378d28b53b416a1d5bf0ab9077ee18867f0d39436ea8013cf5a4ead87a
|
||||
|
@ -1,4 +1,4 @@
|
||||
[run]
|
||||
omit =
|
||||
omit =
|
||||
esphome/components/*
|
||||
tests/integration/*
|
||||
|
1
.github/workflows/ci-clang-tidy-hash.yml
vendored
1
.github/workflows/ci-clang-tidy-hash.yml
vendored
@ -73,4 +73,3 @@ jobs:
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,15 @@ repos:
|
||||
- pydocstyle==5.1.1
|
||||
files: ^(esphome|tests)/.+\.py$
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.4.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: no-commit-to-branch
|
||||
args:
|
||||
- --branch=dev
|
||||
- --branch=release
|
||||
- --branch=beta
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.20.0
|
||||
hooks:
|
||||
@ -43,6 +45,7 @@ repos:
|
||||
rev: v1.37.1
|
||||
hooks:
|
||||
- id: yamllint
|
||||
exclude: ^(\.clang-format|\.clang-tidy)$
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v13.0.1
|
||||
hooks:
|
||||
|
@ -126,7 +126,8 @@ def write_file_content(path: Path, content: str) -> None:
|
||||
def write_hash(hash_value: str) -> None:
|
||||
"""Write hash to file"""
|
||||
hash_file = Path(__file__).parent.parent / ".clang-tidy.hash"
|
||||
write_file_content(hash_file, hash_value)
|
||||
# Strip any trailing newlines to ensure consistent formatting
|
||||
write_file_content(hash_file, hash_value.strip() + "\n")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
@ -72,7 +72,7 @@ for f in ./tests/components/$target_component/*.*.yaml; do
|
||||
|
||||
if [ "$target_platform" = "all" ] || [ $file_name_parts = 2 ]; then
|
||||
# Test has *not* defined a specific target platform. Need to run tests for all possible target platforms.
|
||||
|
||||
|
||||
for target_platform_file in ./tests/test_build_components/build_components_base.*.yaml; do
|
||||
IFS='/' read -r -a folder_name <<< "$target_platform_file"
|
||||
IFS='.' read -r -a file_name <<< "${folder_name[3]}"
|
||||
@ -83,7 +83,7 @@ for f in ./tests/components/$target_component/*.*.yaml; do
|
||||
|
||||
else
|
||||
# Test has defined a specific target platform.
|
||||
|
||||
|
||||
# Validate we have a base test yaml for selected platform.
|
||||
# The target_platform is sourced from the following location.
|
||||
# 1. `./tests/test_build_components/build_components_base.[target_platform].yaml`
|
||||
|
1
tests/components/animation/.gitattributes
vendored
1
tests/components/animation/.gitattributes
vendored
@ -1,4 +1,3 @@
|
||||
*.apng -text
|
||||
*.webp -text
|
||||
*.gif -text
|
||||
|
||||
|
@ -15,4 +15,3 @@ display:
|
||||
|
||||
packages:
|
||||
animation: !include common.yaml
|
||||
|
||||
|
@ -21,4 +21,3 @@ binary_sensor:
|
||||
- platform: ble_presence
|
||||
irk: 1234567890abcdef1234567890abcdef
|
||||
name: "ESP32 BLE Tracker with Identity Resolving Key"
|
||||
|
||||
|
@ -17,4 +17,3 @@ color:
|
||||
hex: 008000
|
||||
- id: cps_blue
|
||||
hex: 000080
|
||||
|
||||
|
@ -41,4 +41,3 @@ display:
|
||||
- delay 120ms
|
||||
- [0x29]
|
||||
- delay 20ms
|
||||
|
||||
|
@ -42,4 +42,3 @@ binary_sensor:
|
||||
x_max: 480
|
||||
y_min: 320
|
||||
y_max: 360
|
||||
|
||||
|
@ -15,4 +15,3 @@ sensor:
|
||||
name: "Loop Time"
|
||||
cpu_frequency:
|
||||
name: "CPU Frequency"
|
||||
|
||||
|
@ -14,4 +14,3 @@ sensor:
|
||||
name: "ENS160 Total Volatile Organic Compounds"
|
||||
aqi:
|
||||
name: "ENS160 Air Quality Index"
|
||||
|
||||
|
@ -9,4 +9,3 @@ esp32:
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
<<: !include common.yaml
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
<<: !include common.yaml
|
||||
|
||||
|
1
tests/components/font/.gitattributes
vendored
1
tests/components/font/.gitattributes
vendored
@ -1,2 +1 @@
|
||||
*.pcf -text
|
||||
|
||||
|
1
tests/components/lvgl/.gitattributes
vendored
1
tests/components/lvgl/.gitattributes
vendored
@ -1,2 +1 @@
|
||||
*.ttf -text
|
||||
|
||||
|
@ -56,4 +56,3 @@ lvgl:
|
||||
packages:
|
||||
lvgl: !include lvgl-package.yaml
|
||||
xvgl: !include common.yaml
|
||||
|
||||
|
@ -3,4 +3,3 @@ substitutions:
|
||||
scl_pin: GPIO22
|
||||
|
||||
<<: !include common.yaml
|
||||
|
||||
|
@ -35,4 +35,3 @@ display:
|
||||
allow_other_uses: true
|
||||
- number: ${enable_pin}
|
||||
bus_mode: single
|
||||
|
||||
|
@ -4,4 +4,3 @@ substitutions:
|
||||
|
||||
packages:
|
||||
base: !include common.yaml
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
<<: !include common-esp32.yaml
|
||||
|
||||
http_request:
|
||||
|
||||
|
@ -11,4 +11,3 @@ openthread:
|
||||
pskc: 0xc23a76e98f1a6483639b1ac1271e2e27
|
||||
mesh_local_prefix: fd53:145f:ed22:ad81::/64
|
||||
force_dataset: true
|
||||
|
||||
|
@ -9,4 +9,3 @@ packages:
|
||||
file: common.yaml
|
||||
ref: dev
|
||||
refresh: 1d
|
||||
|
||||
|
@ -11,4 +11,3 @@ packages:
|
||||
file: common.yaml
|
||||
ref: dev
|
||||
refresh: 1d
|
||||
|
||||
|
@ -41,4 +41,3 @@ display:
|
||||
- delay 120ms
|
||||
- [0x29]
|
||||
- delay 20ms
|
||||
|
||||
|
@ -35,4 +35,3 @@ spi:
|
||||
interface: any
|
||||
clk_pin: 8
|
||||
mosi_pin: 9
|
||||
|
||||
|
@ -35,4 +35,3 @@ spi:
|
||||
interface: any
|
||||
clk_pin: 8
|
||||
mosi_pin: 9
|
||||
|
||||
|
@ -17,4 +17,3 @@ udp:
|
||||
id: my_udp
|
||||
data: !lambda |-
|
||||
return std::vector<uint8_t>{1,3,4,5,6};
|
||||
|
||||
|
@ -27,4 +27,3 @@ logger:
|
||||
logs:
|
||||
web_server: VERBOSE
|
||||
web_server_idf: VERBOSE
|
||||
|
||||
|
@ -3,4 +3,3 @@ substitutions:
|
||||
sda_pin: GPIO21
|
||||
|
||||
<<: !include common.yaml
|
||||
|
||||
|
@ -54,4 +54,3 @@ sensor:
|
||||
device_id: smart_switch_device
|
||||
lambda: return 4.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
|
@ -82,4 +82,3 @@ output:
|
||||
write_action:
|
||||
- lambda: |-
|
||||
ESP_LOGD("test", "Light output: %d", state);
|
||||
|
||||
|
@ -134,4 +134,3 @@ switch:
|
||||
name: "Test Switch"
|
||||
id: test_switch
|
||||
optimistic: true
|
||||
|
||||
|
@ -158,7 +158,7 @@ def test_write_hash() -> None:
|
||||
mock_write.assert_called_once()
|
||||
args = mock_write.call_args[0]
|
||||
assert str(args[0]).endswith(".clang-tidy.hash")
|
||||
assert args[1] == hash_value
|
||||
assert args[1] == hash_value.strip() + "\n"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -1 +1 @@
|
||||
*.received.yaml
|
||||
*.received.yaml
|
||||
|
Loading…
x
Reference in New Issue
Block a user