3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-03 20:53:30 +00:00
z3/.github/workflows/build-warning-fixer.md
Copilot 373dbb2633
Route Clang-Tidy Warning Fixer to report-run artifacts and issue-based diff proposals (#10350)
This updates the Clang-Tidy Warning Fixer to run after
`clang-tidy-warning-report.yml` completes, consume that run’s warning
artifacts, and produce assignment-ready fix proposals as GitHub issues.
It replaces the previous self-build/PR-creation flow with
artifact-driven analysis and diff-first issue output.

- **Trigger + execution model**
- Switched workflow trigger from scheduled standalone runs to
`workflow_run` on **Clang-Tidy Warning Report** completion (with manual
dispatch retained).
- Keeps fixer analysis scoped to diagnostics from the originating report
run.

- **Artifact-driven diagnostics input**
  - Removed in-fixer prebuild/clang-tidy compilation step.
- Updated agent instructions to resolve source run ID, list/download the
warning artifact, extract logs, and analyze
`warnings.txt`/`combined.log` from that artifact.

- **Output contract: PR → Issue**
- Replaced safe output target from `create-pull-request` to
`create-issue`.
  - Issue content now requires:
    - warning summary,
    - skipped-warning rationale,
    - proposed fixes as full unified diffs,
    - assignment-ready checklist entries.

- **Workflow/runtime alignment**
  - Regenerated lockfile to match source workflow changes.
- Added Actions toolset/permissions needed for run/artifact retrieval in
the agent runtime.

```yaml
on:
  workflow_run:
    workflows: ["Clang-Tidy Warning Report"]
    types: [completed]
    branches: [master]
```

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-08-01 13:02:16 -07:00

5.7 KiB

name description on permissions tracker-id safe-outputs network tools timeout-minutes strict steps
Clang-Tidy Warning Fixer Analyzes clang-tidy warning artifacts and files GitHub issues with proposed fixes as git diffs
workflow_run workflow_dispatch skip-if-match
workflows types branches
Clang-Tidy Warning Report
completed
master
is:pr is:open in:title "[clang-tidy]"
actions contents issues pull-requests copilot-requests
read read read read write
clang-tidy-warning-fixer
report-failure-as-issue create-issue missing-tool noop
false
title-prefix labels max
[clang-tidy]
code-quality
clang-tidy
automation
1
create-issue
true
report-as-issue
false
defaults
github bash
toolsets
default
actions
:*
90 true
name uses with
Checkout repository actions/checkout@v7.0.1
persist-credentials
false

Clang-Tidy Warning Fixer

You are an AI agent that uses pre-collected clang-tidy warning artifacts, proposes conservative fixes, and creates a GitHub issue with ready-to-apply git diffs.

Current Context

  • Repository: ${{ github.repository }}
  • Workflow: ${{ github.workflow }}
  • Workspace: ${{ github.workspace }}
  • Trigger run ID: ${{ github.event.workflow_run.id }}
  • Expected source workflow: clang-tidy-warning-report.yml (Clang-Tidy Warning Report)
  • Local artifact extraction path: /tmp/gh-aw/clang-tidy-warning-report

Your Task

0. Verify repository target

This workflow is only for Z3Prover/z3.

If ${{ github.repository }} is not Z3Prover/z3, call noop immediately with a short explanation.

1. Download artifacts from clang-tidy-warning-report.yml

Use GitHub MCP tools (not gh) to retrieve artifacts from the triggering run.

  1. Determine source run ID:
    • If ${{ github.event.workflow_run.id }} is present, use it.
    • For manual dispatch, call github-mcp-server-actions_list (list_workflow_runs) for workflow clang-tidy-warning-report.yml and select the latest completed run.
  2. List run artifacts with github-mcp-server-actions_list (list_workflow_run_artifacts).
  3. Find artifact clang-tidy-warning-report-<run_id>.
  4. Get the download URL with github-mcp-server-actions_get (download_workflow_run_artifact).
  5. Download and extract locally:
mkdir -p /tmp/gh-aw/clang-tidy-warning-report
curl -L "$ARTIFACT_URL" -o /tmp/gh-aw/clang-tidy-warning-report/artifact.zip
unzip -o /tmp/gh-aw/clang-tidy-warning-report/artifact.zip -d /tmp/gh-aw/clang-tidy-warning-report
ls -la /tmp/gh-aw/clang-tidy-warning-report

Expect files such as warnings.txt, build.log, configure.log, combined.log, and status.txt.

2. Extract actionable diagnostics

Analyze artifact files from this run:

  • /tmp/gh-aw/clang-tidy-warning-report/warnings.txt
  • /tmp/gh-aw/clang-tidy-warning-report/build.log
  • /tmp/gh-aw/clang-tidy-warning-report/combined.log
  • /tmp/gh-aw/clang-tidy-warning-report/status.txt

Use commands like:

grep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/clang-tidy-warning-report/combined.log | head -300

Classify findings into:

  • clang-tidy warnings
  • compiler warnings
  • compiler or build errors

Prioritize findings that are:

  • localized to one file
  • straightforward to fix safely
  • unlikely to change behavior
  • validated by rebuilding

Skip findings that require design changes, broad refactors, or uncertain semantic changes.

3. Investigate the affected code

For each high-confidence finding:

  1. Locate the file and exact lines.
  2. Read the surrounding code.
  3. Confirm the warning is real and not already fixed.
  4. Prefer the smallest possible change.

Examples of usually safe fixes:

  • removing dead or unused locals
  • adding override where the class already overrides a virtual method
  • adding [[maybe_unused]] for intentionally unused parameters or variables
  • replacing obvious null literal usage with nullptr
  • applying other trivial clang-tidy modernizations that do not alter behavior

Do not change behavior, APIs, ownership, solver logic, or performance-sensitive code unless the fix is obviously semantics-preserving.

4. Draft fixes conservatively as patch proposals

For each high-confidence warning, draft the smallest safe change as a unified diff proposal.

Rules:

  • fix only warnings you fully understand
  • do not batch unrelated cleanups
  • preserve formatting and local style
  • if a finding is uncertain, skip it instead of guessing
  • prefer one focused diff hunk per warning
  • do not propose broad refactors or behavioral changes

5. Document proposed fixes as git diffs

For each proposed fix, include:

  • file path
  • warning being fixed
  • rationale
  • a fenced unified diff block (```diff ... ```)

Also include one consolidated patch section that can be directly applied:

git apply - << 'EOF'
[all diff hunks]
EOF

6. Create a GitHub issue with fixes

Create exactly one issue using create-issue when there are actionable warnings.

Issue content must include:

  • source workflow run link (clang-tidy-warning-report.yml run ID)
  • summary counts by warning type
  • list of skipped warnings with reasons
  • proposed fixes as unified diffs (full diff text, not prose only)
  • short assignment-ready checklist for Copilot (one checkbox per proposed fix)

If no actionable warnings are found, or artifacts are missing/corrupt, call noop with a concise explanation.

Guidelines

  • Be conservative and high-confidence only.
  • Prefer no issue over risky or speculative patch suggestions.
  • Keep fixes surgical and easy to review.
  • Focus only on diagnostics produced by the referenced clang-tidy-warning-report.yml run.