-
Notifications
You must be signed in to change notification settings - Fork 11
651 lines (604 loc) · 27.4 KB
/
build.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
name: Build
on:
schedule:
- cron: "13 23 * * *"
push:
branches:
- main
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
override:
description: 'Version Number'
required: true
default: '0.0.0'
jobs:
waitOld:
name: Wait For Older Runs To Complete
runs-on: ubuntu-latest
steps:
- name: Wait
id: wait
shell: pwsh
run: |
$runID = ${{ github.run_id }}
$endPoint = "https://api.github.com/repos/${{github.repository}}/actions/runs"
$timeout = New-TimeSpan -Minutes 60
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
do {
$result = Invoke-RestMethod -Uri $endPoint
$builds = $result.workflow_runs | Where-Object {$_.name -eq "Build" -and ($_.status -eq "in_progress" -or $_.status -eq "queued") -and $_.id -lt $runID}
# Check if there were any older build runs still going, if not we waited long enough
if (!$builds)
{
Write-Host "Are now top of the run queue"
return
}
Start-Sleep -s 60
Write-Host "Waited so far $($stopwatch.elapsed)"
} while ($stopwatch.elapsed -lt $timeout)
Write-Host "Waited more than an hour for earlier runs to complete, continuing action pipeline"
draftRelease:
name: Draft release
needs: waitOld
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
getVersion:
name: Get package version
runs-on: ubuntu-latest
needs: draftRelease
outputs:
buildNumber: ${{ steps.ver.outputs.BUILD_NUMBER }}
steps:
- name: GetVersion
id: ver
shell: pwsh
run: |
if ("${{github.event.inputs.override}}")
{
Write-Host "Using manually entered override version"
$version = "${{ github.event.inputs.override}}"
}
else
{
$header = @{Authorization = 'Bearer ${{ secrets.GITHUB_TOKEN }}' }
$endPoint = "https://api.github.com/repos/${{github.repository}}/releases"
$info = Invoke-RestMethod -Uri $endPoint -Headers $header
$version = $info.name[0].Trim("v")
}
Write-Host "::set-output name=BUILD_NUMBER::$($version)"
test-untils:
name: Utils
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: builder
env:
GlobalMaqs:ConfigJsonEnvRunOverride: ENV
GlobalMaqs:ConfigJsonEnvRun: ENV
GlobalMaqs:ConfigJsonEnv: ENV
GlobalMaqs:EnvOnly: ENV
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/UtilitiesUnitTests/UtilitiesUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/untils/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/untils/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: untilResults
path: |
artifactTests/untils/**/*.xml
artifactTests/untils/testResults/
test-winapp:
name: WinApp
needs: waitOld
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Install Appium
run: npm install -g appium
- name: Run Appium
run: invoke-expression 'cmd /c start appium'
shell: pwsh
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter FullyQualifiedName~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/winapp/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/winapp/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: winappResults
path: |
artifactTests/winapp/**/*.xml
artifactTests/winapp/testResults/
test-appium:
name: Appium
# Skip when dependabot PR - Dependabot PRs cannot access action secrets
if: github.actor != 'dependabot[bot]'
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter FullyQualifiedName!~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/appium/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/appium/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"AppiumCapsMaqs:sauce:options:accessKey\",value=\"${{ secrets.SAUCE }}\")'''
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: appiumResults
path: |
artifactTests/appium/**/*.xml
artifactTests/appium/testResults/
test-base:
name: Base
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/BaseTestUnitTests/BaseTestUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/base/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/base/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: baseResults
path: |
artifactTests/base/**/*.xml
artifactTests/base/testResults/
test-webservice:
name: WebService
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
6.x.x
- name: Start test service
run: Start-Process -FilePath "dotnet" -ArgumentList "run --project Docker/MAQSService/MainTestService/MainTestService.csproj"
shell: pwsh
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/WebServiceUnitTests/WebServiceUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/webservice/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/webservice/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: webserviceResults
path: |
artifactTests/webservice/**/*.xml
artifactTests/webservice/testResults/
test-playwright:
name: Playwright
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Playwright
run: |
npx playwright install --with-deps
dotnet build Framework/PlaywrightTests/PlaywrightTests.csproj -o Framework/PlaywrightTests/build
pwsh Framework/PlaywrightTests/build/playwright.ps1 install
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/PlaywrightTests/PlaywrightTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/Playwright/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/Playwright/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'playwright'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: playwrightResults
path: |
artifactTests/Playwright/**/*.xml
artifactTests/Playwright/testResults/
test-mongo:
name: Mongo
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the docker-compose stack
run: docker-compose -f Docker/MAQSMongoDB/docker-compose.yml -p CognizantOpenSource/maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/MongoDBUnitTests/MongoDBUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/mongo/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/mongo/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'mongo'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: mongoResults
path: |
artifactTests/mongo/**/*.xml
artifactTests/mongo/testResults/
test-database:
name: Database
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the docker-compose stack
run: docker-compose -f Docker/MAQSSQLServer/docker-compose.yml -p CognizantOpenSource/maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/DatabaseUnitTests/DatabaseUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/database/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/database/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'database'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: databaseResults
path: |
artifactTests/database/**/*.xml
artifactTests/database/testResults/
test-email:
name: Email
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the docker-compose stack
run: docker-compose -f Docker/MAQSEmail/docker-compose.yml -p CognizantOpenSource/maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/EmailUnitTests/EmailUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/email/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/email/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'email'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: emailResults
path: |
artifactTests/email/**/*.xml
artifactTests/email/testResults/
test-framework:
name: Framework
needs: waitOld
runs-on: windows-2019
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
6.x.x
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Playwright
run: |
npx playwright install --with-deps
dotnet build Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -o Framework/FrameworkUnitTests/build
pwsh Framework/FrameworkUnitTests/build/playwright.ps1 install
- run: dotnet restore Framework/FrameworkUnitTests/FrameworkUnitTests.csproj
shell: pwsh
- id: browserupdate
uses: ./.github/workflows/setupwinbrowser-action
- id: testframework
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -f net471 --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/framework/testResults/"'
- id: testcore
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -f netcoreapp3.1 --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/framework/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/framework/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: frameworkResults
path: |
artifactTests/framework/**/*.xml
artifactTests/framework/testResults/
test-specflow:
name: SpecFlow
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SpecFlowExtensionUnitTests/SpecFlowExtensionUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/specflow/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/specflow/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: specflowResults
path: |
artifactTests/specflow/**/*.xml
artifactTests/specflow/testResults/
test-composite:
name: Composite
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- name: Build the docker-compose mongo stack
run: docker-compose -f Docker/MAQSMongoDB/docker-compose.yml -p CognizantOpenSource/maqs-dotnet up -d
- name: Build the docker-compose email stack
run: docker-compose -f Docker/MAQSEmail/docker-compose.yml -p CognizantOpenSource/maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/CompositeUnitTests/CompositeUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/composite/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/composite/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: compositeResults
path: |
artifactTests/composite/**/*.xml
artifactTests/composite/testResults/
test-specflownunit:
name: SpecFlow NUnit
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SpecFlowExtensionNUnitTests/SpecFlowExtensionNUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/specflownunit/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/specflownunit/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: specflownunitResults
path: |
artifactTests/specflownunit/**/*.xml
artifactTests/specflownunit/testResults/
test-selenpomlazy:
name: Selenium POM and Lazy
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter "(FullyQualifiedName~SeleniumUnitTests.LazyElementUnitTests)|(FullyQualifiedName~SeleniumPageObjectUnitTest)|(FullyQualifiedName~SeleniumWebElementTest)|(FullyQualifiedName~Proxy)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selenpomlazy/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selenpomlazy/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: pomlazyResults
path: |
artifactTests/selenpomlazy/**/*.xml
artifactTests/selenpomlazy/testResults/
test-selenutil:
name: Selenium Utils
needs: waitOld
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- run: dotnet restore Framework/Base.sln
shell: pwsh
- run: choco upgrade firefox
shell: pwsh
- id: browserupdate
uses: ./.github/workflows/setupwinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter "(FullyQualifiedName~SeleniumUnitTests.SeleniumNUnitTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumUnitTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumUtilsTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumConfigTests)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selenutil/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selenutil/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: selenutilResults
path: |
artifactTests/selenutil/**/*.xml
artifactTests/selenutil/testResults/
test-selengen:
name: Selenium General
# Skip when dependabot PR - Dependabot PRs cannot access action secrets
if: github.actor != 'dependabot[bot]'
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- run: |
Write-Host "Installing/Updating Firefox"
sudo apt-get --only-upgrade install firefox
shell: pwsh
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter "(FullyQualifiedName!~SeleniumNUnitTest)&(FullyQualifiedName!~Proxy)&(FullyQualifiedName!~SeleniumConfigTests)&(FullyQualifiedName!~SeleniumPageObjectUnitTest)&(FullyQualifiedName!~LazyElementUnitTests)&(FullyQualifiedName!~SeleniumUnitTests.SeleniumUnitTest)&(FullyQualifiedName!~SeleniumWebElementTest)&(FullyQualifiedName!~SeleniumUtilsTest)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selengen/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selengen/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"RemoteSeleniumCapsMaqs:sauce:options:accessKey\",value=\"${{ secrets.SAUCE }}\")'' ''TestRunParameters.Parameter(name=\"SeleniumMaqs:RunOnSauceLabs\",value=\"YES\")'''
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
with:
name: selengenResults
path: |
artifactTests/selengen/**/*.xml
artifactTests/selengen/testResults/
sonar:
name: Sonar
# Skip when dependabot PR - Dependabot PRs cannot access action secrets
if: github.actor != 'dependabot[bot]'
runs-on: windows-2019
needs: [test-appium, test-winapp, test-untils, test-mongo, test-database, test-webservice, test-base, test-playwright, test-email, test-framework, test-specflow, test-specflownunit, test-composite, test-selenpomlazy, test-selenutil, test-selengen, getVersion]
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}/Results
- name: Update coverage mappings
shell: pwsh
run: |
$rootPath = "${{ github.workspace }}/Results"
$sourcePath = "${{ github.workspace }}"
Write-Host "Start updating relative paths"
Function Replace($path, $pattern, $replace)
{
$text = (Get-Content $path) -join "`n"
[System.Text.RegularExpressions.Regex]::Replace($text, $pattern, $replace) | Out-File -encoding ASCII $path
}
$files = Get-ChildItem -Path $rootPath -Recurse -Include *.xml
foreach ($file in $files)
{
Write-Host "Updating" $file
Replace $file.FullName '(?<=fullPath=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath
Replace $file.FullName '(?<=fullPath="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
}
$files = Get-ChildItem -Path $rootPath -Recurse -Include *.trx
foreach ($file in $files)
{
Write-Host "Updating" $file
Replace $file.FullName '(?<=codeBase=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath
Replace $file.FullName '(?<=codeBase="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
Replace $file.FullName '(?<=storage=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath.ToLower()
Replace $file.FullName '(?<=storage="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
}
Write-Host "Finished updating relative paths"
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"CognizantOpenSource_maqs-dotnet" /o:"cognizantopensource" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:projectVersion="${{ needs.getVersion.outputs.buildNumber }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=${{ github.workspace }}\Results\**\coverage*.opencover.xml /d:sonar.cs.dotcover.reportsPaths=${{ github.workspace }}\Results\**\*.coverage
dotnet build Framework/Base.sln -p:Version=${{ needs.getVersion.outputs.buildNumber }}
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
report:
name: Report
runs-on: ubuntu-latest
needs: [test-appium, test-winapp, test-untils, test-mongo, test-database, test-webservice, test-base, test-email, test-playwright, test-framework, test-specflow, test-specflownunit, test-composite, test-selenpomlazy, test-selenutil, test-selengen]
if: always()
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}/Results
- name: Test Report
# Skip because dependabot cannot access the associated resources
if: github.actor != 'dependabot[bot]'
uses: dorny/test-reporter@v1
continue-on-error: true
with:
name: ReportResults
path: ${{ github.workspace }}/Results/**/*.trx # Path to test results
reporter: dotnet-trx
createNugetPacakges:
name: Create NuGet pacakges
runs-on: windows-2019
needs: [getVersion]
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore Framework/Base.sln
- name: Build
run: |
dotnet build Framework/Base.sln --no-restore --configuration Release -p:Version=${{needs.getVersion.outputs.buildNumber}} -p:BaseOutputPath="${{github.workspace}}/artifactTests/packages/"
- uses: actions/upload-artifact@v2
if: always()
name: "Upload NuGet packages artifact"
with:
name: packages
path: |
artifactTests/packages/**/*.nupkg
artifactTests/packages/**/*.snupkg
publish:
name: Publish NuGet - v${{ needs.getVersion.outputs.buildNumber }}
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.event_name != 'schedule'
needs: [getVersion, createNugetPacakges, sonar]
runs-on: windows-2019
environment: nuget
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- uses: actions/download-artifact@v2
with:
name: 'packages'
path: ${{ github.workspace }}/packages
- name: Deploy to nuget
run: dotnet nuget push ${{ github.workspace }}/packages/**/*.nupkg --api-key ${{ secrets.APIKEY }} --source https://api.nuget.org/v3/index.json
- name: Publish GitHub release v${{ needs.getVersion.outputs.buildNumber }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const result = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
var id = "NA"
var data = result.data
for(var key in data){
if(data[key].tag_name == "v${{ needs.getVersion.outputs.buildNumber }}" && data[key].draft == true)
{
github.repos.updateRelease({
release_id: data[key].id,
"draft": false,
owner: context.repo.owner,
repo: context.repo.repo });
return;
}
}
console.error("Failed to find related draft release");