-
Notifications
You must be signed in to change notification settings - Fork 174
Extract PowerShell code from E2E.yaml into local actions #2029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
10
commits into
main
Choose a base branch
from
copilot/extract-powershell-code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
530663c
Initial plan
Copilot 8a356a1
Extract PowerShell code from E2E.yaml into local actions
Copilot e97149e
Add README documentation for new E2E actions
Copilot 0d2f404
Move E2E actions from Actions/ to .github/actions/
Copilot 7cbba2e
Remove Invoke-AlGoAction.ps1 wrapper and call scripts directly
Copilot e6a2b0d
Fix code scanning and pre-commit issues in E2E actions
Copilot 32499d0
Remove invalid shell inputs and fix duplicate contentPath logic
Copilot e0e69a4
Merge branch 'main' into copilot/extract-powershell-code
mazhelez da92269
Fix E2E failure: change default shell from 'powershell' to 'pwsh' for…
Copilot 5a00241
Add scenariosFilter parameter support to E2EAnalyze action
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| Param( | ||
| [Parameter(HelpMessage = "Maximum parallel jobs", Mandatory = $true)] | ||
| [int] $maxParallel, | ||
| [Parameter(HelpMessage = "Test upgrades from version", Mandatory = $false)] | ||
| [string] $testUpgradesFromVersion = 'v5.0', | ||
| [Parameter(HelpMessage = "Filter to run specific scenarios (separated by comma, supports wildcards)", Mandatory = $false)] | ||
| [string] $scenariosFilter = '*' | ||
| ) | ||
|
|
||
| $ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 | ||
| $modulePath = Join-Path "." "e2eTests/e2eTestHelper.psm1" -resolve | ||
| Import-Module $modulePath -DisableNameChecking | ||
|
|
||
| $publicTestruns = @{ | ||
| "max-parallel" = $maxParallel | ||
| "fail-fast" = $false | ||
| "matrix" = @{ | ||
| "include" = @() | ||
| } | ||
| } | ||
| $privateTestruns = @{ | ||
| "max-parallel" = $maxParallel | ||
| "fail-fast" = $false | ||
| "matrix" = @{ | ||
| "include" = @() | ||
| } | ||
| } | ||
| @('appSourceApp','PTE') | ForEach-Object { | ||
| $type = $_ | ||
| @('linux','windows') | ForEach-Object { | ||
| $os = $_ | ||
| @('multiProject','singleProject') | ForEach-Object { | ||
| $style = $_ | ||
| $publicTestruns.matrix.include += @{ "type" = $type; "os" = $os; "style" = $style; "Compiler" = "Container" } | ||
| $privateTestruns.matrix.include += @{ "type" = $type; "os" = $os; "style" = $style; "Compiler" = "Container" } | ||
| if ($type -eq "PTE") { | ||
| # Run end 2 end tests using CompilerFolder with Windows+Linux and single/multiproject | ||
| $publicTestruns.matrix.include += @{ "type" = $type; "os" = $os; "style" = $style; "Compiler" = "CompilerFolder" } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $publicTestrunsJson = $publicTestruns | ConvertTo-Json -depth 99 -compress | ||
| $privateTestrunsJson = $privateTestruns | ConvertTo-Json -depth 99 -compress | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "publictestruns=$publicTestrunsJson" | ||
| Write-Host "publictestruns=$publicTestrunsJson" | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "privatetestruns=$privateTestrunsJson" | ||
| Write-Host "privatetestruns=$privateTestrunsJson" | ||
|
|
||
| $releases = @(gh release list --repo microsoft/AL-Go | ForEach-Object { $_.split("`t")[0] }) | Where-Object { [Version]($_.trimStart('v')) -ge [Version]($testUpgradesFromVersion.TrimStart('v')) } | ||
| $releasesJson = @{ | ||
| "matrix" = @{ | ||
| "include" = @($releases | ForEach-Object { @{ "Release" = $_; "type" = 'appSourceApp' }; @{ "Release" = $_; "type" = 'PTE' } } ) | ||
| }; | ||
| "max-parallel" = $maxParallel | ||
| "fail-fast" = $false | ||
| } | ConvertTo-Json -depth 99 -compress | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "releases=$releasesJson" | ||
| Write-Host "releases=$releasesJson" | ||
|
|
||
| $scenariosFilterArr = $scenariosFilter -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' } | ||
| $allScenarios = @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE "e2eTests/scenarios/*/runtest.ps1") | ForEach-Object { $_.Directory.Name }) | ||
| $filteredScenarios = $allScenarios | Where-Object { $scenario = $_; $scenariosFilterArr | ForEach-Object { $scenario -like $_ } } | ||
|
|
||
| $scenariosJson = @{ | ||
| "matrix" = @{ | ||
| "include" = @($filteredScenarios | ForEach-Object { @{ "Scenario" = $_ } }) | ||
| }; | ||
| "max-parallel" = $maxParallel | ||
| "fail-fast" = $false | ||
| } | ConvertTo-Json -depth 99 -compress | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "scenarios=$scenariosJson" | ||
| Write-Host "scenarios=$scenariosJson" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # E2E Analyze | ||
|
|
||
| Analyzes and generates test matrices for E2E testing including public/private test runs, releases, and scenarios. | ||
|
|
||
| ## Inputs | ||
|
|
||
| - `maxParallel`: Maximum parallel jobs | ||
| - `testUpgradesFromVersion`: Test upgrades from version (default: 'v5.0') | ||
| - `token`: GitHub token with permissions to read releases | ||
|
|
||
| ## Outputs | ||
|
|
||
| - `publictestruns`: Public test runs matrix | ||
| - `privatetestruns`: Private test runs matrix | ||
| - `releases`: Releases matrix | ||
| - `scenarios`: Scenarios matrix |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: E2E Analyze | ||
| author: Microsoft Corporation | ||
| inputs: | ||
| shell: | ||
| description: Shell in which you want to run the action (powershell or pwsh) | ||
| required: false | ||
| default: pwsh | ||
| maxParallel: | ||
| description: Maximum parallel jobs | ||
| required: true | ||
| testUpgradesFromVersion: | ||
| description: Test upgrades from version | ||
| required: false | ||
| default: 'v5.0' | ||
| scenariosFilter: | ||
| description: Filter to run specific scenarios (separated by comma, supports wildcards) | ||
| required: false | ||
| default: '*' | ||
| token: | ||
| description: GitHub token with permissions to read releases | ||
| required: true | ||
| outputs: | ||
| publictestruns: | ||
| description: Public test runs matrix | ||
| value: ${{ steps.run.outputs.publictestruns }} | ||
| privatetestruns: | ||
| description: Private test runs matrix | ||
| value: ${{ steps.run.outputs.privatetestruns }} | ||
| releases: | ||
| description: Releases matrix | ||
| value: ${{ steps.run.outputs.releases }} | ||
| scenarios: | ||
| description: Scenarios matrix | ||
| value: ${{ steps.run.outputs.scenarios }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: run | ||
| id: run | ||
| shell: ${{ inputs.shell }} | ||
| env: | ||
| _maxParallel: ${{ inputs.maxParallel }} | ||
| _testUpgradesFromVersion: ${{ inputs.testUpgradesFromVersion }} | ||
| _scenariosFilter: ${{ inputs.scenariosFilter }} | ||
| GH_TOKEN: ${{ inputs.token }} | ||
| run: | | ||
| ${{ github.action_path }}/E2EAnalyze.ps1 -maxParallel ([int]$ENV:_maxParallel) -testUpgradesFromVersion $ENV:_testUpgradesFromVersion -scenariosFilter $ENV:_scenariosFilter | ||
| branding: | ||
| icon: activity | ||
| color: blue |
12 changes: 12 additions & 0 deletions
12
.github/actions/E2ECalculateRepoName/E2ECalculateRepoName.ps1
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Param( | ||
| [Parameter(HelpMessage = "GitHub owner for test repositories", Mandatory = $false)] | ||
| [string] $githubOwner = '' | ||
| ) | ||
|
|
||
| $ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 | ||
| $reponame = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetTempFileName()) | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "repoName=$repoName" | ||
| Write-Host "repoName=$repoName" | ||
| if ($githubOwner) { | ||
| Write-Host "Repo URL: https://github.com/$githubOwner/$repoName" | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # E2E Calculate Repo Name | ||
|
|
||
| Generates a random repository name for E2E testing. | ||
|
|
||
| ## Inputs | ||
|
|
||
| - `githubOwner`: GitHub owner for test repositories (optional, for logging purposes) | ||
|
|
||
| ## Outputs | ||
|
|
||
| - `repoName`: Generated repository name |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: E2E Calculate Repo Name | ||
| author: Microsoft Corporation | ||
| inputs: | ||
| shell: | ||
| description: Shell in which you want to run the action (powershell or pwsh) | ||
| required: false | ||
| default: pwsh | ||
| githubOwner: | ||
| description: GitHub owner for test repositories (optional, for logging purposes) | ||
| required: false | ||
| default: '' | ||
| outputs: | ||
| repoName: | ||
| description: Generated repository name | ||
| value: ${{ steps.run.outputs.repoName }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: run | ||
| id: run | ||
| shell: ${{ inputs.shell }} | ||
| env: | ||
| _githubOwner: ${{ inputs.githubOwner }} | ||
| run: | | ||
| ${{ github.action_path }}/E2ECalculateRepoName.ps1 -githubOwner $ENV:_githubOwner | ||
| branding: | ||
| icon: hash | ||
| color: blue |
67 changes: 67 additions & 0 deletions
67
.github/actions/E2ECalculateTestParams/E2ECalculateTestParams.ps1
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| Param( | ||
| [Parameter(HelpMessage = "GitHub owner for test repositories", Mandatory = $true)] | ||
| [string] $githubOwner, | ||
| [Parameter(HelpMessage = "Matrix type (PTE or appSourceApp)", Mandatory = $false)] | ||
| [string] $matrixType = '', | ||
| [Parameter(HelpMessage = "Matrix style (singleProject or multiProject)", Mandatory = $false)] | ||
| [string] $matrixStyle = '', | ||
| [Parameter(HelpMessage = "Matrix OS (windows or linux)", Mandatory = $false)] | ||
| [string] $matrixOs = '', | ||
| [Parameter(HelpMessage = "Admin center API credentials secret", Mandatory = $false)] | ||
| [string] $adminCenterApiCredentialsSecret = '', | ||
| [Parameter(HelpMessage = "AppSource app repository template", Mandatory = $true)] | ||
| [string] $appSourceAppRepo, | ||
| [Parameter(HelpMessage = "Per-tenant extension repository template", Mandatory = $true)] | ||
| [string] $perTenantExtensionRepo, | ||
| [Parameter(HelpMessage = "Content path (for upgrade tests)", Mandatory = $false)] | ||
| [string] $contentPath = '' | ||
| ) | ||
|
|
||
| $ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 | ||
|
|
||
| # Calculate adminCenterApiCredentials | ||
| $adminCenterApiCredentials = '' | ||
| if ($matrixType -eq 'PTE' -and $matrixStyle -eq 'singleProject' -and $matrixOs -eq 'windows') { | ||
| $adminCenterApiCredentials = $adminCenterApiCredentialsSecret | ||
| } | ||
|
|
||
| # Calculate template | ||
| $template = '' | ||
| if ($matrixType -eq 'appSourceApp') { | ||
| $template = "$githubOwner/$appSourceAppRepo" | ||
| } | ||
| elseif ($matrixType -eq 'PTE') { | ||
| $template = "$githubOwner/$perTenantExtensionRepo" | ||
| } | ||
|
|
||
| # Calculate contentPath if not provided | ||
| if (-not $contentPath -and $matrixType) { | ||
| if ($matrixType -eq 'appSourceApp') { | ||
| $contentPath = 'appsourceapp' | ||
| } | ||
| else { | ||
| $contentPath = 'pte' | ||
| } | ||
| } | ||
|
|
||
| # Add outputs | ||
| if ($adminCenterApiCredentials) { | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "adminCenterApiCredentials='$adminCenterApiCredentials'" | ||
| } | ||
| else { | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "adminCenterApiCredentials=''" | ||
| } | ||
|
|
||
| if ($template) { | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "template='$template'" | ||
| } | ||
|
|
||
| if ($contentPath) { | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "contentPath='$contentPath'" | ||
| } | ||
|
|
||
| # Generate repo name | ||
| $reponame = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetTempFileName()) | ||
| Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "repoName='$repoName'" | ||
| Write-Host "repoName='$repoName'" | ||
| Write-Host "Repo URL: https://github.com/$githubOwner/$repoName" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # E2E Calculate Test Parameters | ||
|
|
||
| Calculates test parameters including template repository, admin center credentials, and repository name based on matrix configuration. | ||
|
|
||
| ## Inputs | ||
|
|
||
| - `githubOwner`: GitHub owner for test repositories | ||
| - `matrixType`: Matrix type (PTE or appSourceApp) | ||
| - `matrixStyle`: Matrix style (singleProject or multiProject) | ||
| - `matrixOs`: Matrix OS (windows or linux) | ||
| - `adminCenterApiCredentialsSecret`: Admin center API credentials secret | ||
| - `appSourceAppRepo`: AppSource app repository template | ||
| - `perTenantExtensionRepo`: Per-tenant extension repository template | ||
| - `contentPath`: Content path (for upgrade tests) | ||
|
|
||
| ## Outputs | ||
|
|
||
| - `adminCenterApiCredentials`: Calculated admin center API credentials | ||
| - `template`: Calculated template repository | ||
| - `repoName`: Generated repository name | ||
| - `contentPath`: Content path (for upgrade tests) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: E2E Calculate Test Parameters | ||
| author: Microsoft Corporation | ||
| inputs: | ||
| shell: | ||
| description: Shell in which you want to run the action (powershell or pwsh) | ||
| required: false | ||
| default: pwsh | ||
| githubOwner: | ||
| description: GitHub owner for test repositories | ||
| required: true | ||
| matrixType: | ||
| description: Matrix type (PTE or appSourceApp) | ||
| required: false | ||
| default: '' | ||
| matrixStyle: | ||
| description: Matrix style (singleProject or multiProject) | ||
| required: false | ||
| default: '' | ||
| matrixOs: | ||
| description: Matrix OS (windows or linux) | ||
| required: false | ||
| default: '' | ||
| adminCenterApiCredentialsSecret: | ||
| description: Admin center API credentials secret | ||
| required: false | ||
| default: '' | ||
| appSourceAppRepo: | ||
| description: AppSource app repository template | ||
| required: true | ||
| perTenantExtensionRepo: | ||
| description: Per-tenant extension repository template | ||
| required: true | ||
| contentPath: | ||
| description: Content path (for upgrade tests) | ||
| required: false | ||
| default: '' | ||
| outputs: | ||
| adminCenterApiCredentials: | ||
| description: Calculated admin center API credentials | ||
| value: ${{ steps.run.outputs.adminCenterApiCredentials }} | ||
| template: | ||
| description: Calculated template repository | ||
| value: ${{ steps.run.outputs.template }} | ||
| repoName: | ||
| description: Generated repository name | ||
| value: ${{ steps.run.outputs.repoName }} | ||
| contentPath: | ||
| description: Content path (for upgrade tests) | ||
| value: ${{ steps.run.outputs.contentPath }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: run | ||
| id: run | ||
| shell: ${{ inputs.shell }} | ||
| env: | ||
| _githubOwner: ${{ inputs.githubOwner }} | ||
| _matrixType: ${{ inputs.matrixType }} | ||
| _matrixStyle: ${{ inputs.matrixStyle }} | ||
| _matrixOs: ${{ inputs.matrixOs }} | ||
| _adminCenterApiCredentialsSecret: ${{ inputs.adminCenterApiCredentialsSecret }} | ||
| _appSourceAppRepo: ${{ inputs.appSourceAppRepo }} | ||
| _perTenantExtensionRepo: ${{ inputs.perTenantExtensionRepo }} | ||
| _contentPath: ${{ inputs.contentPath }} | ||
| run: | | ||
| ${{ github.action_path }}/E2ECalculateTestParams.ps1 -githubOwner $ENV:_githubOwner -matrixType $ENV:_matrixType -matrixStyle $ENV:_matrixStyle -matrixOs $ENV:_matrixOs -adminCenterApiCredentialsSecret $ENV:_adminCenterApiCredentialsSecret -appSourceAppRepo $ENV:_appSourceAppRepo -perTenantExtensionRepo $ENV:_perTenantExtensionRepo -contentPath $ENV:_contentPath | ||
| branding: | ||
| icon: settings | ||
| color: blue |
Oops, something went wrong.
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.
Check warning
Code scanning / PSScriptAnalyzer
Parameter '$adminCenterApiCredentialsSecret' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to expose this sensitive information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please, fix