Skip to content

Only enable automatic Copilot review triggers when opted in - #2413

Merged
Alexander Holstrup (aholstrup1) merged 5 commits into
mainfrom
aholstrup1-review-trigger-opt-in
Oct 20, 2026
Merged

Alexander Holstrup (aholstrup1) merged 5 commits into
mainfrom
aholstrup1-review-trigger-opt-in

Conversation

@aholstrup1

Copy link
Copy Markdown
Collaborator

❔What, Why & How

Older AL-Go updaters and newly created repositories copy review workflows directly from the templates, bypassing the current updater's opt-in exclusions. Automatic triggers in those raw files therefore activate workflows before review is enabled.

Both PTE and AppSource templates now ship with only workflow_dispatch. The intake job requires a pull_request event; runner preparation requires a successful workflow_run event. Manual dispatch skips the entry jobs and their dependent jobs.

When CodeReviewAgent.enabled is true, Update AL-Go System Files adds the intake pull_request and runner workflow_run triggers using the existing YAML helper. Original event types, branch defaults/patterns, permissions, concurrency, and security gates are preserved. Disabled/missing settings still exclude or remove both files. Manual triggers remain available but do not perform reviews.

Validation:

  • Invoke-Pester -Path @('.\Tests\CheckForUpdates.Action.Test.ps1', '.\Tests\WorkflowSanitation\WorkflowFileContent.Test.ps1') -PassThru -Output None: 141 passed on PowerShell 7 and 141 passed on Windows PowerShell 5.1, using Pester 5.7.1.
  • Local historical fixture using actual v8.2 (d5c257be) file-selection/generation functions and YAML class: 8 passed. Confirms inert templates survive the old updater and reproduces automatic triggers with the pre-change templates. Settings/logging were mocked; this fixture is not committed and does not exercise live upgrade orchestration.
  • Parsed eight raw/generated YAML documents; changed PowerShell files passed parsing and ScriptAnalyzer error checks. No live workflows or paid review inference were run.

Related to issue: N/A

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

Release notes and Scenarios/settings.md are intentionally unchanged as requested. The review scenario and settings schema are updated. Telemetry is not applicable.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@aholstrup1 Alexander Holstrup (aholstrup1) changed the title Keep Copilot review templates inert until explicitly enabled Only enable automatic Copilot review triggers when opted in Oct 20, 2026
Comment thread Tests/CheckForUpdates.Action.Test.ps1 Fixed
Comment thread Tests/CheckForUpdates.Action.Test.ps1 Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@aholstrup1
Alexander Holstrup (aholstrup1) marked this pull request as ready for review October 20, 2026 14:27
Copilot AI balanced review requested due to automatic review settings October 20, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Manual intake dispatches after opt-in can trigger runner preparation and fail because no metadata artifact was uploaded.

1 open issue
What changed in this PR

Makes Copilot review workflows inert by default, with automatic triggers added only through the AL-Go updater after opt-in.

Changes:

  • Makes both templates manual-only and adds event guards.
  • Generates automatic triggers when CodeReviewAgent.enabled is true.
  • Adds regression coverage and updates setup documentation and schema metadata.
File Description
Tests/​WorkflowSanitation/​WorkflowFileContent.Test.ps1 Checks inert templates and job guards.
Tests/​CheckForUpdates.Action.Test.ps1 Tests opt-in trigger generation and file selection.
Templates/​Per Tenant Extension/​.github/​workflows/​CopilotPRReviewRunner.yaml Makes runner manual-only and guards preparation.
Templates/​Per Tenant Extension/​.github/​workflows/​CopilotPRReview.yaml Makes intake manual-only and guards execution.
Templates/​AppSource App/​.github/​workflows/​CopilotPRReviewRunner.yaml Applies matching runner changes.
Templates/​AppSource App/​.github/​workflows/​CopilotPRReview.yaml Applies matching intake changes.
Scenarios/​Agents/​CopilotCodeReview.md Explains enabling and disabling reviews.
Actions/​CheckForUpdates/​CheckForUpdates.HelperFunctions.ps1 Adds automatic triggers only after opt-in.
Actions/​.Modules/​settings.schema.json Documents the disabled default and activation behavior.

Review effort: Balanced

Comment thread Templates/Per Tenant Extension/.github/workflows/CopilotPRReviewRunner.yaml Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@aholstrup1
Alexander Holstrup (aholstrup1) merged commit 959519d into main Oct 20, 2026
65 of 72 checks passed
Alexander Holstrup (aholstrup1) added a commit that referenced this pull request Oct 21, 2026
### ❔What, Why & How

<!-- Include description of the changes that will help reviewers in
their task -->

Add E2E coverage for Copilot review orchestration and verify that
ordinary upgrades do not enable automatic review.

The new scenario creates one PTE repository, sets only
`CodeReviewAgent.enabled = true`, updates system files, and opens one PR
with a small AL change. It checks that both review workflows succeed and
the final review artifact exists. It uses default models and skills,
does not inspect AI findings or comments, and skips the Linux invocation
to avoid running the review twice. Waiting is bounded and does not rerun
reviews.

The existing upgrade test accepts absent review workflows or manual-only
workflows with event guards, accounting for older updaters that copy
template files directly. Run-count expectations are unchanged. This
follows the behavior introduced by #2413 and should run against
templates/actions containing that fix.

Local validation: 16 checks in a session-local mocked harness passed,
PowerShell parsing and PSScriptAnalyzer passed, and `git diff --check`
passed. No live E2E or paid inference was run.

Related to issue: N/A

### ✅ Checklist

- [x] Add tests (E2E, unit tests)
- [ ] Update RELEASENOTES.md - N/A, test-only change
- [ ] Update documentation (e.g. for new settings or scenarios) - N/A,
scenario steps are documented in the script header
- [ ] Add telemetry - N/A

<!-- Include more checklist entries, if needed -->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

5 participants