diff --git a/.github/workflows/E2E.yaml b/.github/workflows/E2E.yaml index 802072b7e..86a02ed94 100644 --- a/.github/workflows/E2E.yaml +++ b/.github/workflows/E2E.yaml @@ -17,6 +17,10 @@ on: description: Run the end to end test scenario for the full test matrix type: boolean default: true + includePrivateRepos: + description: Include private repos in full test matrix + type: boolean + default: false runScenarios: description: Run the end to end scenario tests type: boolean @@ -102,7 +106,8 @@ jobs: runs-on: [ ubuntu-latest ] needs: [ Check ] outputs: - testruns: ${{ steps.Analyze.outputs.testruns }} + publictestruns: ${{ steps.Analyze.outputs.publictestruns }} + privatetestruns: ${{ steps.Analyze.outputs.privatetestruns }} releases: ${{ steps.Analyze.outputs.releases }} scenarios: ${{ steps.Analyze.outputs.scenarios }} steps: @@ -119,33 +124,41 @@ jobs: SetTokenAndRepository -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -repository "microsoft/AL-Go" $maxParallel = [int]'${{ needs.Check.outputs.maxParallel }}' - $testrunsJson = @{ + $publicTestruns = @{ + "max-parallel" = $maxParallel + "fail-fast" = $false "matrix" = @{ - "include" = @( - @('private','public') | ForEach-Object { - $visibility = $_ - @('appSourceApp','PTE') | ForEach-Object { - $type = $_ - @('linux','windows') | ForEach-Object { - $os = $_ - @('multiProject','singleProject') | ForEach-Object { - $style = $_ - @{ "visibility" = $visibility; "type" = $type; "os" = $os; "style" = $style; "Compiler" = "Container" } - if ($visibility -eq "public" -and $type -eq "PTE") { - # Run end 2 end tests using CompilerFolder with Windows+Linux and single/multiproject - @{ "visibility" = $visibility; "type" = $type; "os" = $os; "style" = $style; "Compiler" = "CompilerFolder" } - } - } - } - } - } - ) + "include" = @() } + } + $privateTestruns = @{ "max-parallel" = $maxParallel "fail-fast" = $false - } | ConvertTo-Json -depth 99 -compress - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "testruns=$testrunsJson" - Write-Host "testruns=$testrunsJson" + "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 = @{ @@ -199,11 +212,54 @@ jobs: $host.SetShouldExit(1) } - TestAlGo: + TestAlGoPublic: runs-on: [ ubuntu-latest ] needs: [ Check, SetupRepositories, Analyze ] if: github.event.inputs.runTestMatrix == 'true' - strategy: ${{ fromJson(needs.Analyze.outputs.testruns) }} + strategy: ${{ fromJson(needs.Analyze.outputs.publictestruns) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + + - 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" + + - name: Run tests + run: | + try { + . (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ 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) + } + + TestAlGoPrivate: + runs-on: [ ubuntu-latest ] + needs: [ Check, SetupRepositories, Analyze ] + if: github.event.inputs.runTestMatrix == 'true' && github.event.inputs.includePrivateRepos == 'true' + strategy: ${{ fromJson(needs.Analyze.outputs.privatetestruns) }} steps: - uses: actions/checkout@v4 with: @@ -233,7 +289,7 @@ jobs: - name: Run tests run: | try { - . (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -private:('${{ matrix.visibility }}' -eq 'private') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder') + . (Join-Path "." "e2eTests/Test-AL-Go.ps1") -private -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ 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 @@ -242,6 +298,7 @@ jobs: $host.SetShouldExit(1) } + TestAlGoUpgrade: runs-on: [ ubuntu-latest ] needs: [ Check, SetupRepositories, Analyze ] @@ -285,7 +342,7 @@ jobs: RemoveRepositories: runs-on: [ ubuntu-latest ] - needs: [ Check, SetupRepositories, TestAlGo, TestAlGoUpgrade, Scenario ] + needs: [ Check, SetupRepositories, TestAlGoPublic, TestAlGoPrivate, TestAlGoUpgrade, Scenario ] if: always() && (!Cancelled()) && (needs.SetupRepositories.result == 'Success') && (needs.TestAlGo.result == 'Success' || needs.TestAlGo.result == 'Skipped') && (needs.TestAlGoUpgrade.result == 'Success' || needs.TestAlGoUpgrade.result == 'Skipped') && (needs.Scenario.result == 'Success' || needs.Scenario.result == 'Skipped') steps: - uses: actions/checkout@v4 diff --git a/e2eTests/e2eTestHelper.psm1 b/e2eTests/e2eTestHelper.psm1 index b99a77a15..e223d6be3 100644 --- a/e2eTests/e2eTestHelper.psm1 +++ b/e2eTests/e2eTestHelper.psm1 @@ -453,11 +453,6 @@ function CreateAlGoRepository { $repoSettings = Get-Content $repoSettingsFile -Encoding UTF8 | ConvertFrom-Json $runson = "windows-latest" $shell = "powershell" - if ($private) { - $repoSettings | Add-Member -MemberType NoteProperty -Name "gitHubRunner" -Value "self-hosted" - $repoSettings | Add-Member -MemberType NoteProperty -Name "gitHubRunnerShell" -Value "powershell" - $runson = "self-hosted" - } if ($linux) { $runson = "ubuntu-latest" $shell = "pwsh"