Skip to content

Make failOn: newWarning work with workspace compilation#2300

Open
aholstrup1 wants to merge 7 commits into
mainfrom
aholstrup1-vigilant-spork
Open

Make failOn: newWarning work with workspace compilation#2300
aholstrup1 wants to merge 7 commits into
mainfrom
aholstrup1-vigilant-spork

Conversation

@aholstrup1

Copy link
Copy Markdown
Collaborator

Why

The failOn: newWarning setting fails a pull request when it introduces new AL compiler warnings, compared against the last successful build of the target branch. It only ever worked for container / compiler-folder builds. With workspaceCompilation enabled it silently did nothing, so repositories using workspace compilation (including BCApps) had no protection against newly introduced warnings.

What changed

The root cause was that the new-warning check (Test-ForNewWarnings) only ran in the RunPipeline action, but with workspace compilation the apps are compiled by the separate CompileApps action and RunPipeline runs against prebuilt apps.

  • Run the check where compilation happens. Test-ForNewWarnings is now invoked from CompileApps when workspace compilation is enabled, and RunPipeline skips it in that mode to avoid a double run. CheckForWarningsUtils.psm1 moved from Actions/RunPipeline/ to Actions/.Modules/ since it is now shared.
  • Preserve the compiler output for the baseline artifact. BcContainerHelper's Run-AlPipeline deletes its buildOutputFile at startup (unconditionally, before it looks at whether anything needs building). In workspace mode that file is the compiler output written by CompileApps and contains the warnings, so RunPipeline now passes an empty buildOutputFile to keep it intact for the uploaded build-output artifact that future PRs compare against.

Two robustness issues surfaced while validating this against BCApps and are fixed here too:

  • Parse the workspace warning format. Workspace compilation writes raw AL compiler output (File(line,col): warning ID: description) rather than the GitHub Actions annotation format (::warning file=...::). The parser now handles both, so warnings are actually detected under workspace compilation.
  • Ignore build-version churn in warning text. Some diagnostics (e.g. AL0523) embed a referenced app's version in the message. AL-Go stamps build/revision from the run number, so that version differs between the baseline and PR builds and made unchanged warnings look new. Four-part version numbers are now normalized before comparison, while the original description is still shown in the error annotation.

Testing

Added Pester coverage in Tests/CheckForWarningsUtils.Test.ps1 for both warning formats, the new-vs-removed warning cases, the version-normalization case, and the pull-request/failOn guards.

Validated end to end on a real multi-project repo (microsoft/BCApps, workspace compilation enabled): a PR that introduces one unused-variable warning fails with "New warnings were introduced" via the CompileApps path, while projects whose only diff was version-churn in warning text pass instead of failing falsely.

Note for reviewers

There is a one-time transition effect: the first PRs after this merges compare against baseline artifacts produced by the previous code, so for workspace publishing projects those baselines may be warning-less until main is rebuilt once. It self-heals after the next successful main build.

The failOn:newWarning check only ran in RunPipeline, so it had no effect when workspaceCompilation was enabled (compilation happens in CompileApps there). Move CheckForWarningsUtils to .Modules, call Test-ForNewWarnings from CompileApps, and preserve the compiler BuildOutput.txt by not letting Run-AlPipeline delete it in workspace mode. Adds Pester tests.
Get-Warnings only matched the container GitHub-annotation format (::warning file=...::). Workspace compilation writes raw AL compiler output (<file>(<line>,<col>): warning <Id>: <desc>) to BuildOutput.txt, so new warnings were never detected under workspace compilation. Parse both formats. Adds Pester coverage.
Some AL diagnostics (e.g. AL0523) embed a referenced app's version in the warning message. AL-Go stamps build/revision from the run number, so the version differs between the baseline and PR builds, making an unchanged warning look new. Normalize 4-part version numbers in the description before comparing (keeping Id, File, Col). Adds a Pester test for the version-churn case.
Collapse the workspace-mode buildOutputFile guard in RunPipeline to a single assignment, and de-duplicate the two identical Get-Warnings branches into one body driven by a list of patterns. No behavior change; tests unchanged.
@aholstrup1 aholstrup1 requested a review from a team as a code owner July 3, 2026 08:29
Copilot AI review requested due to automatic review settings July 3, 2026 08:29

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.

Pull request overview

This pull request makes the failOn: newWarning policy effective when workspaceCompilation is enabled by running the new-warning comparison at the point where compiler output is actually produced, and by improving warning parsing/normalization so baseline-vs-PR comparisons are stable.

Changes:

  • Run Test-ForNewWarnings from CompileApps in workspace compilation mode, and skip the check in RunPipeline to avoid double execution.
  • Preserve BuildOutput.txt in workspace mode by preventing Run-AlPipeline from deleting it at startup.
  • Extend warning detection to parse both GitHub Actions annotation warnings and raw AL compiler warnings, and normalize embedded 4-part version numbers to reduce false “new warning” detections.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/CheckForWarningsUtils.Test.ps1 Adds Pester coverage for both warning formats, new/removed warning comparisons, and version normalization.
RELEASENOTES.md Documents that failOn: newWarning now works with workspace compilation and describes the parsing/normalization improvements.
Actions/RunPipeline/RunPipeline.ps1 Avoids deleting workspace-produced BuildOutput.txt and skips the new-warning check when workspace compilation is enabled.
Actions/CompileApps/Compile.ps1 Invokes Test-ForNewWarnings after workspace compilation to enforce failOn: newWarning where warnings are generated.
Actions/.Modules/CheckForWarningsUtils.psm1 Adds warning-format parsing support for workspace output and normalizes volatile version strings before comparison.

Normalize path separators when parsing warnings so the same warning matches across container (forward slash) and workspace (backslash) compilation formats, avoiding false new-warning hits when a project switches compilation mode. Add direct tests for Get-NormalizedWarningDescription, a cross-format regression test, and Description assertions in the parser tests.
@aholstrup1 aholstrup1 enabled auto-merge (squash) July 3, 2026 11:24
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.

3 participants