mirror of
https://github.com/esphome/esphome.git
synced 2025-10-25 05:03:52 +01:00
[ci] Fix clang-tidy split mode for core file changes (#11434)
This commit is contained in:
@@ -43,7 +43,6 @@ from enum import StrEnum
|
||||
from functools import cache
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Any
|
||||
@@ -53,10 +52,13 @@ from helpers import (
|
||||
CPP_FILE_EXTENSIONS,
|
||||
PYTHON_FILE_EXTENSIONS,
|
||||
changed_files,
|
||||
filter_component_files,
|
||||
get_all_dependencies,
|
||||
get_changed_components,
|
||||
get_component_from_path,
|
||||
get_component_test_files,
|
||||
get_components_from_integration_fixtures,
|
||||
get_components_with_dependencies,
|
||||
git_ls_files,
|
||||
parse_test_filename,
|
||||
root_path,
|
||||
@@ -561,16 +563,29 @@ def main() -> None:
|
||||
run_python_linters = should_run_python_linters(args.branch)
|
||||
changed_cpp_file_count = count_changed_cpp_files(args.branch)
|
||||
|
||||
# Get both directly changed and all changed components (with dependencies) in one call
|
||||
script_path = Path(__file__).parent / "list-components.py"
|
||||
cmd = [sys.executable, str(script_path), "--changed-with-deps"]
|
||||
if args.branch:
|
||||
cmd.extend(["-b", args.branch])
|
||||
# Get changed components
|
||||
# get_changed_components() returns:
|
||||
# None: Core files changed (need full scan)
|
||||
# []: No components changed
|
||||
# [list]: Changed components (already includes dependencies)
|
||||
changed_components_result = get_changed_components()
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
||||
component_data = json.loads(result.stdout)
|
||||
directly_changed_components = component_data["directly_changed"]
|
||||
changed_components = component_data["all_changed"]
|
||||
if changed_components_result is None:
|
||||
# Core files changed - will trigger full clang-tidy scan
|
||||
# No specific components to test
|
||||
changed_components = []
|
||||
directly_changed_components = []
|
||||
is_core_change = True
|
||||
else:
|
||||
# Get both directly changed and all changed (with dependencies)
|
||||
changed = changed_files(args.branch)
|
||||
component_files = [f for f in changed if filter_component_files(f)]
|
||||
|
||||
directly_changed_components = get_components_with_dependencies(
|
||||
component_files, False
|
||||
)
|
||||
changed_components = get_components_with_dependencies(component_files, True)
|
||||
is_core_change = False
|
||||
|
||||
# Filter to only components that have test files
|
||||
# Components without tests shouldn't generate CI test jobs
|
||||
@@ -581,11 +596,11 @@ def main() -> None:
|
||||
# Get directly changed components with tests (for isolated testing)
|
||||
# These will be tested WITHOUT --testing-mode in CI to enable full validation
|
||||
# (pin conflicts, etc.) since they contain the actual changes being reviewed
|
||||
directly_changed_with_tests = [
|
||||
directly_changed_with_tests = {
|
||||
component
|
||||
for component in directly_changed_components
|
||||
if _component_has_tests(component)
|
||||
]
|
||||
}
|
||||
|
||||
# Get dependency-only components (for grouped testing)
|
||||
dependency_only_components = [
|
||||
@@ -599,7 +614,8 @@ def main() -> None:
|
||||
|
||||
# Determine clang-tidy mode based on actual files that will be checked
|
||||
if run_clang_tidy:
|
||||
is_full_scan = _is_clang_tidy_full_scan()
|
||||
# Full scan needed if: hash changed OR core files changed
|
||||
is_full_scan = _is_clang_tidy_full_scan() or is_core_change
|
||||
|
||||
if is_full_scan:
|
||||
# Full scan checks all files - always use split mode for efficiency
|
||||
@@ -638,7 +654,7 @@ def main() -> None:
|
||||
"python_linters": run_python_linters,
|
||||
"changed_components": changed_components,
|
||||
"changed_components_with_tests": changed_components_with_tests,
|
||||
"directly_changed_components_with_tests": directly_changed_with_tests,
|
||||
"directly_changed_components_with_tests": list(directly_changed_with_tests),
|
||||
"dependency_only_components_with_tests": dependency_only_components,
|
||||
"component_test_count": len(changed_components_with_tests),
|
||||
"directly_changed_count": len(directly_changed_with_tests),
|
||||
|
||||
Reference in New Issue
Block a user