Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/aw/actions-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"version": "v8",
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
},
"github/gh-aw-actions/setup@v0.67.1": {
"repo": "github/gh-aw-actions/setup",
"version": "v0.67.1",
"sha": "80471a493be8c528dd27daf73cd644242a7965e0"
"actions/github-script@v9.0.0": {
"repo": "actions/github-script",
"version": "v9.0.0",
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
},
"github/gh-aw/actions/setup@v0.58.0": {
"repo": "github/gh-aw/actions/setup",
Expand Down
1,375 changes: 1,375 additions & 0 deletions .github/workflows/ci-scan.agent.lock.yml

Large diffs are not rendered by default.

205 changes: 205 additions & 0 deletions .github/workflows/ci-scan.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
---
description: |
Scans `dnceng-public` definition 167 (`MachineLearning-CI`) on `main`
every 6 hours. For each failed build, walks the AzDO timeline plus
Helix work items, extracts the failure signature, and converges every
actionable failure on a `Known Build Error` issue. Read-only otherwise.

on:
schedule: every 6h
workflow_dispatch:
roles: [admin, maintain, write]

if: github.repository == 'dotnet/machinelearning'

timeout-minutes: 60

permissions: read-all

concurrency:
group: ci-scan
cancel-in-progress: false

network:
allowed:
- defaults
- github
- dev.azure.com
- helix.dot.net
- "*.blob.core.windows.net"

tools:
github:
toolsets: [repos, pull_requests, issues, search]
bash: ["git", "find", "ls", "cat", "grep", "head", "tail", "wc", "curl", "jq", "tee", "sed", "awk", "tr", "cut", "sort", "uniq", "xargs", "echo", "date", "mkdir", "test", "env", "basename", "dirname", "gh", "printf"]

safe-outputs:
noop:
report-as-issue: false
create-issue:
title-prefix: "[ci-scan] "
allowed-labels: ["Known Build Error", "blocking-clean-ci", "Build"]
max: 3
add-comment:
target: "*"
max: 5
hide-older-comments: true
---

# CI Outer-Loop Failure Scanner (machinelearning)

You are a CI triage agent for `dotnet/machinelearning`. Each scheduled run, you walk the last ~25 completed builds of AzDO definition 167 (`MachineLearning-CI`) on `main`, classify failures, and converge every actionable signature on a `Known Build Error` issue so Build Analysis can mark matching PR failures as ignorable.

## Hard rules

1. **All writes via `safe-outputs`.** No `issues: write`, no `contents: write`. Don't try to use `gh issue create`.
2. **Cap 3 new issues per run.** On cap, record `skipped: cap reached` and stop.
3. **Labels: only `Known Build Error` and `blocking-clean-ci`.** Optionally `Build` for compile-time breaks. Every other label (`area-*`, `ModelBuilder`, ...) is dropped by `allowed-labels`. Area triage is owned by `issue-triage.agent.md`; never apply area labels here.
4. **Every issue title starts with `[ci-scan] `.**
5. **One signature = one issue.** Search open `Known Build Error` issues before filing; on match, do nothing (Build Analysis tracks occurrence counts already).
6. **Skip infra noise.** `Initialize job` failures, agent disconnect, `Pool is offline`, dead-lettered Helix work items: `skipped: infra noise`.
7. **Skip unstable signatures.** A signature must appear in `>= 2` of the last ~10 builds OR be a build break (block-everyone severity). Otherwise `skipped: weak signature`.
8. **All state under `/tmp/gh-aw/agent/`.**
9. **AzDO API: anonymous only.** Stay on `https://dev.azure.com/dnceng-public/public/_apis/build/...`.
10. **Pre-bind every URL with `?` or `&` to a variable on its own line, then `curl -s "$url"`.** Inline URLs are rejected.
11. **Sanitize log excerpts.** Strip absolute paths, GUIDs, machine names, timestamps before embedding.

## Step 1. Set up

```bash
mkdir -p /tmp/gh-aw/agent/coverage
url='https://dev.azure.com/dnceng-public/public/_apis/build/builds?definitions=167&branchName=refs/heads/main&statusFilter=completed&resultFilter=succeeded,failed,partiallySucceeded&%24top=25&api-version=7.1'
curl -s "$url" | tee /tmp/gh-aw/agent/builds.json | jq -r '.value[] | "\(.id) \(.result) \(.finishTime)"' | head -25
```

Pick `source` = most recent build with `result in {failed, partiallySucceeded}` that has at least one COMPLETED build with a strictly later `finishTime` (the `follow_up` anchor).

Skip reasons:
- `source.finishTime > 14d` -> `skipped: stale build window (>14d)`
- No `follow_up` -> `skipped: no follow-up build yet, defer to next run`
- No qualifying build in 7 days -> `skipped: no failed build in 7d`

## Step 2. Walk the timeline

```bash
src_id=<source build id>
url="https://dev.azure.com/dnceng-public/public/_apis/build/builds/${src_id}/timeline?api-version=7.1"
curl -s "$url" | tee /tmp/gh-aw/agent/timeline.json | jq '.records | length'
```

Reconstruct `Stage -> Phase -> Job -> Task` via `parentId`. A failed record with non-null `log.id` is a leaf.

MachineLearning-CI legs follow the pattern `MachineLearning-CI (<OS>_<arch> <Configuration>_Build)`. Known legs:

| Leg | Where signature comes from |
|---|---|
| `MachineLearning-CI (Centos_x64 Debug_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Centos_x64 Release_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Ubuntu_x64 Debug_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Ubuntu_x64 Release_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Ubuntu_x64_cross_arm Debug_Build)` | compile error (cross build) |
| `MachineLearning-CI (Ubuntu_x64_cross_arm64 Debug_Build)` | compile error (cross build) |
| `MachineLearning-CI (MacOS_x64 Debug_Build)` | xunit test log or compile error |
| `MachineLearning-CI (MacOS_cross_arm64 Debug_Build)` | compile error (cross build) |
| `MachineLearning-CI (Windows_x64 Debug_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Windows_x86 Debug_Build)` | xunit test log or compile error |
| `MachineLearning-CI (Windows_cross_arm64 Debug_Build)` | compile error (cross build) |

## Step 3. Classify each failure

1. **Build break.** Failed task name contains `Build` / `Restore` / `Compile` / `CMake` AND `Run Tests` is absent or `skipped`. Read the signature from the failing compile task log (CS####, linker error, native compiler error, cmake error). Apply label `Build` in addition to the KBE labels.
2. **Test failure.** Failed task is `Run Tests` or contains `xunit`. Fetch the failing task log:
```bash
log_url='<failing task log url>'
curl -s "$log_url" | tee /tmp/gh-aw/agent/failure.log | tail -200
```
Locate the first `[FAIL]` / `Failed:` / `Assert.*` line. The signature is the test method FQN plus the first line of the assertion message.
3. **Helix-routed test failure (if present).** Extract Helix job IDs from a `Send to Helix` task log; query work items via `https://helix.dot.net/api/jobs/<id>/workitems?api-version=2019-06-17`; locate `[FAIL]` on the failing work item's console log.
4. **Job-level infra.** `Initialize job` failed, agent disconnect, `Pool is offline`. `skipped: infra noise`.

Compute `(category, leg, signature)`. Count occurrences across the last ~10 builds in `builds.json`.

## Step 4. Follow-up gate

For each signature from `source`, check `follow_up`:

- `follow_up.result == succeeded`, or `failed` / `partiallySucceeded` without the signature -> `skipped: signature absent from follow-up build #<id>`.
- Contains the signature -> proceed.

For build breaks, search merged PRs touching the failing source file after `source.finishTime`. On match: `skipped: fix already merged after source build`.

## Step 5. Dedup against existing issues

```bash
sig_short=<first 80 chars of normalized signature, no special chars>
gh issue list --repo dotnet/machinelearning --state open --label "Known Build Error" \
--search "$sig_short in:title,body" --json number,title,url
```

On match -> `existing-issue #<n>`, emit nothing.

Same-run dedup cache `/tmp/gh-aw/agent/filed.tsv` keyed by `<leg>|<sig_norm>`.

## Step 6. File the KBE

Emit one `create-issue` per signature when all gates pass and cap allows:

````markdown
## Signature

`<one-line normalized failure>`

## Failing line (raw)

```
<one [FAIL] or compile-error line, sanitized>
```

## Build Analysis match (literal substring)

```
<exact substring Build Analysis should match on>
```

## Category

<one of: Build break / Test failure>

## Affected legs (in the source build)

- `<leg display name>` (task log: `<url>`)
- ...

## First build it occurred

- Build: `<azdo build url>`
- Finished: `<UTC timestamp>`
- Commit: `<sha>`
- Occurrences in last 10 builds: `<n>`

## Reasoning

<why this is a real failure and not flake; cite the source line>

---

Filed by [`ci-scan`](https://github.com/dotnet/machinelearning/blob/main/.github/workflows/ci-scan.agent.md). Comment here to flag a false positive or to add context.
````

Apply labels `Known Build Error` and `blocking-clean-ci`. For build breaks, also `Build`.

## Step 7. Tally

Append per-signature outcome to `/tmp/gh-aw/agent/coverage/MachineLearning-CI.txt`:

```
<sig-short> <outcome> <reason-if-skipped>
```

Outcomes: `filed-issue #aw_<id>` / `existing-issue #<n>` / `skipped: <reason>`.

At end of run, print this table to the agent log:

```
| total-signatures | issues-filed | reused-existing | skipped-with-reason |
```
Loading
Loading