Repository navigation
Add Build Failure Analysis agentic workflow - #17125
Evangelink merged 38 commits into
Conversation
Ports the microsoft/testfx "Build Failure Analysis" gh-aw workflow to dotnet/arcade. On every PR (and via the /analyze-build-failure slash command) it runs ./build.sh --binaryLog; when the build fails it delegates to the build-failure-analyst agent, which queries the binary log live through the containerized binlog-mcp MCP server, posts a root-cause summary comment, and attaches inline `suggestion` blocks tied to the diff. The workflow is advisory only (does not gate the PR check) and is gated on build failure so a green build never invokes the AI agent. Files: - .github/workflows/build-failure-analysis.md (+ .lock.yml) - .github/workflows/build-failure-analysis-command.md (+ .lock.yml) - .github/workflows/shared/build-failure-analysis-shared.md - .github/agents/build-failure-analyst.agent.md - .github/aw/actions-lock.json (new action SHA pins) Adapted for arcade: pull_request branches [main, release/*], arcade build.sh, binlog under artifacts/log, and the internal-SDK global.json (NuGet MCP install runs from /tmp). Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
There was a problem hiding this comment.
Pull request overview
Introduces an agentic GitHub Actions workflow pair to run ./build.sh --binaryLog on PRs and via a /analyze-build-failure slash command, and (only on build failure) delegate binlog-driven root-cause analysis to a reusable build-failure-analyst agent via a containerized binlog-mcp MCP server.
Changes:
- Adds PR-triggered and slash-command-triggered build-failure analysis workflows, sharing a common prompt body.
- Adds a reusable
build-failure-analystagent definition intended to query binlogs live and post summary + inline suggestions. - Extends the repo’s agentic workflow action SHA pin map for core actions used by these workflows.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/shared/build-failure-analysis-shared.md | Shared workflow body/prompt that launches the analyst sub-agent on failures. |
| .github/workflows/build-failure-analysis.md | PR + manual dispatch workflow wiring (build + artifact handoff + agent tooling/safe-outputs). |
| .github/workflows/build-failure-analysis.lock.yml | Compiled/locked workflow version executed by Actions. |
| .github/workflows/build-failure-analysis-command.md | Slash-command workflow wiring to rerun analysis on demand for a PR. |
| .github/workflows/build-failure-analysis-command.lock.yml | Compiled/locked slash-command workflow version executed by Actions. |
| .github/aw/actions-lock.json | Adds SHA pins for actions referenced by the new workflows. |
| .github/agents/build-failure-analyst.agent.md | Defines the analyst agent behavior, including binlog + NuGet MCP usage and comment/suggestion output format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix NuGet MCP invocation: use `NuGet.Mcp.Server` (the global tool's command name) instead of `dotnet NuGet.Mcp.Server`, which would resolve a non-existent `dotnet-NuGet.Mcp.Server` subcommand (2 places in the agent). - Align the documented inline-suggestion cap with the workflow config (25, not 10). - Drop the hard-coded `model: "claude-opus-4.6"` from the shared prompt so the workflow-level default model applies (robust to allowlist changes). - Raise timeouts for Arcade's long `./build.sh`: build job 30 -> 120 min, agent job 30 -> 60 min (both workflows), so a slow-but-healthy build is not misclassified as a failure. - SHA-pin the gh-aw setup action (github/gh-aw-actions@3ea13c02...) and record the setup-cli bootstrap action SHA in actions-lock.json. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
|
Thanks for the review — addressed in 3b30e63:
Lock files were regenerated with |
…otnet#17125) Do not merge. Adds an undefined-symbol reference so ./build.sh fails and the build-failure-analysis workflow triggers the analyst agent. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
- Set `persist-credentials: false` on the build-job checkout in both
workflows so the job token isn't written into local git config while
./build.sh runs checked-out PR contents.
- Disable errexit (`set +e`) in the "Build with binary log" step so the
explicit `exit "${PIPESTATUS[0]}"` always runs and we key off build.sh's
real exit code rather than tee's / an early -e abort.
- Relax the "Locate binlog" step (`set +e; set +o pipefail`) so a missing
artifacts/log directory (very early build failure) can't fail the find
pipeline and turn this advisory workflow red.
Lock files regenerated with `gh aw compile` (v0.77.5, LF), 0 errors/warnings.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
…otnet#17125) Do not merge. Adds an undefined-symbol reference so ./build.sh fails and the build-failure-analysis workflow triggers the analyst agent. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
|
Addressed the second review round in 70d2076:
Lock files regenerated with I'm also validating end-to-end on my fork: an intra-fork PR introduces a deliberate |
- Include `inputs.pr-number` in the concurrency group so dispatching analyses for different PRs on the same ref no longer cancel each other. - On `workflow_dispatch` with `pr-number`, check out that PR's merge ref in the build job so the analysed binlog matches the PR being commented on (pull_request events keep the default checkout). - Command workflow: add a "Check PR origin" guard and gate the checkout / build / locate-binlog steps on it, so `/analyze-build-failure` never builds untrusted fork-PR code in the base-repo context. A skipped build reports `skipped` (not `failure`), so the analyst pipeline stays inert for fork PRs. Permissions were intentionally left as `pull-requests: read` on the agent job: gh-aw applies safe-outputs from a separate job that the compiler grants `issues: write` + `pull-requests: write` (verified in the lock), keeping the agent job least-privilege. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
|
Third review round — addressed in cae53c5: Fixed
Not changed (by design)
Lock files regenerated with |
…otnet#17125) Do not merge. Adds an undefined-symbol reference so ./build.sh fails and the build-failure-analysis workflow triggers the analyst agent. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
The slash-command workflow compiles into a workflow_dispatch entrypoint, so event-payload fields aren't populated the way the source frontmatter assumed: - Build job now also requests `pull-requests: read` so the `Check PR origin` step's `gh api .../pulls/<n>` call has the scope it needs (the job-level permissions block otherwise narrows the token to `contents: read`). - Concurrency group falls back to the PR/issue number carried in `aw_context` (and finally `github.run_id`) instead of relying solely on `github.event.issue.number`, which is unset under workflow_dispatch and would otherwise collapse all command runs into one group and cancel each other. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
|
Fourth review round — addressed in 6bcb932 (both specific to the command workflow, which compiles into a
Recompiled with |
The "build failed but no binlog" fallback template wrapped `<!-- build-failure-analysis -->` in backticks, so the agent would post it as inline code rather than a real HTML comment — breaking marker detection for `hide-older-comments`. Emit it as a raw HTML comment, matching the Step 5 summary template. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
.github/aw/actions-lock.json:32
- The new lock workflows were compiled with gh-aw v0.82.8 and pin github/gh-aw-actions/[email protected], but .github/aw/actions-lock.json only pins v0.77.5 today. If the repo expects actions-lock.json to cover every pinned action version used by workflows, add the v0.82.8 entry (or recompile lock files to match the repo’s pinned gh-aw version).
"github/gh-aw-actions/[email protected]": {
"repo": "github/gh-aw-actions/setup",
"version": "v0.77.5",
"sha": "3ea13c02d765410340d533515cb31a7eef2baaf0"
}
…inlogs Validation showed the newer gh-aw runtime mounts binlog-mcp as a CLI wrapper (.../mcp-cli/bin/binlog-mcp) and connects it, but only the native MCP tool was allowlisted; when the agent invoked the wrapper via the shell it was denied, so no binlog could be read. Add shell(binlog-mcp:*) to the bash allowlist and document both invocation forms (native MCP tool or CLI wrapper) in the prompt and playbook. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
.github/aw/actions-lock.json:32
- This actions lock file is missing entries for action versions introduced by the new build-failure-analysis workflows (e.g.,
actions/[email protected],actions/cache/*@v6.1.0, andgithub/gh-aw-actions/[email protected]). Without these,gh aw compilewill be unable to resolve/pin the actions consistently (or will rewrite this file during compilation).
"github/gh-aw-actions/[email protected]": {
"repo": "github/gh-aw-actions/setup",
"version": "v0.77.5",
"sha": "3ea13c02d765410340d533515cb31a7eef2baaf0"
}
Same fix as the auto workflow: add shell(binlog-mcp:*) so the slash-command agent can query the binlogs via the mounted CLI wrapper. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
.github/aw/actions-lock.json:32
- The new lock workflows were generated with
github/gh-aw-actions/[email protected](sha99d9d8...), but.github/aw/actions-lock.jsononly pins@v0.77.5. Add thev0.82.8entry so action resolution remains reproducible when recompiling workflows.
"github/gh-aw-actions/[email protected]": {
"repo": "github/gh-aw-actions/setup",
"version": "v0.77.5",
"sha": "3ea13c02d765410340d533515cb31a7eef2baaf0"
}
The lock files had been regenerated with gh-aw v0.82.8, which pinned newer runtime containers (gh-aw-mcpg v0.4.1, github-mcp-server v1.5.0) and actions ([email protected], [email protected]) inconsistent with dotnet/arcade's standard v0.77.5 (see update-default-versions.lock.yml) and with .github/aw/actions-lock.json. Recompiling with v0.77.5 restores [email protected] (present in actions-lock.json), the v0.3.22 MCP gateway runtime (which exposes the containerized binlog-mcp tools natively to Copilot), and a matching compiler_version. The binlog-mcp CLI-wrapper allowlist is kept as a harmless fallback. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
The size-listing (unzip -l) and the entry-path traversal pre-scan (unzip -Z1) ran on untrusted PR-produced archives without a timeout, so a hostile/huge zip could hang the runner during listing. Worse, the traversal check piped unzip -Z1 straight into grep, so if the listing errored or hung the grep saw empty output, matched nothing, and extraction proceeded (fail-open). - Wrap unzip -l with `timeout 60`; a timeout yields empty output that the existing numeric check rejects (skip). - Capture unzip -Z1 under `timeout 60` into a variable, check its exit code, and skip the artifact (fail closed) on any error/timeout before grepping the captured entries for absolute/.. paths. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
The prior traversal check captured the full `unzip -Z1` output into a shell variable (`entries=...`), which buffers every entry name in memory — a DoS vector for an archive with very many entries even when the byte caps hold. Stream the listing through `grep` under `timeout` instead, and use PIPESTATUS to keep the fail-closed behavior: PIPESTATUS[0] (unzip/timeout) non-zero => listing error/timeout => skip; PIPESTATUS[1] (grep) == 0 => suspicious absolute/.. path => skip; otherwise clean. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7b11dbc-6cf1-440c-a28a-dfcc5ddff35a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/build-failure-analysis.md:23
- The workflow header says the analysis pipeline “only downloads build artifacts (data)” and “does not build or execute PR code”, but it also performs an
actions/checkoutof the repository to load agent/workflow configuration. This is fine, but the wording can read as “no checkout occurs” (which also conflicts with the PR description). Consider tightening the wording here to explicitly distinguish “no PR code build/exec” from “repo checkout for workflow config.”
# only downloads build artifacts (data) and reads them — it does **not** build
# or execute PR code. (gh-aw's generated agent job **does** check out the
# repository — via `actions/checkout` — to load the workflow's own agent
# configuration; that checkout is for tooling only and uses the event's ref,
# **not** the PR head, so no PR code is built or executed.)
|
@Evangelink please take a look |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
.github/workflows/build-failure-analysis-command.md:76
- The
fetch-binlogbash implementation (ADO validation + artifact download + zip-bomb guards + binlog extraction) is effectively duplicated betweenbuild-failure-analysis.mdandbuild-failure-analysis-command.md. This duplication is likely to drift over time and makes future security/bug fixes harder to apply consistently. Consider extracting the shared logic into a single script in-repo (e.g..github/scripts/fetch-ado-binlogs.sh) that both workflows invoke.
# Custom job that reuses the binlogs from the PR's most recent failed Azure
# DevOps `arcade-pr` build instead of rebuilding. Mirrors the fetch-binlog job
# in build-failure-analysis.md; it locates the build by the PR's merge branch
# (no `check_run` payload is available on a slash command).
When the gh api .../pulls/<n> call fails or returns no data (rate limit / transient error), BASE_REF became empty and fell into the scope case's *) branch, logging the PR as base '' "out of scope" and silently skipping a valid PR for the wrong reason. Add an explicit empty-BASE_REF guard in both the check_run workflow and the /analyze-build-failure command so API/data-resolution failures are reported as such via emit_none. Lock files recompiled with gh aw v0.77.5. Co-authored-by: Copilot <[email protected]> Copilot-Session: d22ca9be-7363-4a23-a0aa-ec1d38886fab
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
.github/workflows/build-failure-analysis.md:318
- The uncompressed-size guard relies on parsing the last line of
unzip -loutput, but iftimeoutkillsunzipthe output can be partial and still end with a numeric first column (e.g., a file entry), which would undercountUNCOMPand allow a large/zip-bomb archive to reach extraction. Capture a failingunzip -l/timeout exit status (via a subshell withpipefail) and fail closed before trustingUNCOMP.
UNCOMP=$(timeout 60 unzip -l /tmp/a.zip 2>/dev/null | tail -1 | awk '{print $1}')
# Fail safe: if the uncompressed size isn't a plain integer (corrupt
# zip / unexpected or timed-out `unzip -l` output), we can't verify
# it — skip the artifact rather than let a non-numeric value bypass
# the `-gt` guard.
.github/workflows/build-failure-analysis-command.md:242
- Same issue as the auto-trigger workflow: if
timeoutkillsunzip -l, the output can be partial but still parse as a numericUNCOMP, defeating the zip-bomb/uncompressed-size guard. Fail closed by checking theunzip -l/timeout exit status (e.g., via a subshell withpipefail) before trusting the parsed value.
UNCOMP=$(timeout 60 unzip -l /tmp/a.zip 2>/dev/null | tail -1 | awk '{print $1}')
# Fail safe: if the uncompressed size isn't a plain integer (corrupt
# zip / unexpected or timed-out `unzip -l` output), we can't verify
# it — skip the artifact rather than let a non-numeric value bypass
# the `-gt` guard.
If `timeout` killed `unzip -l` mid-listing, its partial output could still
end in a numeric first column, so `tail -1 | awk '{print \}'` would parse a
per-entry size instead of the archive total and undercount UNCOMP — letting an
oversized/zip-bomb archive slip past the size guard. Run the listing pipeline
in a subshell with `pipefail` and skip the artifact on any non-zero exit
(error/timeout), rather than trusting the parsed value. Applied to both the
check_run workflow and the /analyze-build-failure command; lock files
recompiled with gh aw v0.77.5.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d22ca9be-7363-4a23-a0aa-ec1d38886fab
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/build-failure-analysis-command.md:76
- The
fetch-binlogimplementation (download + zip guards + extraction + staleness checks) is duplicated betweenbuild-failure-analysis.mdandbuild-failure-analysis-command.md. Keeping these large scripts in sync will be error-prone (e.g., security guard tweaks or API changes will likely be applied to one workflow but missed in the other). Consider factoring the shared logic into a single reusable script/composite action and calling it from both workflows, leaving only trigger-specific bits (build-id resolution vs PR-latest-build query) in each file.
# Custom job that reuses the binlogs from the PR's most recent failed Azure
# DevOps `arcade-pr` build instead of rebuilding. Mirrors the fetch-binlog job
# in build-failure-analysis.md; it locates the build by the PR's merge branch
# (no `check_run` payload is available on a slash command).
Summary
Onboards the microsoft/testfx-style Build Failure Analysis agentic (gh-aw) workflow to
dotnet/arcade, adapted to reuse the binary logs from the failed Azure DevOps build instead of rebuilding.Arcade's authoritative PR build runs on Azure DevOps (
dnceng-public/public, pipelinearcade-pr,definitionId 283) and publishes each build leg's binlog as aLogs_Build_<leg>pipeline artifact. When that build's GitHub check reports failure, this workflow downloads those already-produced binlogs (anonymously — public project) and delegates to thebuild-failure-analystagent, which queries them live via the containerizedbinlog-mcpMCP server, posts a root-cause summary comment, and attaches inlinesuggestionblocks.It performs no build of its own — no
./build.shon GitHub Actions.Files
.github/workflows/build-failure-analysis.md(+.lock.yml) —check_run: completedtrigger +workflow_dispatch.github/workflows/build-failure-analysis-command.md(+.lock.yml) —/analyze-build-failureslash command.github/workflows/shared/build-failure-analysis-shared.md— shared delegation prompt.github/agents/build-failure-analyst.agent.md— analyst agent.github/aw/actions-lock.json— action SHA pinsKey behaviors
Logs_Build_*binlog into/data/binlogs; the agent triages all legs and focuses on the one(s) with errors (test/Helix-only failures leave build binlogs clean → it says so instead of inventing fixes).main/release/*.Lock files compiled with
gh awv0.77.5 (matching the repo), LF endings.