---
name: "Test Reviewer on PR (on open / sync)"
description: >-
  Automatically reviews new and modified test methods when a non-draft PR
  is opened, reopened, marked ready-for-review, or pushed to — but only when
  the change touches files under `test/`. Reviews correctness, effectiveness,
  reliability, maintainability, and repository conventions; posts a compact
  scorecard plus complete, apply-ready inline suggestions.

# Triggers:
# - pull_request `opened` / `reopened` / `ready_for_review` — initial
#   review on the PR's first appearance as a non-draft.
# - pull_request `synchronize` — re-review when new commits are pushed
#   so the comment stays current. Combined with `paths` so we only fire
#   when test files change, and with `concurrency.cancel-in-progress`
#   so superseded runs are cancelled.
#
# The companion `/review-tests` slash command lives in `test-reviewer.agent.md`.
# They must remain separate workflows because mixing `slash_command` with
# other triggers makes gh-aw's activation gate always require a command
# position match, silently skipping the agent on every `pull_request`
# invocation.
on:
  pull_request:
    types: [opened, reopened, synchronize, ready_for_review]
    paths:
      - "test/**"

# Skip draft PRs and OneLocBuild localization check-in PRs (authored by
# dotnet-bot) — only run for human-authored PRs in a reviewable state.
if: >
  github.event.pull_request.draft == false
  && !(
    github.event.pull_request.user.login == 'dotnet-bot'
    && startsWith(github.event.pull_request.title, 'Localized file check-in')
  )

permissions:
  contents: read
  pull-requests: read
  copilot-requests: write

imports:
  - shared/test-reviewer-shared.md

# This workflow fires automatically on every PR open / reopen / ready-for-review
# and on every push (`synchronize`) that touches `test/**`. On a busy weekend the
# per-workflow 24h AI-credit usage aggregated across all those runs crossed the
# enterprise default of 5K, tripping the daily guardrail and failing every
# subsequent activation (see issues #9086 and #9053). Raise the daily budget so a
# busy day of PR pushes does not skip reviews.
max-daily-ai-credits: 20K

safe-outputs:
  report-failure-as-issue: false
  messages:
    footer: "> 🤖 **Automated content by GitHub Copilot.** Generated by the [{workflow_name}]({agentic_workflow_url}) workflow.{ai_credits_suffix} · [◷]({history_link})"
  noop:
    report-as-issue: false

concurrency:
  group: test-reviewer-${{ github.event.pull_request.number }}
  cancel-in-progress: true

timeout-minutes: 20
---

<!-- Body provided by shared/test-reviewer-shared.md -->
