Skip to content

Commit

Permalink
End 2 end tests (#1095)
Browse files Browse the repository at this point in the history
End 2 end tests on private repos was using self-hosted agents, which no
longer are there.

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Jun 4, 2024
1 parent f0b33e3 commit 3833302
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 33 deletions.
113 changes: 85 additions & 28 deletions .github/workflows/E2E.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 = @{
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -242,6 +298,7 @@ jobs:
$host.SetShouldExit(1)
}
TestAlGoUpgrade:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions e2eTests/e2eTestHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3833302

Please sign in to comment.