diff --git a/.github/workflows/build-warning-fixer.md b/.github/workflows/build-warning-fixer.md index 20d995cd03..0cfd428e38 100644 --- a/.github/workflows/build-warning-fixer.md +++ b/.github/workflows/build-warning-fixer.md @@ -44,7 +44,7 @@ steps: # 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. +You are an AI agent that uses clang-tidy warning output captured in GitHub Actions logs, proposes conservative fixes, and creates a GitHub issue with ready-to-apply git diffs. ## Current Context @@ -53,7 +53,7 @@ You are an AI agent that uses pre-collected clang-tidy warning artifacts, propos - **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` +- **Local log analysis path**: `/tmp/gh-aw/clang-tidy-warning-report` ## Your Task @@ -63,34 +63,62 @@ 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` +### 1. Retrieve logs from `clang-tidy-warning-report.yml` -Use GitHub MCP tools (not `gh`) to retrieve artifacts from the triggering run. +Use GitHub MCP tools (not `gh`) to retrieve job logs from the triggering run. Do not use `download_workflow_run_artifact`: it may be unavailable, and this workflow must operate entirely from Actions logs. 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-`. -4. Get the download URL with `github-mcp-server-actions_get` (`download_workflow_run_artifact`). -5. Download and extract locally: +2. List jobs for that run with `github-mcp-server-actions_list` (`list_workflow_jobs`). +3. Identify the job named `Build Z3 with clang-tidy warnings`. +4. Retrieve its logs with `github-mcp-server-get_job_logs` using `return_content: true` and a large `tail_lines` value so the appended summary block is included. +5. Save the returned log content locally for repeatable analysis: ```bash 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 +cat <<'EOF' > /tmp/gh-aw/clang-tidy-warning-report/build.log +$JOB_LOG_CONTENT +EOF +cp /tmp/gh-aw/clang-tidy-warning-report/build.log /tmp/gh-aw/clang-tidy-warning-report/combined.log ls -la /tmp/gh-aw/clang-tidy-warning-report ``` -Expect files such as `warnings.txt`, `build.log`, `configure.log`, `combined.log`, and `status.txt`. +The source workflow emits a marker-delimited summary near the end of the job log: + +- `CLANG_TIDY_WARNING_REPORT_BEGIN` +- `CLANG_TIDY_STATUS_BEGIN` / `CLANG_TIDY_STATUS_END` +- `CLANG_TIDY_WARNINGS_BEGIN` / `CLANG_TIDY_WARNINGS_END` +- `CLANG_TIDY_WARNING_REPORT_END` + +Extract the summary into local files: + +```bash +sed -n '/^CLANG_TIDY_STATUS_BEGIN$/,/^CLANG_TIDY_STATUS_END$/p' \ + /tmp/gh-aw/clang-tidy-warning-report/combined.log | sed '1d;$d' \ + > /tmp/gh-aw/clang-tidy-warning-report/status.txt + +sed -n '/^CLANG_TIDY_WARNINGS_BEGIN$/,/^CLANG_TIDY_WARNINGS_END$/p' \ + /tmp/gh-aw/clang-tidy-warning-report/combined.log | sed '1d;$d' \ + > /tmp/gh-aw/clang-tidy-warning-report/warnings.txt +``` + +If the marker block is missing, fall back to grepping the full log: + +```bash +grep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/clang-tidy-warning-report/combined.log \ + > /tmp/gh-aw/clang-tidy-warning-report/warnings.txt || true +``` + +Expect at minimum `build.log`, `combined.log`, and `warnings.txt`. Prefer using `status.txt` when extracted successfully. If the job log is unavailable or empty, call `noop` with a concise explanation. ### 2. Extract actionable diagnostics -Analyze artifact files from this run: +Analyze log-derived 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` +- `/tmp/gh-aw/clang-tidy-warning-report/status.txt` (when available) Use commands like: @@ -168,7 +196,7 @@ Issue content must include: - 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. +If no actionable warnings are found, or the source job logs are missing/corrupt, call `noop` with a concise explanation. ## Guidelines @@ -176,3 +204,4 @@ If no actionable warnings are found, or artifacts are missing/corrupt, call `noo - 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. +- Prefer workflow job logs over cross-run artifact downloads, even if artifact metadata is visible. diff --git a/.github/workflows/clang-tidy-warning-report.yml b/.github/workflows/clang-tidy-warning-report.yml index 7397f19ea9..76390e05ff 100644 --- a/.github/workflows/clang-tidy-warning-report.yml +++ b/.github/workflows/clang-tidy-warning-report.yml @@ -75,6 +75,23 @@ jobs: if-no-files-found: error retention-days: 7 + - name: Emit warning summary to job log + if: always() + shell: bash + run: | + echo "CLANG_TIDY_WARNING_REPORT_BEGIN" + echo "CLANG_TIDY_STATUS_BEGIN" + cat /tmp/clang-tidy-warning-report/status.txt + echo "CLANG_TIDY_STATUS_END" + echo "CLANG_TIDY_WARNINGS_BEGIN" + if [ -s /tmp/clang-tidy-warning-report/warnings.txt ]; then + cat /tmp/clang-tidy-warning-report/warnings.txt + else + echo "no warnings captured" + fi + echo "CLANG_TIDY_WARNINGS_END" + echo "CLANG_TIDY_WARNING_REPORT_END" + - name: Fail on configure or build errors if: always() shell: bash