Skip to content

Add Copilot Autofix Workflow for Test Failure Remediation#962

Open
muldercw wants to merge 7 commits intomasterfrom
copilot-auto-issues
Open

Add Copilot Autofix Workflow for Test Failure Remediation#962
muldercw wants to merge 7 commits intomasterfrom
copilot-auto-issues

Conversation

@muldercw
Copy link
Contributor

@muldercw muldercw commented Feb 26, 2026

Summary

This PR adds a Copilot Autofix GitHub Actions workflow that automatically analyzes test failures on pull requests and posts fix suggestions directly on the failing PR.

What Changed (Latest)

The workflow was completely reworked from a generic "scan code and create issues" approach to a targeted test-failure autofix model:

Before After
Triggered on every push to master Triggers only on Run tests workflow completion
Created new GitHub issues for detected problems Posts fix suggestions on the existing PR
Generic code analysis (bugs, smells, tech debt) Focused on making failing tests pass
Named copilot-auto-issues Renamed to copilot-autofix

Workflow Behavior

Triggers:

  • workflow_run completion for the Run tests workflow (on master branch)
  • Manual dispatch via Actions tab

On test failure, Copilot will:

  1. Gate on failure - if tests passed, exit immediately (no noise)
  2. Find the associated PR - only acts on PRs, skips direct pushes
  3. Download test artifacts - parses JUnit XML (test-results-*) for failing test paths, errors, stack traces, and platform info
  4. Analyze root causes - checks out the failing commit, traces errors back to source code
  5. Post fix suggestions on the PR - using GitHub suggestion blocks (one-click accept) with:
    • Link to the failed workflow run
    • Test failure count and affected platforms
    • Root cause explanation for each failure group
    • Exact code suggestions with suggestion blocks
  6. Stay scoped - only fixes what's needed to make tests pass; no unrelated refactoring

Scope rules:

  • Fix only what's needed to make failing tests pass
  • Never weaken test assertions - fix the source instead
  • Group multiple failures with the same root cause
  • Flag unclear or risky fixes rather than guessing
  • Note merge conflicts for manual resolution

Files

File Purpose
.github/workflows/copilot-autofix.md Workflow definition (human-editable source)
.github/workflows/copilot-autofix.lock.yml Compiled GitHub Actions workflow (auto-generated by gh aw compile)
.github/aw/actions-lock.json Pinned action versions for reproducible builds
.gitattributes Marks .lock.yml as linguist-generated, merge strategy ours

Security

  • Fork validation: workflow_run triggers guarded against fork-based attacks
  • Zizmor annotations: Dangerous trigger usage documented
  • Minimal permissions: contents: read, pull-requests: read, actions: read
  • Rate limiting: Max 10 comments per workflow run
  • Input sanitization: All user-facing text validated and sanitized

Testing

  • Workflow compiles successfully via gh aw compile
  • Can be tested manually via gh aw run copilot-autofix
  • Will activate automatically on the next Run tests failure on a PR

Related

  • Uses gh-aw v0.50.4
  • Pinned actions: actions/github-script@v8, github/gh-aw/actions/setup@v0.50.4

- Add GitHub Actions workflow (copilot-auto-issues) triggered on push to master and manual dispatch
- Workflow analyzes commits for bugs, security issues, code smells, missing tests, docs gaps, and performance problems
- Automatically creates labeled GitHub issues with detailed context, reproduction steps, and suggested fixes
- Includes compiled lock.yml workflow definition generated by gh-aw
- Add .gitattributes for linguist-generated marking of lock files
- Add actions-lock.json for pinned action versions
@github-actions
Copy link

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 69%
clarifai.cli.templates 46%
clarifai.client 65%
clarifai.client.auth 67%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 80%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.rag 0%
clarifai.runners 52%
clarifai.runners.models 64%
clarifai.runners.pipeline_steps 39%
clarifai.runners.pipelines 71%
clarifai.runners.utils 62%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 61%
clarifai.utils.evaluation 16%
clarifai.workflows 95%
Summary 62% (10128 / 16415)

Minimum allowed line rate is 50%

- Change trigger from push-to-master to workflow_run (Run tests, CodeQL, dynamic)
- Add fork validation and dangerous-triggers security annotations
- Add workflow_run HTML URL to environment for issue context
- Simplify concurrency group to workflow-level
Replaced the generic code-analysis-and-issue-creation workflow with a
targeted autofix workflow that responds to test failures on PRs:

- Renamed workflow from copilot-auto-issues to copilot-autofix
- Triggers on 'Run tests' workflow_run completion (not push)
- Gates on failure conclusion — does nothing when tests pass
- Posts fix suggestions directly on the failing PR (not new issues)
- Uses GitHub suggestion blocks for one-click acceptance
- Analyzes JUnit XML test artifacts to identify root causes
- Scoped to only fix what's needed to make failing tests pass
@muldercw muldercw changed the title Add Copilot Auto-Issues Workflow for Automated Code Analysis Add Copilot Autofix Workflow for Test Failure Remediation Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant