Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CI] [GHA] Pre-download logs for failed jobs in CI Doctor (#36618)

Andrei Kashchikhinc431defad4fb
diff --git a/.github/workflows/ci-doctor-mq.lock.yml b/.github/workflows/ci-doctor-mq.lock.yml
index 91785aff3e6..bac558902a8 100644
--- a/.github/workflows/ci-doctor-mq.lock.yml
+++ b/.github/workflows/ci-doctor-mq.lock.yml
@@ -1,4 +1,4 @@
-# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"23f872c6f93afc55589d23d58643af25c69d7d53c070e7238aa197b9d0fce1b1","body_hash":"9ae9e887a00565c9cbd695bca7158ba4d4d0c3776297b463c79cdf7231e7bba7","compiler_version":"v0.80.9","strict":true,"agent_id":"copilot","agent_model":"claude-sonnet-4.6","engine_versions":{"copilot":"1.0.63"}}
+# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"7251f6793fa034fbc67de91d65da8844da8ded65705e5f8765b32188560589ec","body_hash":"b6117d207423d39dc3092924ce9ec2faf5246f8a7e2c63f92207756ca9ffce7d","compiler_version":"v0.80.9","strict":true,"agent_id":"copilot","agent_model":"claude-sonnet-4.6","engine_versions":{"copilot":"1.0.63"}}
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN","TEAMS_WEBHOOK_URL"],"actions":[{"repo":"actions/cache/restore","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/cache/save","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/checkout","sha":"9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0","version":"v7.0.0"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"8c7d04ebf1ece56cd381446125da3e0f6896294a","version":"v0.80.9"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.7","digest":"sha256:aae231e4635c8999d039c132f1602d3df850fe9b84a00aa2b5ac981179b5661c","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.27.7@sha256:aae231e4635c8999d039c132f1602d3df850fe9b84a00aa2b5ac981179b5661c"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.7","digest":"sha256:009caf2e3d88fa77b64e9a03a95a228fc58db0f1701c6d324b29ba5a3c7c79b6","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.7@sha256:009caf2e3d88fa77b64e9a03a95a228fc58db0f1701c6d324b29ba5a3c7c79b6"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.7","digest":"sha256:deb1d4e19de62d51cee0508057a596a19315c3423ada4d675cad136dc8037c96","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.27.7@sha256:deb1d4e19de62d51cee0508057a596a19315c3423ada4d675cad136dc8037c96"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.27","digest":"sha256:fe984bddde4ec05d756d9043edb0a32912e6b7b72f6a121b1082f29221421cc7","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.27@sha256:fe984bddde4ec05d756d9043edb0a32912e6b7b72f6a121b1082f29221421cc7"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b","pinned_image":"ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b"},{"image":"ghcr.io/github/github-mcp-server:v1.4.0","digest":"sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036","pinned_image":"ghcr.io/github/github-mcp-server:v1.4.0@sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036"}]}
# This file was automatically generated by gh-aw (v0.80.9). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
#
@@ -509,6 +509,13 @@ jobs:
run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh"
env:
GH_TOKEN: ${{ github.token }}
+ - env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ REPO: ${{ github.repository }}
+ RUN_ID: ${{ github.event.workflow_run.id || github.event.inputs.run_id }}
+ name: Download CI failure logs
+ run: "set -e\nLOG_DIR=\"/tmp/gh-aw/agent/ci-doctor/logs\"\nFILTERED_DIR=\"/tmp/gh-aw/agent/ci-doctor/filtered\"\nmkdir -p \"$LOG_DIR\" \"$FILTERED_DIR\"\n\necho \"=== CI Doctor: Pre-downloading logs for run $RUN_ID ===\"\n\n# Get failed jobs and their failed steps\ngh api \"repos/$REPO/actions/runs/$RUN_ID/jobs\" \\\n --jq '[.jobs[] | select(.conclusion == \"failure\" or .conclusion == \"cancelled\") | {id:.id, name:.name, failed_steps:[.steps[]? | select(.conclusion==\"failure\") | .name]}]' \\\n > \"$LOG_DIR/failed-jobs.json\"\n\nFAILED_COUNT=$(jq 'length' \"$LOG_DIR/failed-jobs.json\")\necho \"Found $FAILED_COUNT failed job(s)\"\n\nif [ \"$FAILED_COUNT\" -eq 0 ]; then\n echo \"No failed jobs found, skipping log download\"\n exit 0\nfi\n\necho \"Failed jobs:\"\ncat \"$LOG_DIR/failed-jobs.json\"\n\n# Download logs for each failed job and apply generic error heuristics\njq -r '.[].id' \"$LOG_DIR/failed-jobs.json\" | while read -r JOB_ID; do\n LOG_FILE=\"$LOG_DIR/job-${JOB_ID}.log\"\n echo \"Downloading log for job $JOB_ID...\"\n gh api \"repos/$REPO/actions/jobs/$JOB_ID/logs\" > \"$LOG_FILE\" 2>/dev/null \\\n || echo \"(log download failed)\" > \"$LOG_FILE\"\n echo \" -> Saved $(wc -l < \"$LOG_FILE\") lines to $LOG_FILE\"\n\n # Apply generic heuristics: find lines with common error indicators\n HINTS_FILE=\"$FILTERED_DIR/job-${JOB_ID}-hints.txt\"\n grep -n -m 30 -iE \"(error[: ]|ERROR|FAIL|panic:|fatal[: ]|undefined[: ]|exception|exit status [^0])\" \\\n \"$LOG_FILE\" > \"$HINTS_FILE\" 2>/dev/null || true\n\n if [ -s \"$HINTS_FILE\" ]; then\n echo \" -> Pre-located $(wc -l < \"$HINTS_FILE\") hint line(s) in $HINTS_FILE\"\n else\n echo \" -> No error hints found in $LOG_FILE\"\n fi\ndone\n\n# Write summary for the agent\nSUMMARY_FILE=\"/tmp/gh-aw/agent/ci-doctor/summary.txt\"\n{\n echo \"=== CI Doctor Pre-Analysis ===\"\n echo \"Run ID: $RUN_ID\"\n echo \"\"\n echo \"Failed jobs (details in $LOG_DIR/failed-jobs.json):\"\n jq -r '.[] | \" Job \\(.id): \\(.name)\\n Failed steps: \\(.failed_steps | join(\", \"))\"' \\\n \"$LOG_DIR/failed-jobs.json\"\n echo \"\"\n echo \"Downloaded log files ($LOG_DIR):\"\n for LOG_FILE in \"$LOG_DIR\"/job-*.log; do\n [ -f \"$LOG_FILE\" ] || continue\n echo \" $LOG_FILE ($(wc -l < \"$LOG_FILE\") lines)\"\n done\n echo \"\"\n echo \"Filtered hint files ($FILTERED_DIR):\"\n for HINTS_FILE in \"$FILTERED_DIR\"/*-hints.txt; do\n [ -s \"$HINTS_FILE\" ] || continue\n echo \" $HINTS_FILE ($(wc -l < \"$HINTS_FILE\") matches)\"\n head -3 \"$HINTS_FILE\" | sed 's/^/ /'\n done\n} | tee \"$SUMMARY_FILE\"\n\necho \"\"\necho \"✅ Pre-analysis complete. Agent should start with $SUMMARY_FILE\"\n"
+
# Repo memory git-based storage configuration from frontmatter processed below
- name: Clone repo-memory branch (default)
env:
diff --git a/.github/workflows/ci-doctor-mq.md b/.github/workflows/ci-doctor-mq.md
index fb234b002ea..508edbb934a 100644
--- a/.github/workflows/ci-doctor-mq.md
+++ b/.github/workflows/ci-doctor-mq.md
@@ -332,6 +332,83 @@ tools:
max-patch-size: 1048576 # 1MB max
max-file-count: 500
+steps:
+ - name: Download CI failure logs
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ RUN_ID: ${{ github.event.workflow_run.id || github.event.inputs.run_id }}
+ REPO: ${{ github.repository }}
+ run: |
+ set -e
+ LOG_DIR="/tmp/gh-aw/agent/ci-doctor/logs"
+ FILTERED_DIR="/tmp/gh-aw/agent/ci-doctor/filtered"
+ mkdir -p "$LOG_DIR" "$FILTERED_DIR"
+
+ echo "=== CI Doctor: Pre-downloading logs for run $RUN_ID ==="
+
+ # Get failed jobs and their failed steps
+ gh api "repos/$REPO/actions/runs/$RUN_ID/jobs" \
+ --jq '[.jobs[] | select(.conclusion == "failure" or .conclusion == "cancelled") | {id:.id, name:.name, failed_steps:[.steps[]? | select(.conclusion=="failure") | .name]}]' \
+ > "$LOG_DIR/failed-jobs.json"
+
+ FAILED_COUNT=$(jq 'length' "$LOG_DIR/failed-jobs.json")
+ echo "Found $FAILED_COUNT failed job(s)"
+
+ if [ "$FAILED_COUNT" -eq 0 ]; then
+ echo "No failed jobs found, skipping log download"
+ exit 0
+ fi
+
+ echo "Failed jobs:"
+ cat "$LOG_DIR/failed-jobs.json"
+
+ # Download logs for each failed job and apply generic error heuristics
+ jq -r '.[].id' "$LOG_DIR/failed-jobs.json" | while read -r JOB_ID; do
+ LOG_FILE="$LOG_DIR/job-${JOB_ID}.log"
+ echo "Downloading log for job $JOB_ID..."
+ gh api "repos/$REPO/actions/jobs/$JOB_ID/logs" > "$LOG_FILE" 2>/dev/null \
+ || echo "(log download failed)" > "$LOG_FILE"
+ echo " -> Saved $(wc -l < "$LOG_FILE") lines to $LOG_FILE"
+
+ # Apply generic heuristics: find lines with common error indicators
+ HINTS_FILE="$FILTERED_DIR/job-${JOB_ID}-hints.txt"
+ grep -n -m 30 -iE "(error[: ]|ERROR|FAIL|panic:|fatal[: ]|undefined[: ]|exception|exit status [^0])" \
+ "$LOG_FILE" > "$HINTS_FILE" 2>/dev/null || true
+
+ if [ -s "$HINTS_FILE" ]; then
+ echo " -> Pre-located $(wc -l < "$HINTS_FILE") hint line(s) in $HINTS_FILE"
+ else
+ echo " -> No error hints found in $LOG_FILE"
+ fi
+ done
+
+ # Write summary for the agent
+ SUMMARY_FILE="/tmp/gh-aw/agent/ci-doctor/summary.txt"
+ {
+ echo "=== CI Doctor Pre-Analysis ==="
+ echo "Run ID: $RUN_ID"
+ echo ""
+ echo "Failed jobs (details in $LOG_DIR/failed-jobs.json):"
+ jq -r '.[] | " Job \(.id): \(.name)\n Failed steps: \(.failed_steps | join(", "))"' \
+ "$LOG_DIR/failed-jobs.json"
+ echo ""
+ echo "Downloaded log files ($LOG_DIR):"
+ for LOG_FILE in "$LOG_DIR"/job-*.log; do
+ [ -f "$LOG_FILE" ] || continue
+ echo " $LOG_FILE ($(wc -l < "$LOG_FILE") lines)"
+ done
+ echo ""
+ echo "Filtered hint files ($FILTERED_DIR):"
+ for HINTS_FILE in "$FILTERED_DIR"/*-hints.txt; do
+ [ -s "$HINTS_FILE" ] || continue
+ echo " $HINTS_FILE ($(wc -l < "$HINTS_FILE") matches)"
+ head -3 "$HINTS_FILE" | sed 's/^/ /'
+ done
+ } | tee "$SUMMARY_FILE"
+
+ echo ""
+ echo "✅ Pre-analysis complete. Agent should start with $SUMMARY_FILE"
+
post-steps:
- name: Upload CI Doctor MQ investigations and patterns
if: always()
@@ -361,6 +438,17 @@ You are the CI Failure Doctor for the Merge Queue, an expert investigative agent
- **Head SHA**: ${{ github.event.workflow_run.head_sha }}
- **Trigger Event**: ${{ github.event.workflow_run.event }}
+## Pre-Analysis Data
+
+Logs have been pre-downloaded before this session started:
+
+- **Summary**: `/tmp/gh-aw/agent/ci-doctor/summary.txt` — failed jobs, failed steps, all file locations, and pre-located error hints
+- **Job metadata**: `/tmp/gh-aw/agent/ci-doctor/logs/failed-jobs.json` — structured list of failed jobs and their failed steps
+- **Log files**: `/tmp/gh-aw/agent/ci-doctor/logs/job-<job-id>.log` — full job logs downloaded from GitHub Actions
+- **Hint files**: `/tmp/gh-aw/agent/ci-doctor/filtered/*-hints.txt` — pre-located error lines (from logs) via generic grep heuristics
+
+**Start here**: Read `/tmp/gh-aw/agent/ci-doctor/summary.txt` first — it lists every file location and the first few hint matches. Then examine the relevant hint files to jump directly to error locations (read ~50 lines around each hinted line number before loading the full log).
+
## Investigation Protocol
**Trigger detection:**
@@ -383,15 +471,19 @@ You are the CI Failure Doctor for the Merge Queue, an expert investigative agent
### Phase 2: Deep Log Analysis
-1. **Retrieve Logs**: Use `get_job_logs` with `failed_only=true` to get logs from all failed jobs. **This step is mandatory — do not skip it or substitute with source code analysis.**
-2. **Pattern Recognition**: Analyze logs for:
+1. **Use Pre-Downloaded Logs**: Start with the files in `/tmp/gh-aw/agent/ci-doctor/`:
+ - Read `/tmp/gh-aw/agent/ci-doctor/summary.txt` and the hint files first (minimal context load).
+ - Read ~50 lines around each hinted line number in the full log file.
+ - Only load the full log content if the hints are insufficient.
+2. **Fallback Log Retrieval**: If the pre-downloaded files are unavailable, use `get_job_logs` with `failed_only=true` to get logs from all failed jobs. **This step is mandatory — do not skip it or substitute with source code analysis.**
+3. **Pattern Recognition**: Analyze logs for:
- Error messages and stack traces
- Dependency installation failures
- Test failures with specific patterns
- Infrastructure or runner issues
- Timeout patterns
- Memory or resource constraints
-3. **Extract Key Information**:
+4. **Extract Key Information**:
- Primary error messages
- File paths and line numbers where failures occurred
- Test names that failed