Publish to environment error preference - #2176
Open
spetersenms wants to merge 12 commits into
Open
Conversation
…ersenms/AL-Go into publishToEnvironmentErrorPreference
The test piped an array to Should -Match, which in Pester 5 asserts that every element matches the regex. The first non-matching element (e.g. GenerateALDocArtifact=1) caused the assertion to fail even though the warning was correctly emitted. Fix by joining output with Out-String before matching, so the regex checks the combined text for the warning message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tErrorPreference # Conflicts: # RELEASENOTES.md # Scenarios/settings.md
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurable handling when manual publication finds environments but branch policies exclude them.
Changes:
- Adds
ignore,warning, anderrorbehaviors with tests. - Improves branch-policy diagnostics and workflow input logging.
- Documents the setting and release impact.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Tests/DetermineDeploymentEnvironments.Test.ps1 |
Tests all behaviors and CD exclusion. |
Scenarios/settings.md |
Documents the setting. |
RELEASENOTES.md |
Announces the behavior. |
Actions/DumpWorkflowInfo/DumpWorkflowInfo.ps1 |
Logs the selected branch. |
Actions/DetermineDeploymentEnvironments/DetermineDeploymentEnvironments.ps1 |
Implements filtering diagnostics and configured outcomes. |
Actions/.Modules/settings.schema.json |
Defines schema validation. |
Actions/.Modules/ReadSettings.psm1 |
Adds the default value. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+597
to
+601
| "noMatchingEnvironmentsAction": { | ||
| "type": "string", | ||
| "pattern": "^(ignore|warning|error)$", | ||
| "description": "Specifies what happens when deployment environments are found but all are excluded by branch policies or deployment type filters. Allowed values are ignore, warning and error. See https://aka.ms/ALGoSettings#nomatchingenvironmentsaction" | ||
| }, |
Comment on lines
+273
to
+281
| if ($deploymentSettings.BranchesFromPolicy -and $deploymentSettings.BranchesFromPolicy.Count -gt 0) { | ||
| Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (GitHub policy allows branches: $($deploymentSettings.BranchesFromPolicy -join ', '))" | ||
| } | ||
| elseif ($deploymentSettings.Branches -and $deploymentSettings.Branches.Count -gt 0) { | ||
| Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (allowed branches in settings: $($deploymentSettings.Branches -join ', '))" | ||
| } | ||
| else { | ||
| Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (no branch policy defined - only 'main' is allowed by default)" | ||
| } |
…sage - Use enum + default (ignore) instead of regex pattern for noMatchingEnvironmentsAction in settings schema - Report both GitHub policy and settings Branches allowed lists in skip message when both are configured, so the actual rejection reason is not hidden Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The combined branch-message test rendered captured output via Out-String, which word-wraps long lines at the console width. On the windows-latest (PS5) runner the wrap split 'GitHub policy allows branches: feature/*' across a newline, breaking the regex match even though production emits the correct message. Match against raw joined output lines instead. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
❔What, Why & How
New error preference setting to allow users to select what should happen if the selected environments in Publish to Environment are all excluded by branch policies or rules. Default and current behavior is to ignore, New options includes a warning, and error which will fail the workflow.
Related to issue: #2147
✅ Checklist