|
| 1 | +--- |
| 2 | +name: ci-status |
| 3 | +description: > |
| 4 | + Check CI build status and investigate failures for dotnet/android PRs. ALWAYS use this skill when |
| 5 | + the user asks "check CI", "CI status", "why is CI failing", "is CI green", "why is my PR blocked", |
| 6 | + or anything about build status on a PR. Auto-detects the current PR from the git branch when no |
| 7 | + PR number is given. Covers both GitHub checks and internal Azure DevOps builds. |
| 8 | + DO NOT USE FOR: GitHub Actions workflow authoring, non-dotnet/android repos. |
| 9 | +--- |
| 10 | + |
| 11 | +# CI Status |
| 12 | + |
| 13 | +Check CI status and investigate build failures for dotnet/android PRs. |
| 14 | + |
| 15 | +**Key fact:** dotnet/android's primary CI runs on Azure DevOps (internal). GitHub checks alone are insufficient — they may all show ✅ while the internal build is failing. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +| Tool | Check | Setup | |
| 20 | +|------|-------|-------| |
| 21 | +| `gh` | `gh --version` | https://cli.github.com/ | |
| 22 | +| `az` + devops ext | `az version` | `az extension add --name azure-devops` then `az login` | |
| 23 | + |
| 24 | +If `az` is not authenticated, stop and tell the user to run `az login`. |
| 25 | + |
| 26 | +## Workflow |
| 27 | + |
| 28 | +### Phase 1: Quick Status (always do this first) |
| 29 | + |
| 30 | +#### Step 1 — Resolve the PR |
| 31 | + |
| 32 | +**No PR specified** — detect from current branch: |
| 33 | + |
| 34 | +```bash |
| 35 | +gh pr view --json number,title,url,headRefName --jq '{number,title,url,headRefName}' |
| 36 | +``` |
| 37 | + |
| 38 | +```powershell |
| 39 | +gh pr view --json number,title,url,headRefName | ConvertFrom-Json |
| 40 | +``` |
| 41 | + |
| 42 | +If no PR exists for the current branch, tell the user and stop. |
| 43 | + |
| 44 | +**PR number given** — use it directly. |
| 45 | + |
| 46 | +#### Step 2 — Get GitHub check status |
| 47 | + |
| 48 | +```bash |
| 49 | +gh pr checks $PR --repo dotnet/android --json "name,state,link,bucket" 2>&1 \ |
| 50 | + | jq '[.[] | {name, state, bucket, link}]' |
| 51 | +``` |
| 52 | + |
| 53 | +```powershell |
| 54 | +gh pr checks $PR --repo dotnet/android --json "name,state,link,bucket" | ConvertFrom-Json |
| 55 | +``` |
| 56 | + |
| 57 | +Note which checks passed/failed/pending. The `link` field contains the AZDO build URL for internal checks. |
| 58 | + |
| 59 | +#### Step 3 — Get Azure DevOps build status |
| 60 | + |
| 61 | +Extract the AZDO build URL from the check `link` fields. Parse `{orgUrl}`, `{project}`, and `{buildId}` from patterns: |
| 62 | +- `https://dev.azure.com/{org}/{project}/_build/results?buildId={id}` |
| 63 | +- `https://{org}.visualstudio.com/{project}/_build/results?buildId={id}` |
| 64 | + |
| 65 | +Then fetch the build timeline: |
| 66 | + |
| 67 | +```bash |
| 68 | +az devops invoke --area build --resource timeline \ |
| 69 | + --route-parameters project=$PROJECT buildId=$BUILD_ID \ |
| 70 | + --org $ORG_URL --project $PROJECT \ |
| 71 | + --query "records[?result=='failed'] | [].{name:name, type:type, result:result, issues:issues, errorCount:errorCount, log:log}" \ |
| 72 | + --output json 2>&1 |
| 73 | +``` |
| 74 | + |
| 75 | +```powershell |
| 76 | +az devops invoke --area build --resource timeline ` |
| 77 | + --route-parameters project=$PROJECT buildId=$BUILD_ID ` |
| 78 | + --org $ORG_URL --project $PROJECT ` |
| 79 | + --query "records[?result=='failed'] | [].{name:name, type:type, result:result, issues:issues, errorCount:errorCount, log:log}" ` |
| 80 | + --output json |
| 81 | +``` |
| 82 | + |
| 83 | +Check `issues` arrays first — they often contain the root cause directly. |
| 84 | + |
| 85 | +#### Step 4 — Present summary |
| 86 | + |
| 87 | +Use this format: |
| 88 | + |
| 89 | +``` |
| 90 | +# CI Status for PR #NNNN — "PR Title" |
| 91 | +
|
| 92 | +## GitHub Checks |
| 93 | +| Check | Status | |
| 94 | +|-------|--------| |
| 95 | +| check-name | ✅ / ❌ / 🟡 | |
| 96 | +
|
| 97 | +## Azure DevOps Build [#BuildId](link) |
| 98 | +**Result:** ✅ Succeeded / ❌ Failed / 🟡 In Progress |
| 99 | +
|
| 100 | +### Failures (if any) |
| 101 | +❌ Stage > Job > Task |
| 102 | + Error: <first error message> |
| 103 | +
|
| 104 | +## What next? |
| 105 | +1. View full logs for a failure |
| 106 | +2. Download and analyze .binlog artifacts |
| 107 | +3. Retry failed stages |
| 108 | +``` |
| 109 | + |
| 110 | +**If no failures found anywhere**, report CI as green and stop. |
| 111 | + |
| 112 | +### Phase 2: Deep Investigation (only if user requests) |
| 113 | + |
| 114 | +Only proceed here if the user asks to investigate a specific failure, view logs, or analyze binlogs. |
| 115 | + |
| 116 | +#### Fetch logs |
| 117 | + |
| 118 | +Get the `log.id` from failed timeline records, then: |
| 119 | + |
| 120 | +```bash |
| 121 | +az devops invoke --area build --resource logs \ |
| 122 | + --route-parameters project=$PROJECT buildId=$BUILD_ID logId=$LOG_ID \ |
| 123 | + --org $ORG_URL --project $PROJECT \ |
| 124 | + --out-file "/tmp/azdo-log-$LOG_ID.log" 2>&1 |
| 125 | +tail -40 "/tmp/azdo-log-$LOG_ID.log" |
| 126 | +``` |
| 127 | + |
| 128 | +```powershell |
| 129 | +$logFile = Join-Path $env:TEMP "azdo-log-$LOG_ID.log" |
| 130 | +az devops invoke --area build --resource logs ` |
| 131 | + --route-parameters project=$PROJECT buildId=$BUILD_ID logId=$LOG_ID ` |
| 132 | + --org $ORG_URL --project $PROJECT ` |
| 133 | + --out-file $logFile |
| 134 | +Get-Content $logFile -Tail 40 |
| 135 | +``` |
| 136 | + |
| 137 | +#### Analyze .binlog artifacts |
| 138 | + |
| 139 | +See [references/binlog-analysis.md](references/binlog-analysis.md) for binlog download and analysis commands. |
| 140 | + |
| 141 | +#### Categorize failures |
| 142 | + |
| 143 | +See [references/error-patterns.md](references/error-patterns.md) for dotnet/android-specific error patterns and categorization. |
| 144 | + |
| 145 | +## Error Handling |
| 146 | + |
| 147 | +- **Build in progress:** Report current status and offer to watch with `gh pr checks --watch` |
| 148 | +- **No AZDO build found:** The PR may not have triggered internal CI yet. Report GitHub checks only. |
| 149 | +- **Auth expired:** Tell user to run `az login` and retry. |
| 150 | +- **Build not found:** Verify the PR number/build ID is correct. |
| 151 | + |
| 152 | +## Tips |
| 153 | + |
| 154 | +- Focus on the **first** error chronologically — later errors often cascade |
| 155 | +- `.binlog` has richer detail than text logs when logs show only "Build FAILED" |
| 156 | +- `issues` in timeline records often contain the root cause without needing to download logs |
0 commit comments