Skip to content

Commit 89052b9

Browse files
Add ci-status Copilot skill
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3c1d9d7 commit 89052b9

File tree

3 files changed

+277
-0
lines changed

3 files changed

+277
-0
lines changed

.github/skills/ci-status/SKILL.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Binlog Analysis Reference
2+
3+
Load this file only when the user asks to analyze .binlog artifacts from a build.
4+
5+
## Prerequisites
6+
7+
| Tool | Check | Install |
8+
|------|-------|---------|
9+
| `binlogtool` | `dotnet tool list -g \| grep binlogtool` | `dotnet tool install -g binlogtool` |
10+
11+
## Download .binlog artifacts
12+
13+
### List artifacts
14+
15+
```bash
16+
az pipelines runs artifact list --run-id $BUILD_ID --org $ORG_URL --project $PROJECT --output json 2>&1
17+
```
18+
19+
```powershell
20+
az pipelines runs artifact list --run-id $BUILD_ID --org $ORG_URL --project $PROJECT --output json
21+
```
22+
23+
Look for artifact names containing `binlog`, `msbuild`, or `build-log`.
24+
25+
### Download
26+
27+
```bash
28+
TEMP_DIR="/tmp/azdo-binlog-$BUILD_ID"
29+
mkdir -p "$TEMP_DIR"
30+
az pipelines runs artifact download --artifact-name "$ARTIFACT_NAME" --path "$TEMP_DIR" \
31+
--run-id $BUILD_ID --org $ORG_URL --project $PROJECT
32+
```
33+
34+
```powershell
35+
$tempDir = Join-Path $env:TEMP "azdo-binlog-$BUILD_ID"
36+
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
37+
az pipelines runs artifact download --artifact-name "$ARTIFACT_NAME" --path $tempDir `
38+
--run-id $BUILD_ID --org $ORG_URL --project $PROJECT
39+
```
40+
41+
## Analysis commands
42+
43+
```bash
44+
# Broad error search
45+
binlogtool search "$TEMP_DIR"/*.binlog "error"
46+
47+
# .NET Android errors
48+
binlogtool search "$TEMP_DIR"/*.binlog "XA"
49+
50+
# C# compiler errors
51+
binlogtool search "$TEMP_DIR"/*.binlog "error CS"
52+
53+
# NuGet errors
54+
binlogtool search "$TEMP_DIR"/*.binlog "error NU"
55+
56+
# Full text log reconstruction
57+
binlogtool reconstruct "$TEMP_DIR/file.binlog" "$TEMP_DIR/reconstructed"
58+
59+
# MSBuild properties
60+
binlogtool listproperties "$TEMP_DIR/file.binlog"
61+
62+
# Double-write detection
63+
binlogtool doublewrites "$TEMP_DIR/file.binlog" "$TEMP_DIR/dw"
64+
```
65+
66+
## Cleanup
67+
68+
```bash
69+
rm -rf "/tmp/azdo-binlog-$BUILD_ID"
70+
```
71+
72+
```powershell
73+
Remove-Item -Recurse -Force (Join-Path $env:TEMP "azdo-binlog-$BUILD_ID")
74+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Error Patterns (dotnet/android)
2+
3+
Load this file only during failure categorization or when investigating a specific error.
4+
5+
## Categories
6+
7+
### 🔴 Real Failures — Investigate
8+
9+
These indicate genuine code problems that need fixing.
10+
11+
| Pattern | Example |
12+
|---------|---------|
13+
| MSBuild errors | `XA####`, `APT####` |
14+
| C# compiler | `error CS####` |
15+
| NuGet resolution | `NU1100``NU1699` |
16+
| Test assertions | `Failed :`, `Assert.`, `Expected:` |
17+
| Segfaults / crashes | `SIGSEGV`, `SIGABRT`, `Fatal error` |
18+
19+
### 🟡 Flaky Failures — Retry
20+
21+
These are known intermittent issues.
22+
23+
| Pattern | Example |
24+
|---------|---------|
25+
| Device connectivity | `device not found`, `adb: device offline` |
26+
| Emulator timeouts | `System.TimeoutException`, `emulator did not boot` |
27+
| Single-platform failure | Test fails on one OS but passes on others |
28+
29+
### 🔵 Infrastructure — Retry
30+
31+
These are CI environment issues, not code problems.
32+
33+
| Pattern | Example |
34+
|---------|---------|
35+
| Disk space | `No space left on device`, `NOSPC` |
36+
| Network | `Unable to load the service index`, `Connection refused` |
37+
| NuGet feed | `NU1301` (feed connectivity) |
38+
| Agent issues | `The agent did not connect`, `##[error] The job was canceled` |
39+
| Timeout (job-level) | Job canceled after 55+ minutes |
40+
41+
## Decision Tree
42+
43+
1. Does the error contain `XA`, `CS`, `NU1[1-6]`, or `Assert`? → 🔴 Real
44+
2. Does the error mention `device`, `emulator`, `adb`, or `TimeoutException`? → 🟡 Flaky
45+
3. Does the error mention `disk`, `network`, `feed`, `agent`, or `##[error] canceled`? → 🔵 Infra
46+
4. Does the same test pass on other platforms in the same build? → 🟡 Flaky
47+
5. Otherwise → 🔴 Real (default to investigating)

0 commit comments

Comments
 (0)