diff --git a/.github/actions/bot-ci-failure/analyze_failure.py b/.github/actions/bot-ci-failure/analyze_failure.py index dc0e537d..648e5316 100644 --- a/.github/actions/bot-ci-failure/analyze_failure.py +++ b/.github/actions/bot-ci-failure/analyze_failure.py @@ -391,6 +391,21 @@ def main(): ): print("::warning::Skipping: No failure logs to analyse.", file=sys.stderr) return + if not error_log.strip(): + print("::warning::Skipping: Empty failure logs.", file=sys.stderr) + return + if not tests_failed and not transient_only: + no_failure_patterns = [ + "No failed jobs found", + "Failed jobs found but logs unavailable", + "Could not fetch failed jobs", + ] + if any(p in error_log for p in no_failure_patterns): + print( + "::notice::No CI failures detected; skipping analysis.", + file=sys.stderr, + ) + return # Only fetch the full repository code context when automated tests # actually failed. For QA-only or commit-message failures the code # is not needed and would waste prompt tokens. diff --git a/.github/workflows/reusable-bot-ci-failure.yml b/.github/workflows/reusable-bot-ci-failure.yml index c17dfcc3..d2334b43 100644 --- a/.github/workflows/reusable-bot-ci-failure.yml +++ b/.github/workflows/reusable-bot-ci-failure.yml @@ -183,4 +183,8 @@ jobs: echo "AI analysis produced no output; skipping comment." exit 0 fi + if ! grep -q "##\[error\]" failed_logs.txt 2>/dev/null; then + echo "No CI failures detected; skipping comment." + exit 0 + fi gh pr comment "$PR_NUM" --repo "$REPO" --body-file solution.md