ci/tools/gh/README.md
Tools for analyzing and debugging GitHub Actions workflow failures.
workflow_scanner.py - Workflow Failure ScannerScans GitHub Actions workflow runs and analyzes all failing jobs. Designed to prevent stdout buffer overflow by streaming output serially while fetching logs concurrently.
# Scan latest build.yml run (default)
uv run ci/tools/gh/workflow_scanner.py
# Scan specific workflow
uv run ci/tools/gh/workflow_scanner.py --workflow build.yml
# Scan specific run by ID
uv run ci/tools/gh/workflow_scanner.py --run-id 12345678
# Scan with more context lines
uv run ci/tools/gh/workflow_scanner.py --context 30
# Scan last 5 runs
uv run ci/tools/gh/workflow_scanner.py --max-runs 5
# Limit concurrent job processing
uv run ci/tools/gh/workflow_scanner.py --max-concurrent 3
| Option | Default | Description |
|---|---|---|
--workflow | build.yml | Workflow filename to scan |
--run-id | Latest | Specific run ID to analyze |
--context | 20 | Lines of context before/after errors |
--max-concurrent | 5 | Maximum concurrent job processing |
--max-runs | 1 | Number of recent runs to scan (if no run-id) |
The tool outputs error blocks in the following format:
================================================================================
Error #1 in job: build (ubuntu-latest, gcc) (ID: 12345678)
================================================================================
[20 lines of context before]
>>> line containing "error" or "fatal" keyword
[20 lines of context after]
================================================================================
Error #2 in job: test (windows-latest) (ID: 12345679)
================================================================================
[context lines...]
>>> error line
[context lines...]
Lines containing the error keyword are prefixed with >>> for easy identification.
WorkflowScanner
├── Workflow Discovery
│ ├── get_workflow_runs() - Get runs for specified workflow
│ └── get_failed_jobs() - Filter for failed/cancelled jobs
│
├── Log Processing (Worker Threads)
│ ├── fetch_and_filter_job_logs() - Download logs via gh API
│ ├── Filter for error/fatal keywords
│ └── Extract ±N lines of context
│
└── Output Streaming (Main Thread)
├── output_queue - Thread-safe queue
└── stream_output() - Serial stdout writing
The tool searches for these keywords (case insensitive):
errorfatalWhen found, it extracts the surrounding context (default ±20 lines) and outputs the block immediately.
gh CLI tool installed and authenticatedExample 1: Scan latest build.yml run
uv run ci/tools/gh/workflow_scanner.py
Example 2: Deep dive into a specific failing run
uv run ci/tools/gh/workflow_scanner.py --run-id 18397776636 --context 30
Example 3: Scan last 3 runs to find pattern of failures
uv run ci/tools/gh/workflow_scanner.py --max-runs 3
gh_healthcheck.py - Workflow Health CheckAnalyzes GitHub Actions workflow health and provides a comprehensive diagnostic report with root cause analysis and recommendations.
# Check latest build.yml run
uv run ci/tools/gh/gh_healthcheck.py
# Check specific run
uv run ci/tools/gh/gh_healthcheck.py --run-id 18399875461
# High detail analysis (slower, more info)
uv run ci/tools/gh/gh_healthcheck.py --detail high
# Quick check (fast, summary only)
uv run ci/tools/gh/gh_healthcheck.py --detail low
| Option | Values | Default | Description |
|---|---|---|---|
--workflow | filename | build.yml | Workflow to analyze |
--run-id | run ID | latest | Specific run to analyze |
--detail | low/medium/high | medium | Analysis depth |
================================================================================
GitHub Actions Health Check Report
================================================================================
📋 Run Information:
Run ID: 18399875461
Title: feat(compile_perf): add support for tracking header include tree
Branch: master
Status: completed
Conclusion: failure
📊 Job Summary:
Total Jobs: 17
✅ Passed: 13
❌ Failed: 4
❌ Failed Jobs (4):
- build_esp32dev_idf33 / build (failure)
- build_esp32_c3_devkitm_1 / build (failure)
...
🔍 Root Cause Analysis:
1. Missing Header (15 occurrences)
Description: Missing include file
💡 Suggestion: Check if header exists for this platform/version
Affected:
- soc/soc_caps.h
- esp_system.h
💡 Recommendations:
1. Missing header files detected - likely platform/version compatibility issue
Consider using conditional includes: #if __has_include(...)
0: Workflow healthy (all jobs passed)1: Failures detectedUse the /gh-healthcheck command for quick access:
/gh-healthcheck
/gh-healthcheck --run-id 18399875461
/gh-healthcheck --detail high
gh_debug.py - Single Run DebuggerLocated at ci/tools/gh_debug.py, this tool provides deep analysis of a specific workflow run with full error context.
See the tool's help for usage:
uv run ci/tools/gh_debug.py --help
| Tool | Use Case | Speed | Detail |
|---|---|---|---|
gh_healthcheck.py | Quick status check, pattern analysis | ⚡ Fast | Overview + recommendations |
workflow_scanner.py | Stream all errors from workflow | ⚖️ Medium | All errors with context |
gh_debug.py | Deep dive into specific failure | 🐌 Slow | Full logs with context |
.py file in ci/tools/gh/__init__.py to export public API# Test with a known failing run
uv run ci/tools/gh/workflow_scanner.py --run-id <failing-run-id>
# Test with latest run
uv run ci/tools/gh/workflow_scanner.py
"No workflow runs found"
build.yml)gh CLI is authenticated: gh auth status"Error getting repo info"
gh CLI is installed: gh --versiongh auth loginTimeout errors
--max-concurrent to process fewer jobs at onceNo errors found but jobs failed
--context to capture more linesgh_debug.py tool for more detailed analysis