Extract PowerShell code from E2E.yaml into local actions#2029
Conversation
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
|
@copilot Would you please fix the code scanning issues, as well as the issues reported by the pre-commit check. |
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Fixed all code scanning and pre-commit issues: Pre-commit fixes:
Code quality improvements:
All pre-commit checks now pass, and scripts follow PowerShell best practices. Commit: e6a2b0d Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the E2E.yaml workflow by extracting 13 inline PowerShell code blocks into 7 reusable local composite actions, reducing the workflow file from 453 to 358 lines. The refactoring improves maintainability, reduces duplication, and adds proper error handling and PowerShell best practices to all scripts.
Key changes:
- Extracted secret validation, repository setup, test matrix generation, and test execution logic into separate actions
- Added error handling patterns with try-catch blocks and proper error propagation
- Standardized PowerShell script headers with
$ErrorActionPreference,$ProgressPreference, andSet-StrictMode
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/E2E.yaml | Replaced inline PowerShell blocks with calls to composite actions |
| .github/actions/E2ECheckSecrets/* | Action for validating required secrets and calculating test parameters |
| .github/actions/E2ESetupRepositories/* | Action for initializing test repositories |
| .github/actions/E2EAnalyze/* | Action for generating test matrices (public/private runs, releases, scenarios) |
| .github/actions/E2ECalculateRepoName/* | Action for generating random repository names |
| .github/actions/E2ECalculateTestParams/* | Action for resolving template and credential parameters |
| .github/actions/E2ERunScenario/* | Action for executing scenario tests |
| .github/actions/E2ERunTest/* | Action for executing Test-AL-Go.ps1 and Test-AL-Go-Upgrade.ps1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixed. The previous inline |
|
@copilot resolve the merge conflicts in this pull request |
Resolved. The only conflict was in |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (4)
.github/actions/E2EAnalyze/E2EAnalyze.ps1:63
- Comma-separated filters emit multiple booleans from the inner pipeline. PowerShell treats any multi-element result as true, so every scenario is selected even when none of the patterns match; the unwrapped pipeline can also become
$nullfor zero matches under StrictMode. Use an explicit any-match predicate and preserve the array shape.
$filteredScenarios = $allScenarios | Where-Object { $scenario = $_; $scenariosFilterArr | ForEach-Object { $scenario -like $_ } }
.github/actions/E2EAnalyze/E2EAnalyze.ps1:86
- If disabled-scenario filtering removes the last selected scenario, this pipeline assigns
$null; line 87 then accesses.Countunder StrictMode and terminates the Analyze job instead of producing an empty matrix. Keep the result array-wrapped as the original workflow did.
$filteredScenarios = $filteredScenarios | Where-Object { $disabledScenarios -notcontains $_ }
.github/actions/E2ERunTest/E2ERunTest.ps1:66
- Hashtable splatting does not support abbreviated parameter names.
Test-AL-Go.ps1declares$appSourceApp(line 14), so thisappSourcekey causes all normal test invocations to fail parameter binding, even when its value is false.
'appSource' = $appSource
.github/actions/E2EAnalyze/E2EAnalyze.ps1:71
- The checked-in
disabled-scenarios.jsoncurrently contains one entry.ConvertFrom-Jsonunwraps a single-element root array to a scalar, so line 78's.Countaccess throws under StrictMode and the Analyze job fails on every run. Preserve array shape when parsing the configuration.
$disabledScenariosConfig = $disabledScenariosContent | ConvertFrom-Json
- E2ERunTest: splat 'appSourceApp' (not 'appSource') so parameter binding to Test-AL-Go.ps1 / Test-AL-Go-Upgrade.ps1 does not rely on prefix matching - E2EAnalyze: check $LASTEXITCODE after 'gh release list' so a failure no longer silently produces an empty upgrade matrix - E2EAnalyze: extract scenario filtering into testable Get-E2EScenariosToRun and fix multi-filter wildcard bug where multiple comma-separated patterns matched every scenario - E2EAnalyze: document scenariosFilter input in README - Add Tests/E2EAnalyze.Test.ps1 covering zero/one/multi-match filters and disabled-scenario filtering Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: dbbb5420-42f2-4742-8db0-f2b1002a52d8
- E2EAnalyze/README.md: escape wildcard so mdformat (pre-commit) passes - E2ERunTest.ps1: forward 'private' switch in the upgrade branch so testType: upgrade with private: true creates a private repository - E2ECheckSecrets.ps1: load AL-Go-Helper and normalize orgmap.json via ConvertTo-HashTable -recurse for the standard hashtable access contract - E2EAnalyze.ps1: normalize disabled-scenarios.json recursively - Tests/E2EAnalyze.Test.ps1: use a cross-platform (forward-slash) path Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0278e4fe-f6e1-4ebe-881f-ce95f19163d2
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
.github/actions/E2ERunTest/E2ERunTest.ps1:40
- The added Pester suite only exercises scenario filtering, leaving this new test/upgrade router untested. Both branches build different splats and conditionally forward
privateand switch values—the same area where parameter-binding regressions were already found during review. Add isolated Pester cases for standard and upgrade runs that stub the target scripts and assert the complete forwarded parameter sets, includingprivate: true.
if ($testType -eq 'upgrade') {
$params = @{
Extract the matrix-to-parameter calculation in E2ECalculateTestParams into a pure, testable Get-E2ECalculatedTestParams function (following the E2EAnalyze pattern) and add Tests/E2ECalculateTestParams.Test.ps1 with table-driven cases covering PTE/AppSource templates, single/multi-project, Windows/Linux, explicit/default contentPath, and adminCenterApiCredentials forwarding. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0278e4fe-f6e1-4ebe-881f-ce95f19163d2
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/actions/E2ERunTest/E2ERunTest.ps1:40
- The new test/upgrade dispatch is not covered by Pester; the added tests only exercise Analyze and CalculateTestParams. Add wrapper tests for both
testTypebranches (includingprivateandappSourceAppforwarding), since parameter-name regressions here otherwise fail only during the destructive E2E workflow.
if ($testType -eq 'upgrade') {
$params = @{
❔What, Why & How
Refactored E2E.yaml by extracting 13 inline PowerShell code blocks into 7 reusable local composite actions, reducing the workflow file from 453 to 358 lines. This improves maintainability, reduces duplication, and adds proper error handling and PowerShell best practices to all scripts.
Created Actions (in
.github/actions/):scenariosFiltersupport and disabled scenarios filtering viae2eTests/disabled-scenarios.jsonEach action includes PowerShell script with proper error handling, action.yaml descriptor, and README documentation. All actions are placed in
.github/actions/to avoid confusion with the actions that AL-Go ships. Actions call PowerShell scripts directly without wrapper layers.Code Quality Improvements:
$ErrorActionPreference = "Stop",$ProgressPreference = "SilentlyContinue", andSet-StrictMode -Version 2.0to all PowerShell scriptsshellinputs from composite action calls (composite actions define shell in action.yaml)powershelltopwshfor Linux compatibility (Ubuntu runners don't havepowershell, onlypwsh)scenariosFilterparameter support to E2EAnalyze action for filtering scenarios by wildcard patternse2eTests/disabled-scenarios.jsonconfiguration file and filters out disabled scenarios with detailed logging about which scenarios were filtered and whyscenariosFilterworkflow input to E2EAnalyze action, enabling scenario filtering functionalityadminCenterApiCredentials,adminCenterApiCredentialsSecret,e2eAppKey,algoAuthApp,azureCredentials,e2ePrivateKey,e2eGHPackagesPAT,githubPackagesToken) - Credentials come from GitHub Actions secrets (already masked) and are passed through to test scripts without storageBug Fixes:
gh repo createto misinterpret repository names as command flags (error: "unknown switch 't'")Merge Updates:
.github/actions/as the refactoring is the core purpose of this PR✅ Checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.