[ci] Run CodSpeed benchmarks when top-level esphome Python modules change (#18114)

This commit is contained in:
J. Nick Koston
2026-08-05 20:50:13 -05:00
committed by GitHub
parent 0fcc2a6ff1
commit a7740091ec
4 changed files with 86 additions and 5 deletions
+29
View File
@@ -2475,6 +2475,35 @@ def test_should_run_benchmarks_core_header_change() -> None:
assert determine_jobs.should_run_benchmarks() is True
def test_should_run_benchmarks_top_level_python_change() -> None:
"""Test benchmarks trigger on top-level esphome Python module changes.
The Python benchmarks exercise config loading, so changes to modules
like config.py and yaml_util.py must run them; a regression in #16718
went unnoticed because these files matched no trigger.
"""
for py_file in [
"esphome/config.py",
"esphome/yaml_util.py",
"esphome/__main__.py",
"esphome/helpers.py",
]:
with patch.object(determine_jobs, "changed_files", return_value=[py_file]):
assert determine_jobs.should_run_benchmarks() is True, (
f"Expected benchmarks to run for {py_file}"
)
def test_should_run_benchmarks_nested_python_change() -> None:
"""Test benchmarks do NOT trigger for nested non-core Python changes."""
with patch.object(
determine_jobs,
"changed_files",
return_value=["esphome/dashboard/web_server.py"],
):
assert determine_jobs.should_run_benchmarks() is False
def test_should_run_benchmarks_host_platform_change() -> None:
"""Test benchmarks trigger on host platform changes.
+21
View File
@@ -1851,3 +1851,24 @@ def test_get_component_test_files_component_without_tests(
)
def test_is_validate_only_file(filename: str, expected: bool, tmp_path: Path) -> None:
assert helpers.is_validate_only_file(tmp_path / filename) is expected
@pytest.mark.parametrize(
("files", "expected"),
[
(["esphome/config.py"], True),
(["esphome/yaml_util.py"], True),
(["esphome/__main__.py"], True),
(["esphome/const.pyi"], True),
(["README.md", "esphome/helpers.py"], True),
(["esphome/core/config.py"], False),
(["esphome/components/sensor/__init__.py"], False),
(["esphome/dashboard/web_server.py"], False),
(["esphome/idf_component.yml"], False),
(["tests/unit_tests/test_config.py"], False),
([], False),
],
)
def test_base_python_changed(files: list[str], expected: bool) -> None:
"""Only Python modules directly in esphome/ count as base Python changes."""
assert helpers.base_python_changed(files) is expected