1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

[CI] Fix CI job failures for PRs with >300 changed files (#10215)

This commit is contained in:
J. Nick Koston
2025-08-12 22:46:56 -05:00
committed by Jesse Hills
parent 6b7ced1970
commit 68ddd98f5f
2 changed files with 72 additions and 2 deletions

View File

@@ -139,9 +139,24 @@ def _get_changed_files_github_actions() -> list[str] | None:
if event_name == "pull_request":
pr_number = _get_pr_number_from_github_env()
if pr_number:
# Use GitHub CLI to get changed files directly
# Try gh pr diff first (faster for small PRs)
cmd = ["gh", "pr", "diff", pr_number, "--name-only"]
return _get_changed_files_from_command(cmd)
try:
return _get_changed_files_from_command(cmd)
except Exception as e:
# If it fails due to the 300 file limit, use the API method
if "maximum" in str(e) and "files" in str(e):
cmd = [
"gh",
"api",
f"repos/esphome/esphome/pulls/{pr_number}/files",
"--paginate",
"--jq",
".[].filename",
]
return _get_changed_files_from_command(cmd)
# Re-raise for other errors
raise
# For pushes (including squash-and-merge)
elif event_name == "push":