1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-21 19:23:45 +01:00
This commit is contained in:
J. Nick Koston
2025-10-17 15:34:17 -10:00
parent 922c2bcd5a
commit 57bf3f968f

View File

@@ -258,9 +258,10 @@ def detect_memory_impact_config(
""" """
# Platform preference order for memory impact analysis # Platform preference order for memory impact analysis
# Prefer ESP8266 for memory impact as it's the most constrained platform # Prefer ESP8266 for memory impact as it's the most constrained platform
# ESP32-IDF is preferred over ESP32-Arduino as it's faster to build and more commonly used
PLATFORM_PREFERENCE = [ PLATFORM_PREFERENCE = [
"esp8266-ard", # ESP8266 Arduino (most memory constrained - best for impact analysis) "esp8266-ard", # ESP8266 Arduino (most memory constrained - best for impact analysis)
"esp32-idf", # Primary ESP32 IDF platform "esp32-idf", # ESP32 IDF platform (primary ESP32 platform, faster builds)
"esp32-c3-idf", # ESP32-C3 IDF "esp32-c3-idf", # ESP32-C3 IDF
"esp32-c6-idf", # ESP32-C6 IDF "esp32-c6-idf", # ESP32-C6 IDF
"esp32-s2-idf", # ESP32-S2 IDF "esp32-s2-idf", # ESP32-S2 IDF
@@ -289,6 +290,7 @@ def detect_memory_impact_config(
# Find components that have tests on the preferred platform # Find components that have tests on the preferred platform
components_with_tests = [] components_with_tests = []
selected_platform = None selected_platform = None
component_platforms = {} # Track which platforms each component has
for component in sorted(changed_component_set): for component in sorted(changed_component_set):
tests_dir = Path(root_path) / "tests" / "components" / component tests_dir = Path(root_path) / "tests" / "components" / component
@@ -301,20 +303,28 @@ def detect_memory_impact_config(
continue continue
# Check if component has tests for any preferred platform # Check if component has tests for any preferred platform
available_platforms = []
for test_file in test_files: for test_file in test_files:
parts = test_file.stem.split(".") parts = test_file.stem.split(".")
if len(parts) < 2: if len(parts) < 2:
continue continue
platform = parts[1] platform = parts[1]
if platform not in PLATFORM_PREFERENCE: if platform in PLATFORM_PREFERENCE:
continue available_platforms.append(platform)
components_with_tests.append(component)
# Select the most preferred platform across all components if not available_platforms:
if selected_platform is None or PLATFORM_PREFERENCE.index( continue
platform
) < PLATFORM_PREFERENCE.index(selected_platform): # Find the most preferred platform for this component
selected_platform = platform component_platform = min(available_platforms, key=PLATFORM_PREFERENCE.index)
break component_platforms[component] = component_platform
components_with_tests.append(component)
# Select the most preferred platform across all components
if selected_platform is None or PLATFORM_PREFERENCE.index(
component_platform
) < PLATFORM_PREFERENCE.index(selected_platform):
selected_platform = component_platform
# If no components have tests, don't run memory impact # If no components have tests, don't run memory impact
if not components_with_tests: if not components_with_tests:
@@ -323,6 +333,13 @@ def detect_memory_impact_config(
# Use the most preferred platform found, or fall back to esp8266-ard # Use the most preferred platform found, or fall back to esp8266-ard
platform = selected_platform or "esp8266-ard" platform = selected_platform or "esp8266-ard"
# Debug output
print("Memory impact analysis:", file=sys.stderr)
print(f" Changed components: {sorted(changed_component_set)}", file=sys.stderr)
print(f" Components with tests: {components_with_tests}", file=sys.stderr)
print(f" Component platforms: {component_platforms}", file=sys.stderr)
print(f" Selected platform: {platform}", file=sys.stderr)
return { return {
"should_run": "true", "should_run": "true",
"components": components_with_tests, "components": components_with_tests,