mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
[ci] Remove base bus components exclusion from memory impact analysis (#11572)
This commit is contained in:
@@ -48,7 +48,6 @@ import sys
|
||||
from typing import Any
|
||||
|
||||
from helpers import (
|
||||
BASE_BUS_COMPONENTS,
|
||||
CPP_FILE_EXTENSIONS,
|
||||
PYTHON_FILE_EXTENSIONS,
|
||||
changed_files,
|
||||
@@ -453,7 +452,7 @@ def detect_memory_impact_config(
|
||||
# Get actually changed files (not dependencies)
|
||||
files = changed_files(branch)
|
||||
|
||||
# Find all changed components (excluding core and base bus components)
|
||||
# Find all changed components (excluding core)
|
||||
# Also collect platform hints from platform-specific filenames
|
||||
changed_component_set: set[str] = set()
|
||||
has_core_cpp_changes = False
|
||||
@@ -462,13 +461,13 @@ def detect_memory_impact_config(
|
||||
for file in files:
|
||||
component = get_component_from_path(file)
|
||||
if component:
|
||||
# Skip base bus components as they're used across many builds
|
||||
if component not in BASE_BUS_COMPONENTS:
|
||||
changed_component_set.add(component)
|
||||
# Check if this is a platform-specific file
|
||||
platform_hint = _detect_platform_hint_from_filename(file)
|
||||
if platform_hint:
|
||||
platform_hints.append(platform_hint)
|
||||
# Add all changed components, including base bus components
|
||||
# Base bus components (uart, i2c, spi, etc.) should still be analyzed
|
||||
# when directly changed, even though they're also used as dependencies
|
||||
changed_component_set.add(component)
|
||||
# Check if this is a platform-specific file
|
||||
if platform_hint := _detect_platform_hint_from_filename(file):
|
||||
platform_hints.append(platform_hint)
|
||||
elif file.startswith("esphome/") and file.endswith(CPP_FILE_EXTENSIONS):
|
||||
# Core ESPHome C++ files changed (not component-specific)
|
||||
# Only C++ files affect memory usage
|
||||
|
||||
@@ -849,39 +849,47 @@ def test_detect_memory_impact_config_no_components_with_tests(tmp_path: Path) ->
|
||||
assert result["should_run"] == "false"
|
||||
|
||||
|
||||
def test_detect_memory_impact_config_skips_base_bus_components(tmp_path: Path) -> None:
|
||||
"""Test that base bus components (i2c, spi, uart) are skipped."""
|
||||
def test_detect_memory_impact_config_includes_base_bus_components(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Test that base bus components (i2c, spi, uart) are included when directly changed.
|
||||
|
||||
Base bus components should be analyzed for memory impact when they are directly
|
||||
changed, even though they are often used as dependencies. This ensures that
|
||||
optimizations to base components (like using move semantics or initializer_list)
|
||||
are properly measured.
|
||||
"""
|
||||
# Create test directory structure
|
||||
tests_dir = tmp_path / "tests" / "components"
|
||||
|
||||
# i2c component (should be skipped as it's a base bus component)
|
||||
i2c_dir = tests_dir / "i2c"
|
||||
i2c_dir.mkdir(parents=True)
|
||||
(i2c_dir / "test.esp32-idf.yaml").write_text("test: i2c")
|
||||
# uart component (base bus component that should be included)
|
||||
uart_dir = tests_dir / "uart"
|
||||
uart_dir.mkdir(parents=True)
|
||||
(uart_dir / "test.esp32-idf.yaml").write_text("test: uart")
|
||||
|
||||
# wifi component (should not be skipped)
|
||||
# wifi component (regular component)
|
||||
wifi_dir = tests_dir / "wifi"
|
||||
wifi_dir.mkdir(parents=True)
|
||||
(wifi_dir / "test.esp32-idf.yaml").write_text("test: wifi")
|
||||
|
||||
# Mock changed_files to return both i2c and wifi
|
||||
# Mock changed_files to return both uart and wifi
|
||||
with (
|
||||
patch.object(determine_jobs, "root_path", str(tmp_path)),
|
||||
patch.object(helpers, "root_path", str(tmp_path)),
|
||||
patch.object(determine_jobs, "changed_files") as mock_changed_files,
|
||||
):
|
||||
mock_changed_files.return_value = [
|
||||
"esphome/components/i2c/i2c.cpp",
|
||||
"esphome/components/uart/automation.h", # Header file with inline code
|
||||
"esphome/components/wifi/wifi.cpp",
|
||||
]
|
||||
determine_jobs._component_has_tests.cache_clear()
|
||||
|
||||
result = determine_jobs.detect_memory_impact_config()
|
||||
|
||||
# Should only include wifi, not i2c
|
||||
# Should include both uart and wifi
|
||||
assert result["should_run"] == "true"
|
||||
assert result["components"] == ["wifi"]
|
||||
assert "i2c" not in result["components"]
|
||||
assert set(result["components"]) == {"uart", "wifi"}
|
||||
assert result["platform"] == "esp32-idf" # Common platform
|
||||
|
||||
|
||||
def test_detect_memory_impact_config_with_variant_tests(tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user