mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 06:06:33 +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
.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
|
- pydocstyle==5.1.1
|
||||||
files: ^(esphome|tests)/.+\.py$
|
files: ^(esphome|tests)/.+\.py$
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: no-commit-to-branch
|
- id: no-commit-to-branch
|
||||||
args:
|
args:
|
||||||
- --branch=dev
|
- --branch=dev
|
||||||
- --branch=release
|
- --branch=release
|
||||||
- --branch=beta
|
- --branch=beta
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.20.0
|
rev: v3.20.0
|
||||||
hooks:
|
hooks:
|
||||||
@ -43,6 +45,7 @@ repos:
|
|||||||
rev: v1.37.1
|
rev: v1.37.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
|
exclude: ^(\.clang-format|\.clang-tidy)$
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: v13.0.1
|
rev: v13.0.1
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -126,7 +126,8 @@ def write_file_content(path: Path, content: str) -> None:
|
|||||||
def write_hash(hash_value: str) -> None:
|
def write_hash(hash_value: str) -> None:
|
||||||
"""Write hash to file"""
|
"""Write hash to file"""
|
||||||
hash_file = Path(__file__).parent.parent / ".clang-tidy.hash"
|
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:
|
def main() -> None:
|
||||||
|
1
tests/components/animation/.gitattributes
vendored
1
tests/components/animation/.gitattributes
vendored
@ -1,4 +1,3 @@
|
|||||||
*.apng -text
|
*.apng -text
|
||||||
*.webp -text
|
*.webp -text
|
||||||
*.gif -text
|
*.gif -text
|
||||||
|
|
||||||
|
@ -15,4 +15,3 @@ display:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
animation: !include common.yaml
|
animation: !include common.yaml
|
||||||
|
|
||||||
|
@ -21,4 +21,3 @@ binary_sensor:
|
|||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
irk: 1234567890abcdef1234567890abcdef
|
irk: 1234567890abcdef1234567890abcdef
|
||||||
name: "ESP32 BLE Tracker with Identity Resolving Key"
|
name: "ESP32 BLE Tracker with Identity Resolving Key"
|
||||||
|
|
||||||
|
@ -17,4 +17,3 @@ color:
|
|||||||
hex: 008000
|
hex: 008000
|
||||||
- id: cps_blue
|
- id: cps_blue
|
||||||
hex: 000080
|
hex: 000080
|
||||||
|
|
||||||
|
@ -41,4 +41,3 @@ display:
|
|||||||
- delay 120ms
|
- delay 120ms
|
||||||
- [0x29]
|
- [0x29]
|
||||||
- delay 20ms
|
- delay 20ms
|
||||||
|
|
||||||
|
@ -42,4 +42,3 @@ binary_sensor:
|
|||||||
x_max: 480
|
x_max: 480
|
||||||
y_min: 320
|
y_min: 320
|
||||||
y_max: 360
|
y_max: 360
|
||||||
|
|
||||||
|
@ -15,4 +15,3 @@ sensor:
|
|||||||
name: "Loop Time"
|
name: "Loop Time"
|
||||||
cpu_frequency:
|
cpu_frequency:
|
||||||
name: "CPU Frequency"
|
name: "CPU Frequency"
|
||||||
|
|
||||||
|
@ -14,4 +14,3 @@ sensor:
|
|||||||
name: "ENS160 Total Volatile Organic Compounds"
|
name: "ENS160 Total Volatile Organic Compounds"
|
||||||
aqi:
|
aqi:
|
||||||
name: "ENS160 Air Quality Index"
|
name: "ENS160 Air Quality Index"
|
||||||
|
|
||||||
|
@ -9,4 +9,3 @@ esp32:
|
|||||||
wifi:
|
wifi:
|
||||||
ssid: MySSID
|
ssid: MySSID
|
||||||
password: password1
|
password: password1
|
||||||
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
1
tests/components/font/.gitattributes
vendored
1
tests/components/font/.gitattributes
vendored
@ -1,2 +1 @@
|
|||||||
*.pcf -text
|
*.pcf -text
|
||||||
|
|
||||||
|
1
tests/components/lvgl/.gitattributes
vendored
1
tests/components/lvgl/.gitattributes
vendored
@ -1,2 +1 @@
|
|||||||
*.ttf -text
|
*.ttf -text
|
||||||
|
|
||||||
|
@ -56,4 +56,3 @@ lvgl:
|
|||||||
packages:
|
packages:
|
||||||
lvgl: !include lvgl-package.yaml
|
lvgl: !include lvgl-package.yaml
|
||||||
xvgl: !include common.yaml
|
xvgl: !include common.yaml
|
||||||
|
|
||||||
|
@ -3,4 +3,3 @@ substitutions:
|
|||||||
scl_pin: GPIO22
|
scl_pin: GPIO22
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
@ -35,4 +35,3 @@ display:
|
|||||||
allow_other_uses: true
|
allow_other_uses: true
|
||||||
- number: ${enable_pin}
|
- number: ${enable_pin}
|
||||||
bus_mode: single
|
bus_mode: single
|
||||||
|
|
||||||
|
@ -4,4 +4,3 @@ substitutions:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
base: !include common.yaml
|
base: !include common.yaml
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<<: !include common-esp32.yaml
|
<<: !include common-esp32.yaml
|
||||||
|
|
||||||
http_request:
|
http_request:
|
||||||
|
|
||||||
|
@ -11,4 +11,3 @@ openthread:
|
|||||||
pskc: 0xc23a76e98f1a6483639b1ac1271e2e27
|
pskc: 0xc23a76e98f1a6483639b1ac1271e2e27
|
||||||
mesh_local_prefix: fd53:145f:ed22:ad81::/64
|
mesh_local_prefix: fd53:145f:ed22:ad81::/64
|
||||||
force_dataset: true
|
force_dataset: true
|
||||||
|
|
||||||
|
@ -9,4 +9,3 @@ packages:
|
|||||||
file: common.yaml
|
file: common.yaml
|
||||||
ref: dev
|
ref: dev
|
||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
|
@ -11,4 +11,3 @@ packages:
|
|||||||
file: common.yaml
|
file: common.yaml
|
||||||
ref: dev
|
ref: dev
|
||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
|
@ -41,4 +41,3 @@ display:
|
|||||||
- delay 120ms
|
- delay 120ms
|
||||||
- [0x29]
|
- [0x29]
|
||||||
- delay 20ms
|
- delay 20ms
|
||||||
|
|
||||||
|
@ -35,4 +35,3 @@ spi:
|
|||||||
interface: any
|
interface: any
|
||||||
clk_pin: 8
|
clk_pin: 8
|
||||||
mosi_pin: 9
|
mosi_pin: 9
|
||||||
|
|
||||||
|
@ -35,4 +35,3 @@ spi:
|
|||||||
interface: any
|
interface: any
|
||||||
clk_pin: 8
|
clk_pin: 8
|
||||||
mosi_pin: 9
|
mosi_pin: 9
|
||||||
|
|
||||||
|
@ -17,4 +17,3 @@ udp:
|
|||||||
id: my_udp
|
id: my_udp
|
||||||
data: !lambda |-
|
data: !lambda |-
|
||||||
return std::vector<uint8_t>{1,3,4,5,6};
|
return std::vector<uint8_t>{1,3,4,5,6};
|
||||||
|
|
||||||
|
@ -27,4 +27,3 @@ logger:
|
|||||||
logs:
|
logs:
|
||||||
web_server: VERBOSE
|
web_server: VERBOSE
|
||||||
web_server_idf: VERBOSE
|
web_server_idf: VERBOSE
|
||||||
|
|
||||||
|
@ -3,4 +3,3 @@ substitutions:
|
|||||||
sda_pin: GPIO21
|
sda_pin: GPIO21
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
@ -54,4 +54,3 @@ sensor:
|
|||||||
device_id: smart_switch_device
|
device_id: smart_switch_device
|
||||||
lambda: return 4.0;
|
lambda: return 4.0;
|
||||||
update_interval: 0.1s
|
update_interval: 0.1s
|
||||||
|
|
||||||
|
@ -82,4 +82,3 @@ output:
|
|||||||
write_action:
|
write_action:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGD("test", "Light output: %d", state);
|
ESP_LOGD("test", "Light output: %d", state);
|
||||||
|
|
||||||
|
@ -134,4 +134,3 @@ switch:
|
|||||||
name: "Test Switch"
|
name: "Test Switch"
|
||||||
id: test_switch
|
id: test_switch
|
||||||
optimistic: true
|
optimistic: true
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ def test_write_hash() -> None:
|
|||||||
mock_write.assert_called_once()
|
mock_write.assert_called_once()
|
||||||
args = mock_write.call_args[0]
|
args = mock_write.call_args[0]
|
||||||
assert str(args[0]).endswith(".clang-tidy.hash")
|
assert str(args[0]).endswith(".clang-tidy.hash")
|
||||||
assert args[1] == hash_value
|
assert args[1] == hash_value.strip() + "\n"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user