-
Notifications
You must be signed in to change notification settings - Fork 248
158 lines (146 loc) · 5.78 KB
/
RunTests.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
name: Run Tests
on:
workflow_dispatch:
inputs:
ref:
description: ref on which to run the end-2-end tests (default is head_sha on the current branch)
required: false
default: ''
testPatterns:
description: Commaseparated list of patterns to match against test names (default is * for all tests)
required: false
default: ''
permissions:
contents: read
actions: read
pull-requests: write
checks: write
concurrency:
group: 'runTests-${{ github.event.inputs.ref }}'
cancel-in-progress: true
defaults:
run:
shell: powershell
jobs:
AnalyzeTests:
runs-on: [ windows-latest ]
outputs:
tests: ${{ steps.Analyze.outputs.tests }}
linuxtests: ${{ steps.Analyze.outputs.linuxtests }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
lfs: true
- name: Analyze
id: Analyze
env:
testPatterns: ${{ github.event.inputs.testPatterns }}
run: |
$errorActionPreference = "stop"
$testPatterns = $ENV:TESTPATTERNS
if (!$testPatterns) { $testPatterns = '*' }
$testPatternArr = $testPatterns.Split(',')
Write-Host "Running test matching patterns:"
$testPatternArr | ForEach-Object { Write-Host "- $_" }
$tests = ConvertTo-Json -compress -InputObject @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\*.Tests.ps1') | Where-Object { $name = $_.Basename; $testPatternArr | Where-Object { $name -like "$($_).Tests" } } | ForEach-Object { $_.BaseName })
Add-Content -Path $env:GITHUB_OUTPUT -Value "tests=$tests"
Write-Host "tests=$tests"
$linuxtests = ConvertTo-Json -compress -InputObject @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\*.Tests.ps1') | Where-Object { $name = $_.Basename; $testPatternArr | Where-Object { $name -like "$($_).Tests" } } | ForEach-Object { $_.BaseName })
Add-Content -Path $env:GITHUB_OUTPUT -Value "linuxtests=$linuxtests"
Write-Host "linuxtests=$linuxtests"
PS5:
runs-on: [ windows-latest ]
needs: [ AnalyzeTests ]
if: needs.AnalyzeTests.outputs.tests != '[]'
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.buildLicenseFile }}' }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}
PS7:
runs-on: [ windows-latest ]
needs: [ AnalyzeTests ]
if: needs.AnalyzeTests.outputs.tests != '[]'
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}}
fail-fast: false
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.buildLicenseFile }}' }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}
Linux:
runs-on: [ ubuntu-latest ]
needs: [ AnalyzeTests ]
if: needs.AnalyzeTests.outputs.linuxtests != '[]'
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.linuxtests)}}
fail-fast: false
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.buildLicenseFile }}' }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}