-
Notifications
You must be signed in to change notification settings - Fork 125
386 lines (355 loc) · 19.8 KB
/
E2E.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
name: End to end tests
run-name: End to end tests - ${{ github.event.inputs.ref != '' && github.event.inputs.ref || github.sha }}
on:
workflow_dispatch:
inputs:
ref:
description: ref on which to run the end-2-end tests (default is head_sha on main)
required: false
default: ''
githubOwner:
description: GitHub organization set as owner for the temp repositories (default is to use your personal account - CANNOT be a free account)
required: false
default: ''
runTestMatrix:
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
default: true
runUpgradeTests:
description: Run the end to end upgrade tests
type: boolean
default: true
bcContainerHelperVersion:
description: Which version of BcContainerHelper to use? (latest, preview, private, a specific version number or a direct download URL like https://github.com/freddydk/navcontainerhelper/archive/master.zip - leave empty to use latest)
required: false
default: 'preview'
env:
TestUpgradesFromVersion: 'v3.1'
defaults:
run:
shell: pwsh
jobs:
Check:
runs-on: [ ubuntu-latest ]
outputs:
maxParallel: ${{ steps.check.outputs.maxParallel }}
githubOwner: ${{ steps.check.outputs.githubOwner }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check secrets
id: check
env:
githubOwner: ${{ github.event.inputs.githubOwner }}
run: |
$err = $false
if ('${{ Secrets.E2EPAT }}' -eq '') {
Write-Host "::Error::In order to run end to end tests, you need a Secret called E2EPAT containing a valid Personal Access Token with the following permissions: admin:org, delete_repo, repo, workflow, packages:write"
$err = $true
}
if ('${{ Secrets.adminCenterApiCredentials }}' -eq '') {
Write-Host "::Error::In order to run end to end tests, you need a Secret called adminCenterApiCredentials containing API access credentials for BC Admin Center"
$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"
SetupRepositories:
runs-on: [ ubuntu-latest ]
needs: [ Check ]
outputs:
actionsRepo: ${{ steps.setup.outputs.actionsRepo }}
perTenantExtensionRepo: ${{ steps.setup.outputs.perTenantExtensionRepo }}
appSourceAppRepo: ${{ steps.setup.outputs.appSourceAppRepo }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- name: Setup Repositories
id: setup
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
. (Join-Path "." "e2eTests/SetupRepositories.ps1") -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -bcContainerHelperVersion '${{ github.event.inputs.bcContainerHelperVersion }}'
Analyze:
runs-on: [ ubuntu-latest ]
needs: [ Check ]
outputs:
publictestruns: ${{ steps.Analyze.outputs.publictestruns }}
privatetestruns: ${{ steps.Analyze.outputs.privatetestruns }}
releases: ${{ steps.Analyze.outputs.releases }}
scenarios: ${{ steps.Analyze.outputs.scenarios }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- name: Analyze
id: Analyze
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
$modulePath = Join-Path "." "e2eTests\e2eTestHelper.psm1" -resolve
Import-Module $modulePath -DisableNameChecking
SetTokenAndRepository -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -repository "microsoft/AL-Go"
$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"
ScenariosOnWindows:
runs-on: [ windows-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runScenarios == 'true'
strategy: ${{ fromJson(needs.Analyze.outputs.scenarios) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- 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"
- 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 }}' -token '${{ Secrets.E2EPAT }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
}
catch {
Write-Host $_.Exception.Message
Write-Host $_.ScriptStackTrace
Write-Host "::Error::$($_.Exception.Message)"
$host.SetShouldExit(1)
}
ScenariosOnLinux:
runs-on: [ windows-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runScenarios == 'true'
strategy: ${{ fromJson(needs.Analyze.outputs.scenarios) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- 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"
- 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 }}' -token '${{ Secrets.E2EPAT }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
}
catch {
Write-Host $_.Exception.Message
Write-Host $_.ScriptStackTrace
Write-Host "::Error::$($_.Exception.Message)"
$host.SetShouldExit(1)
}
TestAlGoPublic:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runTestMatrix == 'true'
strategy: ${{ fromJson(needs.Analyze.outputs.publictestruns) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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") -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
Write-Host $_.ScriptStackTrace
Write-Host "::Error::$($_.Exception.Message)"
$host.SetShouldExit(1)
}
TestAlGoUpgrade:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runUpgradeTests == 'true'
strategy: ${{ fromJson(needs.Analyze.outputs.releases) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- 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"
- name: Run tests
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -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)
}
RemoveRepositories:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, TestAlGoPublic, TestAlGoPrivate, TestAlGoUpgrade, ScenariosOnWindows, ScenariosOnLinux ]
if: always() && (!Cancelled()) && (needs.SetupRepositories.result == 'Success') && (needs.TestAlGoPublic.result == 'Success' || needs.TestAlGoPublic.result == 'Skipped') && (needs.TestAlGoPrivate.result == 'Success' || needs.TestAlGoPrivate.result == 'Skipped') && (needs.TestAlGoUpgrade.result == 'Success' || needs.TestAlGoUpgrade.result == 'Skipped') && (needs.Scenario.result == 'Success' || needs.Scenario.result == 'Skipped')
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.inputs.ref }}
- name: Remove Repositories
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
. (Join-Path "." "e2eTests/RemoveRepositories.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -actionsRepo '${{ needs.SetupRepositories.outputs.actionsRepo }}' -perTenantExtensionRepo '${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceAppRepo '${{ needs.SetupRepositories.outputs.appSourceAppRepo }}'