-
Notifications
You must be signed in to change notification settings - Fork 131
376 lines (369 loc) · 14.3 KB
/
github-actions.yml
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
on:
workflow_dispatch:
pull_request:
push:
branches:
- '*'
paths-ignore:
- README.md
tags:
- '*'
schedule:
- cron: '0 18 * * 0'
env:
solution: ${{ github.workspace }}/Ocaramba.sln
buildPlatform: Any CPU
buildConfiguration: Release
frameworkVersion: 4.2.0
TestResultsDirWindows: D:\a\Ocaramba\Ocaramba\TestResults
CHROMEWEBDRIVER: C:\SeleniumWebDrivers\ChromeDriver
BuildVersion: 4.2.0${{ github.run_number }}
ChromeDriverVersion: 122.0.6261.9400
seleniumGridVersion: selenium-server-4.8.0.jar
seleniumGridUrl: https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.8.0/selenium-server-4.8.0.jar
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build_Stage_BuildTestsOnWindows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- shell: powershell
run: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag"
if: startsWith(github.ref, 'refs/tags/')
- shell: powershell
run: '(Get-Content ''Ocaramba.sln'' -raw) -replace [regex](''.*?'' + ''Documentation'' + (''.*?\r\n'' * (5 + 1))) | set-content ''Ocaramba.sln'''
- name: Update ChromeDriver in csproj
run: |
Get-ChildItem ./ *.csproj -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$c = $c -replace '109.0.5414.7400','${{ env.ChromeDriverVersion }}'
[IO.File]::WriteAllText($_.FullName, ($c -join "`r`n"))
}
- name: Setup nuget
uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- name: Cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}\.nuget\packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
restore-keys: |
${{ runner.os }}-nuget-
- name: NuGet restore
run: nuget restore ${{ env.solution }}
- name: Set project versions
id: update
uses: vers-one/[email protected]
with:
file: |
"**/Ocaramba.csproj", "**/OcarambaLite.csproj"
version: ${{ env.frameworkVersion }}
- run: msbuild '${{ env.solution }}' /p:configuration='${{ env.buildConfiguration }}' /p:platform='${{ env.buildPlatform }}' /v:minimal
- uses: actions/upload-artifact@v4
with:
path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.nupkg
name: Ocaramba${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.snupkg
name: OcarambaS${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.nupkg
name: OcarambaLite${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.snupkg
name: OcarambaLiteS${{ env.frameworkVersion }}
- name: Zip artifact for deployment
run: Compress-Archive -Path ./ -Destination OcarambaBuild.zip
- uses: actions/upload-artifact@v4
with:
path: OcarambaBuild.zip
name: OcarambaBuild
compression-level: 0
if: (${{ job.status }} != 'cancelled')
test_Stage_RunTestsOnDocker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ocaramba/selenium:latest
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install docker-compose -y
- run: docker-compose -f docker-compose.yml up -d
- shell: pwsh
run: ./ExecutingTestsOnDockerGithubActions.ps1
if: true
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: true
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.Docker.xml
test_Stage_RunTestsOnLinux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: find . -name '*.csproj' -exec sed -i -e 's/109.0.5414.7400/${{ env.ChromeDriverVersion }}/g' {} \;
- uses: browser-actions/setup-chrome@v1
if: true
- run: chrome --version
- uses: nanasess/setup-chromedriver@v2
- run: |
ls
export ASPNETCORE_ENVIRONMENT=Linux
echo $ASPNETCORE_ENVIRONMENT
sudo apt-get install google-chrome-stable
sed -i '/Documentation/,+5 d' ./Ocaramba.sln
- run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }}
- shell: pwsh
run: ./ExecutingTestsOnLinuxAzure.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: true
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.netcoreapp.xml
check_name: ExecutingTestsOnLinuxAzure
test_Stage_RunTestsOnLinuxBrowserStack:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- run: |
ls
export ASPNETCORE_ENVIRONMENT=Linux
echo $ASPNETCORE_ENVIRONMENT
sed -i '/Documentation/,+5 d' ./Ocaramba.sln
- run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }}
- uses: browser-actions/setup-chrome@v1
if: true
- run: chrome --version
- uses: nanasess/setup-chromedriver@v2
- shell: pwsh
if: true
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ secrets.BROWSERSTACKKEY }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ secrets.BROWSERSTACKUSER }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
run: ./ExecutingTestsOnLinuxBrowserStackGithubActions.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: false
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/BrowserStacknetcoreapp.xml
check_name: test_Stage_RunTestsOnLinuxBrowserStack
test_Stage_RunTestsOnWindowsCore1:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions1.ps1
- run: Get-ChildItem .\ -Recurse
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.trx
check_name: ExecutingTestsOnWindowsGithubActions1
- name: Zip artifact
run: Compress-Archive -Path D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnitExtentReports\bin\Release\net8.0\TestOutput -Destination ExtentReports_${{ github.run_id }}.zip
- uses: actions/upload-artifact@v4
with:
path: ExtentReports_${{ github.run_id }}.zip
name: ExtentTestReport
if: always()
test_Stage_RunTestsOnWindowsCore2:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions2.ps1
- run: Get-ChildItem .\ -Recurse
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.xml
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.EdgeChrominum.xml
check_name: ExecutingTestsOnWindowsGithubActions2
test_Stage_RunTestsOnWindowsFramework:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions3.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.net4.xml
check_name: ExecutingTestsOnWindowsGithubActions3
test_Stage_RunTestsOnWindowsBrowserStack:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions4.ps1
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.BrowserStack.xml
check_name: ExecutingTestsOnWindowsGithubActions4
test_Stage_RunTestsSeleniumGrid:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions5.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.NUnitGrid.xml
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.CloudProviderCrossBrowserGrid.xml
check_name: ExecutingTestsOnWindowsGithubActions5
test_Stage_RunTestsOnWindowsSaucelabs:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions6.ps1
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.saucelabsnet472.xml
check_name: ExecutingTestsOnWindowsGithubActions6
release_Stage_PublishNuget:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
- test_Stage_RunTestsOnDocker
- test_Stage_RunTestsOnLinux
- test_Stage_RunTestsOnLinuxBrowserStack
- test_Stage_RunTestsOnWindowsCore1
- test_Stage_RunTestsOnWindowsCore2
- test_Stage_RunTestsOnWindowsFramework
- test_Stage_RunTestsOnWindowsBrowserStack
- test_Stage_RunTestsSeleniumGrid
- test_Stage_RunTestsOnWindowsSaucelabs
steps:
- uses: actions/checkout@v4
- shell: powershell
run: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag"
if: startsWith(github.ref, 'refs/tags/')
- uses: actions/download-artifact@v4
with:
name: Ocaramba${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaS${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaLite${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaLiteS${{ env.frameworkVersion }}
- run: Get-ChildItem ./ -Recurse
- name: Push Nuget Package
run: dotnet push .\Ocaramba\Ocaramba\Ocaramba.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
if: (success() && startsWith(github.ref, 'refs/tags/'))
- name: Push Nuget Package
run: dotnet push .\Ocaramba\Ocaramba\OcarambaLite.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
if: (success() && startsWith(github.ref, 'refs/tags/'))