Last active
March 25, 2024 12:58
-
-
Save fluxdigital/13a556204dd2f6f9ce786e9f25596cde to your computer and use it in GitHub Desktop.
Git Hub actions yaml file for Code Cov with Sitecore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Setup VSTest Path | |
uses: darenm/[email protected] | |
- name: Install Coverlet | |
run: dotnet tool install --global coverlet.console | |
shell: cmd | |
- name: Run Coverlet & Unit Tests for all test projects | |
run: | | |
$basePath = "." | |
$reportPath = "coverlet" | |
$incNamePattern = "*Fluxdigital*test*.dll" | |
$incVSTestNamePattern = "[Fluxdigital.*]*" | |
#get all test dlls in the solution - filter here to reduce duplicates | |
$testdlls = (Get-ChildItem $basePath -include $($incNamePattern) -recurse | ? {$_.FullName -match 'Release' -and $_.FullName -notmatch 'obj' -and $_.FullName -notmatch 'LocalPublish'}).FullName | |
#write-host "$($testdlls.Count) test dlls found..." | |
[System.Collections.ArrayList]$uniquedlls = @() | |
#ensure we only get each test dll once by adding them to an arraylist | |
foreach ($testdll in $testdlls){ | |
$fileName = [System.IO.Path]::GetFileName($testdll) | |
#write-host "checking for $($fileName)" | |
if($uniquedlls -match $fileName){ | |
#write-host "allready in array" | |
} | |
else{ | |
$uniquedlls.Add($testdll) | out-null | |
} | |
} | |
#run coverlet for each test dll in the list | |
write-host "$($uniquedlls.Count) unique test dlls found..." | |
foreach ($uniquedll in $uniquedlls){ | |
$fileName = [System.IO.Path]::GetFileName($uniquedll) | |
$cmd = @" | |
coverlet $($uniquedll) --target "vstest.console.exe" --targetargs "$($uniquedll)" --output "$($reportPath)\coverlet-$($fileName.Replace('.dll','')).cobertura" --format cobertura --include "$($incVSTestNamePattern)" --verbosity detailed | |
"@ | |
write-host "running tests for: $($fileName) - report path: $($reportPath)\coverlet-$($fileName.Replace('.dll','')).cobertura" | |
$($cmd) | cmd | |
} | |
shell: pwsh | |
- name: Install ReportGenerator | |
run: dotnet tool install -g dotnet-reportgenerator-globaltool | |
shell: cmd | |
- name: Create Single Coverage Report file with ReportGenerator | |
run: reportgenerator "-reports:coverlet\*.cobertura" "-targetdir:coverlet\report" -reporttypes:Cobertura | |
shell: cmd | |
- name: Generate Coverage Markdown Report | |
uses: clearlyip/code-coverage-report-action@v4 | |
id: code_coverage_report_action | |
with: | |
filename: 'coverlet\report\Cobertura.xml' | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
directory: ./coverlet/report/ | |
fail_ci_if_error: false | |
files: Cobertura.xml | |
flags: unittests | |
name: FluxDigital.Extensions | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: fluxdigital/FluxDigital.Extensions | |
verbose: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment