-
Notifications
You must be signed in to change notification settings - Fork 181
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
base: main
Are you sure you want to change the base?
Changes from 26 commits
530663c
8a356a1
e97149e
0d2f404
7cbba2e
e6a2b0d
32499d0
e0e69a4
da92269
5a00241
534f104
26a8716
8e25c3c
fac0f52
c38cd33
faa8bc7
d8bd92a
b9cf0c7
1f8ab19
d374ea9
e3fc5f3
b3b0575
1bcce32
599b797
6ab711c
bc7cfc5
b80cf2b
39bccf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" |
| 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 |
| 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 |
| 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" | ||
| } |
| 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 |
| 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 |
| 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)] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Could you please supress the following warnings as the secrets come from GitHub secrets, so they are obfuscated in logs: Parameter '$adminCenterApiCredentialsSecret' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to expose this sensitive information.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added PSScriptAnalyzer suppression for the |
||
| [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" | ||
| 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) |
| 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 |
Uh oh!
There was an error while loading. Please reload this page.