diff --git a/.github/actions/E2EAnalyze/E2EAnalyze.ps1 b/.github/actions/E2EAnalyze/E2EAnalyze.ps1 new file mode 100644 index 000000000..a2d32fc2f --- /dev/null +++ b/.github/actions/E2EAnalyze/E2EAnalyze.ps1 @@ -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" diff --git a/.github/actions/E2EAnalyze/README.md b/.github/actions/E2EAnalyze/README.md new file mode 100644 index 000000000..5061596d9 --- /dev/null +++ b/.github/actions/E2EAnalyze/README.md @@ -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 diff --git a/.github/actions/E2EAnalyze/action.yaml b/.github/actions/E2EAnalyze/action.yaml new file mode 100644 index 000000000..f05bd6da6 --- /dev/null +++ b/.github/actions/E2EAnalyze/action.yaml @@ -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 diff --git a/.github/actions/E2ECalculateRepoName/E2ECalculateRepoName.ps1 b/.github/actions/E2ECalculateRepoName/E2ECalculateRepoName.ps1 new file mode 100644 index 000000000..9c5c7bfa8 --- /dev/null +++ b/.github/actions/E2ECalculateRepoName/E2ECalculateRepoName.ps1 @@ -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" +} diff --git a/.github/actions/E2ECalculateRepoName/README.md b/.github/actions/E2ECalculateRepoName/README.md new file mode 100644 index 000000000..28be7d270 --- /dev/null +++ b/.github/actions/E2ECalculateRepoName/README.md @@ -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 diff --git a/.github/actions/E2ECalculateRepoName/action.yaml b/.github/actions/E2ECalculateRepoName/action.yaml new file mode 100644 index 000000000..fd94339b8 --- /dev/null +++ b/.github/actions/E2ECalculateRepoName/action.yaml @@ -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 diff --git a/.github/actions/E2ECalculateTestParams/E2ECalculateTestParams.ps1 b/.github/actions/E2ECalculateTestParams/E2ECalculateTestParams.ps1 new file mode 100644 index 000000000..f468ad773 --- /dev/null +++ b/.github/actions/E2ECalculateTestParams/E2ECalculateTestParams.ps1 @@ -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" diff --git a/.github/actions/E2ECalculateTestParams/README.md b/.github/actions/E2ECalculateTestParams/README.md new file mode 100644 index 000000000..e9a5aadf3 --- /dev/null +++ b/.github/actions/E2ECalculateTestParams/README.md @@ -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) diff --git a/.github/actions/E2ECalculateTestParams/action.yaml b/.github/actions/E2ECalculateTestParams/action.yaml new file mode 100644 index 000000000..9305f7b49 --- /dev/null +++ b/.github/actions/E2ECalculateTestParams/action.yaml @@ -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 diff --git a/.github/actions/E2ECheckSecrets/E2ECheckSecrets.ps1 b/.github/actions/E2ECheckSecrets/E2ECheckSecrets.ps1 new file mode 100644 index 000000000..73fb0a44c --- /dev/null +++ b/.github/actions/E2ECheckSecrets/E2ECheckSecrets.ps1 @@ -0,0 +1,58 @@ +Param( + [Parameter(HelpMessage = "GitHub owner (defaults to current repository owner)", Mandatory = $false)] + [string] $githubOwner = '', + [Parameter(HelpMessage = "E2E_APP_ID variable value", Mandatory = $false)] + [string] $e2eAppId = '', + [Parameter(HelpMessage = "E2E_PRIVATE_KEY secret value", Mandatory = $false)] + [string] $e2ePrivateKey = '', + [Parameter(HelpMessage = "ALGOAUTHAPP secret value", Mandatory = $false)] + [string] $algoAuthApp = '', + [Parameter(HelpMessage = "adminCenterApiCredentials secret value", Mandatory = $false)] + [string] $adminCenterApiCredentials = '', + [Parameter(HelpMessage = "E2E_GHPackagesPAT secret value", Mandatory = $false)] + [string] $e2eGHPackagesPAT = '', + [Parameter(HelpMessage = "E2EAZURECREDENTIALS secret value", Mandatory = $false)] + [string] $e2eAzureCredentials = '' +) + +$ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + +$err = $false +if (($e2eAppId -eq '') -or ($e2ePrivateKey -eq '')){ + Write-Host "::Error::In order to run end to end tests, you need a Secret called E2E_PRIVATE_KEY and a variable called E2E_APP_ID." + $err = $true +} +if ($algoAuthApp -eq '') { + Write-Host "::Error::In order to run end to end tests, you need a Secret called ALGOAUTHAPP" + $err = $true +} +if ($adminCenterApiCredentials -eq '') { + Write-Host "::Error::In order to run end to end tests, you need a Secret called adminCenterApiCredentials" + $err = $true +} +if ($e2eGHPackagesPAT -eq '') { + Write-Host "::Error::In order to run end to end tests, you need a secret called E2E_GHPackagesPAT" + $err = $true +} +if ($e2eAzureCredentials -eq '') { + Write-Host "::Error::In order to run end to end tests, you need a secret called E2EAZURECREDENTIALS" + $err = $true +} +if ($err) { + exit 1 +} +$maxParallel = 99 +if (!($githubOwner)) { + $githubOwner = $ENV:GITHUB_REPOSITORY_OWNER +} +$orgmap = Get-Content -path (Join-Path "." "e2eTests/orgmap.json") -encoding UTF8 -raw | ConvertFrom-Json +if ($orgmap.PSObject.Properties.Name -eq $githubOwner) { + $githubOwner = $orgmap."$githubOwner" +} +if ($githubOwner -eq $ENV:GITHUB_REPOSITORY_OWNER) { + $maxParallel = 8 +} +Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "maxParallel=$maxParallel" +Write-Host "maxParallel=$maxParallel" +Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "githubOwner=$githubOwner" +Write-Host "githubOwner=$githubOwner" diff --git a/.github/actions/E2ECheckSecrets/README.md b/.github/actions/E2ECheckSecrets/README.md new file mode 100644 index 000000000..23111251c --- /dev/null +++ b/.github/actions/E2ECheckSecrets/README.md @@ -0,0 +1,18 @@ +# E2E Check Secrets + +Validates that all required secrets and variables are configured for E2E testing. + +## Inputs + +- `githubOwner`: GitHub owner (defaults to current repository owner) +- `e2eAppId`: E2E_APP_ID variable value +- `e2ePrivateKey`: E2E_PRIVATE_KEY secret value +- `algoAuthApp`: ALGOAUTHAPP secret value +- `adminCenterApiCredentials`: adminCenterApiCredentials secret value +- `e2eGHPackagesPAT`: E2E_GHPackagesPAT secret value +- `e2eAzureCredentials`: E2EAZURECREDENTIALS secret value + +## Outputs + +- `maxParallel`: Maximum number of parallel jobs +- `githubOwner`: GitHub owner for test repositories diff --git a/.github/actions/E2ECheckSecrets/action.yaml b/.github/actions/E2ECheckSecrets/action.yaml new file mode 100644 index 000000000..806a1da55 --- /dev/null +++ b/.github/actions/E2ECheckSecrets/action.yaml @@ -0,0 +1,61 @@ +name: E2E Check Secrets +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 (defaults to current repository owner) + required: false + default: '' + e2eAppId: + description: E2E_APP_ID variable value + required: false + default: '' + e2ePrivateKey: + description: E2E_PRIVATE_KEY secret value + required: false + default: '' + algoAuthApp: + description: ALGOAUTHAPP secret value + required: false + default: '' + adminCenterApiCredentials: + description: adminCenterApiCredentials secret value + required: false + default: '' + e2eGHPackagesPAT: + description: E2E_GHPackagesPAT secret value + required: false + default: '' + e2eAzureCredentials: + description: E2EAZURECREDENTIALS secret value + required: false + default: '' +outputs: + maxParallel: + description: Maximum number of parallel jobs + value: ${{ steps.run.outputs.maxParallel }} + githubOwner: + description: GitHub owner for test repositories + value: ${{ steps.run.outputs.githubOwner }} +runs: + using: composite + steps: + - name: run + id: run + shell: ${{ inputs.shell }} + env: + _githubOwner: ${{ inputs.githubOwner }} + _e2eAppId: ${{ inputs.e2eAppId }} + _e2ePrivateKey: ${{ inputs.e2ePrivateKey }} + _algoAuthApp: ${{ inputs.algoAuthApp }} + _adminCenterApiCredentials: ${{ inputs.adminCenterApiCredentials }} + _e2eGHPackagesPAT: ${{ inputs.e2eGHPackagesPAT }} + _e2eAzureCredentials: ${{ inputs.e2eAzureCredentials }} + run: | + ${{ github.action_path }}/E2ECheckSecrets.ps1 -githubOwner $ENV:_githubOwner -e2eAppId $ENV:_e2eAppId -e2ePrivateKey $ENV:_e2ePrivateKey -algoAuthApp $ENV:_algoAuthApp -adminCenterApiCredentials $ENV:_adminCenterApiCredentials -e2eGHPackagesPAT $ENV:_e2eGHPackagesPAT -e2eAzureCredentials $ENV:_e2eAzureCredentials +branding: + icon: check-circle + color: blue diff --git a/.github/actions/E2ERunScenario/E2ERunScenario.ps1 b/.github/actions/E2ERunScenario/E2ERunScenario.ps1 new file mode 100644 index 000000000..77bd92bea --- /dev/null +++ b/.github/actions/E2ERunScenario/E2ERunScenario.ps1 @@ -0,0 +1,56 @@ +Param( + [Parameter(HelpMessage = "Scenario name", Mandatory = $true)] + [string] $scenario, + [Parameter(HelpMessage = "Run on Linux", Mandatory = $false)] + [bool] $linux = $false, + [Parameter(HelpMessage = "GitHub owner", Mandatory = $true)] + [string] $githubOwner, + [Parameter(HelpMessage = "Repository name", Mandatory = $true)] + [string] $repoName, + [Parameter(HelpMessage = "E2E App ID", Mandatory = $true)] + [string] $e2eAppId, + [Parameter(HelpMessage = "E2E App Key", Mandatory = $true)] + [string] $e2eAppKey, + [Parameter(HelpMessage = "ALGO Auth App", Mandatory = $true)] + [string] $algoAuthApp, + [Parameter(HelpMessage = "PTE template", Mandatory = $true)] + [string] $pteTemplate, + [Parameter(HelpMessage = "AppSource template", Mandatory = $true)] + [string] $appSourceTemplate, + [Parameter(HelpMessage = "Admin center API credentials", Mandatory = $true)] + [string] $adminCenterApiCredentials, + [Parameter(HelpMessage = "Azure credentials", Mandatory = $true)] + [string] $azureCredentials, + [Parameter(HelpMessage = "GitHub packages token", Mandatory = $true)] + [string] $githubPackagesToken +) + +$ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + +try { + $params = @{ + 'github' = $true + 'githubOwner' = $githubOwner + 'repoName' = $repoName + 'e2eAppId' = $e2eAppId + 'e2eAppKey' = $e2eAppKey + 'algoauthapp' = $algoAuthApp + 'pteTemplate' = $pteTemplate + 'appSourceTemplate' = $appSourceTemplate + 'adminCenterApiCredentials' = $adminCenterApiCredentials + 'azureCredentials' = $azureCredentials + 'githubPackagesToken' = $githubPackagesToken + } + + if ($linux) { + $params['linux'] = $true + } + + . (Join-Path "." "e2eTests/scenarios/$scenario/runtest.ps1") @params +} +catch { + Write-Host $_.Exception.Message + Write-Host $_.ScriptStackTrace + Write-Host "::Error::$($_.Exception.Message)" + $host.SetShouldExit(1) +} diff --git a/.github/actions/E2ERunScenario/README.md b/.github/actions/E2ERunScenario/README.md new file mode 100644 index 000000000..16b474c43 --- /dev/null +++ b/.github/actions/E2ERunScenario/README.md @@ -0,0 +1,18 @@ +# E2E Run Scenario + +Runs E2E scenario tests by executing scenario-specific test scripts. + +## Inputs + +- `scenario`: Scenario name +- `linux`: Run on Linux (default: false) +- `githubOwner`: GitHub owner +- `repoName`: Repository name +- `e2eAppId`: E2E App ID +- `e2eAppKey`: E2E App Key +- `algoAuthApp`: ALGO Auth App +- `pteTemplate`: PTE template +- `appSourceTemplate`: AppSource template +- `adminCenterApiCredentials`: Admin center API credentials +- `azureCredentials`: Azure credentials +- `githubPackagesToken`: GitHub packages token diff --git a/.github/actions/E2ERunScenario/action.yaml b/.github/actions/E2ERunScenario/action.yaml new file mode 100644 index 000000000..ffe937c90 --- /dev/null +++ b/.github/actions/E2ERunScenario/action.yaml @@ -0,0 +1,68 @@ +name: E2E Run Scenario +author: Microsoft Corporation +inputs: + shell: + description: Shell in which you want to run the action (powershell or pwsh) + required: false + default: pwsh + scenario: + description: Scenario name + required: true + linux: + description: Run on Linux + required: false + default: 'false' + githubOwner: + description: GitHub owner + required: true + repoName: + description: Repository name + required: true + e2eAppId: + description: E2E App ID + required: true + e2eAppKey: + description: E2E App Key + required: true + algoAuthApp: + description: ALGO Auth App + required: true + pteTemplate: + description: PTE template + required: true + appSourceTemplate: + description: AppSource template + required: true + adminCenterApiCredentials: + description: Admin center API credentials + required: true + azureCredentials: + description: Azure credentials + required: true + githubPackagesToken: + description: GitHub packages token + required: true +runs: + using: composite + steps: + - name: run + id: run + shell: ${{ inputs.shell }} + env: + _scenario: ${{ inputs.scenario }} + _linux: ${{ inputs.linux }} + _githubOwner: ${{ inputs.githubOwner }} + _repoName: ${{ inputs.repoName }} + _e2eAppId: ${{ inputs.e2eAppId }} + _e2eAppKey: ${{ inputs.e2eAppKey }} + _algoAuthApp: ${{ inputs.algoAuthApp }} + _pteTemplate: ${{ inputs.pteTemplate }} + _appSourceTemplate: ${{ inputs.appSourceTemplate }} + _adminCenterApiCredentials: ${{ inputs.adminCenterApiCredentials }} + _azureCredentials: ${{ inputs.azureCredentials }} + _githubPackagesToken: ${{ inputs.githubPackagesToken }} + run: | + ${{ github.action_path }}/E2ERunScenario.ps1 -scenario $ENV:_scenario -linux ($ENV:_linux -eq 'true') -githubOwner $ENV:_githubOwner -repoName $ENV:_repoName -e2eAppId $ENV:_e2eAppId -e2eAppKey $ENV:_e2eAppKey -algoAuthApp $ENV:_algoAuthApp -pteTemplate $ENV:_pteTemplate -appSourceTemplate $ENV:_appSourceTemplate -adminCenterApiCredentials $ENV:_adminCenterApiCredentials -azureCredentials $ENV:_azureCredentials -githubPackagesToken $ENV:_githubPackagesToken +branding: + icon: play + color: blue diff --git a/.github/actions/E2ERunTest/E2ERunTest.ps1 b/.github/actions/E2ERunTest/E2ERunTest.ps1 new file mode 100644 index 000000000..ded44499e --- /dev/null +++ b/.github/actions/E2ERunTest/E2ERunTest.ps1 @@ -0,0 +1,82 @@ +Param( + [Parameter(HelpMessage = "Test type (test or upgrade)", Mandatory = $false)] + [ValidateSet('test', 'upgrade')] + [string] $testType = 'test', + [Parameter(HelpMessage = "Private repository", Mandatory = $false)] + [bool] $private = $false, + [Parameter(HelpMessage = "GitHub owner", Mandatory = $true)] + [string] $githubOwner, + [Parameter(HelpMessage = "Repository name", Mandatory = $true)] + [string] $repoName, + [Parameter(HelpMessage = "E2E App ID", Mandatory = $true)] + [string] $e2eAppId, + [Parameter(HelpMessage = "E2E App Key", Mandatory = $true)] + [string] $e2eAppKey, + [Parameter(HelpMessage = "ALGO Auth App", Mandatory = $true)] + [string] $algoAuthApp, + [Parameter(HelpMessage = "Template", Mandatory = $true)] + [string] $template, + [Parameter(HelpMessage = "Admin center API credentials", Mandatory = $false)] + [string] $adminCenterApiCredentials = '', + [Parameter(HelpMessage = "Multi-project", Mandatory = $false)] + [bool] $multiProject = $false, + [Parameter(HelpMessage = "AppSource app", Mandatory = $false)] + [bool] $appSource = $false, + [Parameter(HelpMessage = "Linux", Mandatory = $false)] + [bool] $linux = $false, + [Parameter(HelpMessage = "Use compiler folder", Mandatory = $false)] + [bool] $useCompilerFolder = $false, + [Parameter(HelpMessage = "Release (for upgrade tests)", Mandatory = $false)] + [string] $release = '', + [Parameter(HelpMessage = "Content path (for upgrade tests)", Mandatory = $false)] + [string] $contentPath = '' +) + +$ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + +try { + if ($testType -eq 'upgrade') { + $params = @{ + 'github' = $true + 'githubOwner' = $githubOwner + 'repoName' = $repoName + 'e2eAppId' = $e2eAppId + 'e2eAppKey' = $e2eAppKey + 'algoauthapp' = $algoAuthApp + 'template' = $template + 'appSource' = $appSource + 'release' = $release + 'contentPath' = $contentPath + } + + . (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") @params + } + else { + $params = @{ + 'github' = $true + 'githubOwner' = $githubOwner + 'repoName' = $repoName + 'e2eAppId' = $e2eAppId + 'e2eAppKey' = $e2eAppKey + 'algoauthapp' = $algoAuthApp + 'template' = $template + 'adminCenterApiCredentials' = $adminCenterApiCredentials + 'multiProject' = $multiProject + 'appSource' = $appSource + 'linux' = $linux + 'useCompilerFolder' = $useCompilerFolder + } + + if ($private) { + $params['private'] = $true + } + + . (Join-Path "." "e2eTests/Test-AL-Go.ps1") @params + } +} +catch { + Write-Host $_.Exception.Message + Write-Host $_.ScriptStackTrace + Write-Host "::Error::$($_.Exception.Message)" + $host.SetShouldExit(1) +} diff --git a/.github/actions/E2ERunTest/README.md b/.github/actions/E2ERunTest/README.md new file mode 100644 index 000000000..6fe298599 --- /dev/null +++ b/.github/actions/E2ERunTest/README.md @@ -0,0 +1,21 @@ +# E2E Run Test + +Runs E2E tests by executing Test-AL-Go.ps1 or Test-AL-Go-Upgrade.ps1 scripts. + +## Inputs + +- `testType`: Test type (test or upgrade, default: test) +- `private`: Private repository (default: false) +- `githubOwner`: GitHub owner +- `repoName`: Repository name +- `e2eAppId`: E2E App ID +- `e2eAppKey`: E2E App Key +- `algoAuthApp`: ALGO Auth App +- `template`: Template +- `adminCenterApiCredentials`: Admin center API credentials +- `multiProject`: Multi-project (default: false) +- `appSource`: AppSource app (default: false) +- `linux`: Linux (default: false) +- `useCompilerFolder`: Use compiler folder (default: false) +- `release`: Release (for upgrade tests) +- `contentPath`: Content path (for upgrade tests) diff --git a/.github/actions/E2ERunTest/action.yaml b/.github/actions/E2ERunTest/action.yaml new file mode 100644 index 000000000..99aa277cc --- /dev/null +++ b/.github/actions/E2ERunTest/action.yaml @@ -0,0 +1,88 @@ +name: E2E Run Test +author: Microsoft Corporation +inputs: + shell: + description: Shell in which you want to run the action (powershell or pwsh) + required: false + default: pwsh + testType: + description: Test type (test or upgrade) + required: false + default: 'test' + private: + description: Private repository + required: false + default: 'false' + githubOwner: + description: GitHub owner + required: true + repoName: + description: Repository name + required: true + e2eAppId: + description: E2E App ID + required: true + e2eAppKey: + description: E2E App Key + required: true + algoAuthApp: + description: ALGO Auth App + required: true + template: + description: Template + required: true + adminCenterApiCredentials: + description: Admin center API credentials + required: false + default: '' + multiProject: + description: Multi-project + required: false + default: 'false' + appSource: + description: AppSource app + required: false + default: 'false' + linux: + description: Linux + required: false + default: 'false' + useCompilerFolder: + description: Use compiler folder + required: false + default: 'false' + release: + description: Release (for upgrade tests) + required: false + default: '' + contentPath: + description: Content path (for upgrade tests) + required: false + default: '' +runs: + using: composite + steps: + - name: run + id: run + shell: ${{ inputs.shell }} + env: + _testType: ${{ inputs.testType }} + _private: ${{ inputs.private }} + _githubOwner: ${{ inputs.githubOwner }} + _repoName: ${{ inputs.repoName }} + _e2eAppId: ${{ inputs.e2eAppId }} + _e2eAppKey: ${{ inputs.e2eAppKey }} + _algoAuthApp: ${{ inputs.algoAuthApp }} + _template: ${{ inputs.template }} + _adminCenterApiCredentials: ${{ inputs.adminCenterApiCredentials }} + _multiProject: ${{ inputs.multiProject }} + _appSource: ${{ inputs.appSource }} + _linux: ${{ inputs.linux }} + _useCompilerFolder: ${{ inputs.useCompilerFolder }} + _release: ${{ inputs.release }} + _contentPath: ${{ inputs.contentPath }} + run: | + ${{ github.action_path }}/E2ERunTest.ps1 -testType $ENV:_testType -private ($ENV:_private -eq 'true') -githubOwner $ENV:_githubOwner -repoName $ENV:_repoName -e2eAppId $ENV:_e2eAppId -e2eAppKey $ENV:_e2eAppKey -algoAuthApp $ENV:_algoAuthApp -template $ENV:_template -adminCenterApiCredentials $ENV:_adminCenterApiCredentials -multiProject ($ENV:_multiProject -eq 'true') -appSource ($ENV:_appSource -eq 'true') -linux ($ENV:_linux -eq 'true') -useCompilerFolder ($ENV:_useCompilerFolder -eq 'true') -release $ENV:_release -contentPath $ENV:_contentPath +branding: + icon: check-square + color: blue diff --git a/.github/actions/E2ESetupRepositories/E2ESetupRepositories.ps1 b/.github/actions/E2ESetupRepositories/E2ESetupRepositories.ps1 new file mode 100644 index 000000000..9ccdd5b49 --- /dev/null +++ b/.github/actions/E2ESetupRepositories/E2ESetupRepositories.ps1 @@ -0,0 +1,9 @@ +Param( + [Parameter(HelpMessage = "GitHub owner for test repositories", Mandatory = $true)] + [string] $githubOwner, + [Parameter(HelpMessage = "BcContainerHelper version", Mandatory = $false)] + [string] $bcContainerHelperVersion = '' +) + +$ErrorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 +. (Join-Path "." "e2eTests/SetupRepositories.ps1") -githubOwner $githubOwner -bcContainerHelperVersion $bcContainerHelperVersion diff --git a/.github/actions/E2ESetupRepositories/README.md b/.github/actions/E2ESetupRepositories/README.md new file mode 100644 index 000000000..9cc433495 --- /dev/null +++ b/.github/actions/E2ESetupRepositories/README.md @@ -0,0 +1,15 @@ +# E2E Setup Repositories + +Sets up test repositories for E2E testing by calling the SetupRepositories.ps1 script. + +## Inputs + +- `githubOwner`: GitHub owner for test repositories +- `bcContainerHelperVersion`: BcContainerHelper version +- `token`: GitHub token with permissions to create repositories + +## Outputs + +- `actionsRepo`: Actions repository name +- `perTenantExtensionRepo`: Per-tenant extension repository name +- `appSourceAppRepo`: AppSource app repository name diff --git a/.github/actions/E2ESetupRepositories/action.yaml b/.github/actions/E2ESetupRepositories/action.yaml new file mode 100644 index 000000000..d0e8f601d --- /dev/null +++ b/.github/actions/E2ESetupRepositories/action.yaml @@ -0,0 +1,42 @@ +name: E2E Setup Repositories +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 + bcContainerHelperVersion: + description: BcContainerHelper version + required: false + default: '' + token: + description: GitHub token with permissions to create repositories + required: true +outputs: + actionsRepo: + description: Actions repository name + value: ${{ steps.run.outputs.actionsRepo }} + perTenantExtensionRepo: + description: Per-tenant extension repository name + value: ${{ steps.run.outputs.perTenantExtensionRepo }} + appSourceAppRepo: + description: AppSource app repository name + value: ${{ steps.run.outputs.appSourceAppRepo }} +runs: + using: composite + steps: + - name: run + id: run + shell: ${{ inputs.shell }} + env: + _githubOwner: ${{ inputs.githubOwner }} + _bcContainerHelperVersion: ${{ inputs.bcContainerHelperVersion }} + GH_TOKEN: ${{ inputs.token }} + run: | + ${{ github.action_path }}/E2ESetupRepositories.ps1 -githubOwner $ENV:_githubOwner -bcContainerHelperVersion $ENV:_bcContainerHelperVersion +branding: + icon: git-branch + color: blue diff --git a/.github/workflows/E2E.yaml b/.github/workflows/E2E.yaml index d8905a2f5..98bb3fad1 100644 --- a/.github/workflows/E2E.yaml +++ b/.github/workflows/E2E.yaml @@ -61,49 +61,15 @@ jobs: - name: Check secrets id: check - env: + uses: ./.github/actions/E2ECheckSecrets + with: githubOwner: ${{ github.event.inputs.githubOwner }} - run: | - $err = $false - if (('${{ vars.E2E_APP_ID }}' -eq '') -or ('${{ secrets.E2E_PRIVATE_KEY }}' -eq '')){ - Write-Host "::Error::In order to run end to end tests, you need a Secret called E2E_PRIVATE_KEY and a variable called E2E_APP_ID." - $err = $true - } - if ('${{ Secrets.ALGOAUTHAPP }}' -eq '') { - Write-Host "::Error::In order to run end to end tests, you need a Secret called ALGOAUTHAPP" - $err = $true - } - if ('${{ Secrets.adminCenterApiCredentials }}' -eq '') { - Write-Host "::Error::In order to run end to end tests, you need a Secret called adminCenterApiCredentials" - $err = $true - } - if ('${{ Secrets.E2E_GHPackagesPAT }}' -eq '') { - Write-Host "::Error::In order to run end to end tests, you need a secret called E2E_GHPackagesPAT" - $err = $true - } - if ('${{ Secrets.E2EAZURECREDENTIALS }}' -eq '') { - Write-Host "::Error::In order to run end to end tests, you need a secret called E2EAZURECREDENTIALS" - $err = $true - } - if ($err) { - exit 1 - } - $githubOwner = $ENV:githubOwner - $maxParallel = 99 - if (!($githubOwner)) { - $githubOwner = "$ENV:GITHUB_REPOSITORY_OWNER" - } - $orgmap = Get-Content -path (Join-Path "." "e2eTests\orgmap.json") -encoding UTF8 -raw | ConvertFrom-Json - if ($orgmap.PSObject.Properties.Name -eq $githubOwner) { - $githubOwner = $orgmap."$githubOwner" - } - if ($githubOwner -eq $ENV:GITHUB_REPOSITORY_OWNER) { - $maxParallel = 8 - } - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "maxParallel=$maxParallel" - Write-Host "maxParallel=$maxParallel" - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "githubOwner=$githubOwner" - Write-Host "githubOwner=$githubOwner" + e2eAppId: ${{ vars.E2E_APP_ID }} + e2ePrivateKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + adminCenterApiCredentials: ${{ secrets.adminCenterApiCredentials }} + e2eGHPackagesPAT: ${{ secrets.E2E_GHPackagesPAT }} + e2eAzureCredentials: ${{ secrets.E2EAZURECREDENTIALS }} SetupRepositories: runs-on: [ ubuntu-latest ] @@ -132,12 +98,11 @@ jobs: - name: Setup Repositories id: setup - env: - _bcContainerHelperVersion: ${{ github.event.inputs.bcContainerHelperVersion }} - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - . (Join-Path "." "e2eTests/SetupRepositories.ps1") -githubOwner '${{ needs.Check.outputs.githubowner }}' -bcContainerHelperVersion $ENV:_bcContainerHelperVersion + uses: ./.github/actions/E2ESetupRepositories + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} + bcContainerHelperVersion: ${{ github.event.inputs.bcContainerHelperVersion }} + token: ${{ steps.app-token.outputs.token }} Analyze: runs-on: [ ubuntu-latest ] @@ -167,70 +132,11 @@ jobs: - name: Analyze id: Analyze - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - $modulePath = Join-Path "." "e2eTests\e2eTestHelper.psm1" -resolve - Import-Module $modulePath -DisableNameChecking - $maxParallel = [int]'${{ needs.Check.outputs.maxParallel }}' - - $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]("$env: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" - - $scenariosJson = @{ - "matrix" = @{ - "include" = @(Get-ChildItem -path (Join-Path $ENV:GITHUB_WORKSPACE "e2eTests/scenarios/*/runtest.ps1") | ForEach-Object { @{ "Scenario" = $_.Directory.Name } } ) - }; - "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" + uses: ./.github/actions/E2EAnalyze + with: + maxParallel: ${{ needs.Check.outputs.maxParallel }} + testUpgradesFromVersion: ${{ env.TestUpgradesFromVersion }} + token: ${{ steps.app-token.outputs.token }} ScenariosOnWindows: runs-on: [ windows-latest ] @@ -250,24 +156,25 @@ jobs: - name: Calculate parameters id: calculateParams - run: | - $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" - Write-Host "Repo URL: https://github.com/${{ needs.Check.outputs.githubowner }}/$repoName" + uses: ./.github/actions/E2ECalculateRepoName + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} - name: Run test on Windows - run: | - try { - . (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -e2eAppId '${{ vars.E2E_APP_ID }}' -e2eAppKey '${{ secrets.E2E_PRIVATE_KEY }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiCredentials '${{ Secrets.adminCenterApiCredentials }}' -azureCredentials '${{ Secrets.E2EAzureCredentials }}' -githubPackagesToken '${{ Secrets.E2E_GHPackagesPAT }}' - } - catch { - Write-Host $_.Exception.Message - Write-Host $_.ScriptStackTrace - Write-Host "::Error::$($_.Exception.Message)" - $host.SetShouldExit(1) - } + uses: ./.github/actions/E2ERunScenario + with: + scenario: ${{ matrix.scenario }} + linux: false + githubOwner: ${{ needs.Check.outputs.githubowner }} + repoName: ${{ steps.calculateParams.outputs.repoName }} + e2eAppId: ${{ vars.E2E_APP_ID }} + e2eAppKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + pteTemplate: ${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }} + appSourceTemplate: ${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }} + adminCenterApiCredentials: ${{ secrets.adminCenterApiCredentials }} + azureCredentials: ${{ secrets.E2EAzureCredentials }} + githubPackagesToken: ${{ secrets.E2E_GHPackagesPAT }} ScenariosOnLinux: runs-on: [ windows-latest ] @@ -287,24 +194,25 @@ jobs: - name: Calculate parameters id: calculateParams - run: | - $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" - Write-Host "Repo URL: https://github.com/${{ needs.Check.outputs.githubowner }}/$repoName" + uses: ./.github/actions/E2ECalculateRepoName + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} - name: Run tests - run: | - try { - . (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -linux -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -e2eAppId '${{ vars.E2E_APP_ID }}' -e2eAppKey '${{ secrets.E2E_PRIVATE_KEY }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiCredentials '${{ Secrets.adminCenterApiCredentials }}' -azureCredentials '${{ Secrets.E2EAzureCredentials }}' -githubPackagesToken '${{ Secrets.E2E_GHPackagesPAT }}' - } - catch { - Write-Host $_.Exception.Message - Write-Host $_.ScriptStackTrace - Write-Host "::Error::$($_.Exception.Message)" - $host.SetShouldExit(1) - } + uses: ./.github/actions/E2ERunScenario + with: + scenario: ${{ matrix.scenario }} + linux: true + githubOwner: ${{ needs.Check.outputs.githubowner }} + repoName: ${{ steps.calculateParams.outputs.repoName }} + e2eAppId: ${{ vars.E2E_APP_ID }} + e2eAppKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + pteTemplate: ${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }} + appSourceTemplate: ${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }} + adminCenterApiCredentials: ${{ secrets.adminCenterApiCredentials }} + azureCredentials: ${{ secrets.E2EAzureCredentials }} + githubPackagesToken: ${{ secrets.E2E_GHPackagesPAT }} TestAlGoPublic: runs-on: [ ubuntu-latest ] @@ -324,36 +232,32 @@ jobs: - name: Calculate parameters id: calculateParams - run: | - $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - $adminCenterApiCredentials = '' - if ('${{ matrix.type }}' -eq 'PTE' -and '${{ matrix.style }}' -eq 'singleProject' -and '${{ matrix.os }}' -eq 'windows') { - $adminCenterApiCredentials = '${{ Secrets.adminCenterApiCredentials }}' - } - if ('${{ matrix.type }}' -eq 'appSourceApp') { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' - } - else { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' - } - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "adminCenterApiCredentials='$adminCenterApiCredentials'" - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "template='$template'" - $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/${{ needs.Check.outputs.githubowner }}/$repoName" + uses: ./.github/actions/E2ECalculateTestParams + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} + matrixType: ${{ matrix.type }} + matrixStyle: ${{ matrix.style }} + matrixOs: ${{ matrix.os }} + adminCenterApiCredentialsSecret: ${{ secrets.adminCenterApiCredentials }} + appSourceAppRepo: ${{ needs.SetupRepositories.outputs.appSourceAppRepo }} + perTenantExtensionRepo: ${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }} - name: Run tests - run: | - try { - . (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2eAppId '${{ vars.E2E_APP_ID }}' -e2eAppKey '${{ secrets.E2E_PRIVATE_KEY }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiCredentials ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder') - } - catch { - Write-Host $_.Exception.Message - Write-Host $_.ScriptStackTrace - Write-Host "::Error::$($_.Exception.Message)" - $host.SetShouldExit(1) - } + uses: ./.github/actions/E2ERunTest + with: + testType: test + private: false + githubOwner: ${{ needs.Check.outputs.githubowner }} + repoName: ${{ steps.calculateParams.outputs.repoName }} + e2eAppId: ${{ vars.E2E_APP_ID }} + e2eAppKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + template: ${{ steps.calculateParams.outputs.template }} + adminCenterApiCredentials: ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} + multiProject: ${{ matrix.style == 'multiProject' }} + appSource: ${{ matrix.type == 'appSourceApp' }} + linux: ${{ matrix.os == 'linux' }} + useCompilerFolder: ${{ matrix.Compiler == 'CompilerFolder' }} TestAlGoPrivate: runs-on: [ ubuntu-latest ] @@ -373,36 +277,32 @@ jobs: - name: Calculate parameters id: calculateParams - run: | - $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - $adminCenterApiCredentials = '' - if ('${{ matrix.type }}' -eq 'PTE' -and '${{ matrix.style }}' -eq 'singleProject' -and '${{ matrix.os }}' -eq 'windows') { - $adminCenterApiCredentials = '${{ Secrets.adminCenterApiCredentials }}' - } - if ('${{ matrix.type }}' -eq 'appSourceApp') { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' - } - else { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' - } - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "adminCenterApiCredentials='$adminCenterApiCredentials'" - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "template='$template'" - $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/${{ needs.Check.outputs.githubowner }}/$repoName" + uses: ./.github/actions/E2ECalculateTestParams + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} + matrixType: ${{ matrix.type }} + matrixStyle: ${{ matrix.style }} + matrixOs: ${{ matrix.os }} + adminCenterApiCredentialsSecret: ${{ secrets.adminCenterApiCredentials }} + appSourceAppRepo: ${{ needs.SetupRepositories.outputs.appSourceAppRepo }} + perTenantExtensionRepo: ${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }} - name: Run tests - run: | - try { - . (Join-Path "." "e2eTests/Test-AL-Go.ps1") -private -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2eAppId '${{ vars.E2E_APP_ID }}' -e2eAppKey '${{ secrets.E2E_PRIVATE_KEY }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiCredentials ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder') - } - catch { - Write-Host $_.Exception.Message - Write-Host $_.ScriptStackTrace - Write-Host "::Error::$($_.Exception.Message)" - $host.SetShouldExit(1) - } + uses: ./.github/actions/E2ERunTest + with: + testType: test + private: true + githubOwner: ${{ needs.Check.outputs.githubowner }} + repoName: ${{ steps.calculateParams.outputs.repoName }} + e2eAppId: ${{ vars.E2E_APP_ID }} + e2eAppKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + template: ${{ steps.calculateParams.outputs.template }} + adminCenterApiCredentials: ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} + multiProject: ${{ matrix.style == 'multiProject' }} + appSource: ${{ matrix.type == 'appSourceApp' }} + linux: ${{ matrix.os == 'linux' }} + useCompilerFolder: ${{ matrix.Compiler == 'CompilerFolder' }} TestAlGoUpgrade: runs-on: [ ubuntu-latest ] @@ -422,31 +322,23 @@ jobs: - name: Calculate parameters id: calculateParams - run: | - $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - if ('${{ matrix.type }}' -eq 'appSourceApp') { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' - $contentPath = 'appsourceapp' - } - else { - $template = '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' - $contentPath = 'pte' - } - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "template='$template'" - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "contentPath='$contentPath'" - $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/${{ needs.Check.outputs.githubowner }}/$repoName" + uses: ./.github/actions/E2ECalculateTestParams + with: + githubOwner: ${{ needs.Check.outputs.githubowner }} + matrixType: ${{ matrix.type }} + appSourceAppRepo: ${{ needs.SetupRepositories.outputs.appSourceAppRepo }} + perTenantExtensionRepo: ${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }} - name: Run tests - run: | - try { - . (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2eAppId '${{ vars.E2E_APP_ID }}' -e2eAppKey '${{ secrets.E2E_PRIVATE_KEY }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -release '${{ matrix.release }}' -contentPath ${{ steps.calculateParams.outputs.contentPath }} - } - catch { - Write-Host $_.Exception.Message - Write-Host $_.ScriptStackTrace - Write-Host "::Error::$($_.Exception.Message)" - $host.SetShouldExit(1) - } + uses: ./.github/actions/E2ERunTest + with: + testType: upgrade + githubOwner: ${{ needs.Check.outputs.githubowner }} + repoName: ${{ steps.calculateParams.outputs.repoName }} + e2eAppId: ${{ vars.E2E_APP_ID }} + e2eAppKey: ${{ secrets.E2E_PRIVATE_KEY }} + algoAuthApp: ${{ secrets.ALGOAUTHAPP }} + template: ${{ steps.calculateParams.outputs.template }} + appSource: ${{ matrix.type == 'appSourceApp' }} + release: ${{ matrix.release }} + contentPath: ${{ steps.calculateParams.outputs.contentPath }}