Skip to content

Commit

Permalink
upload codecov coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dgg committed Jan 9, 2024
1 parent b450249 commit 96d95e1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ jobs:
- name: Copy-Artifacts
shell: pwsh
run: ./build.ps1 -task CopyArtifacts -verbosity "${{ env.VERBOSITY }}" -configuration "${{ env.CONFIGURATION }}"
#- name: Build-All
# shell: pwsh
# run: ./build.ps1

- name: Test Reporter
if: ${{ !env.ACT }}
uses: dorny/[email protected]
Expand Down Expand Up @@ -67,3 +65,13 @@ jobs:
with:
name: packages
path: ./release/*.nupkg

- name: Upload Codecov Coverage
uses: codecov/codecov-action@v3
with:
# token: ${{ secrets.CODECOV_TOKEN }}
files: ./release/TestResults/coverage.cobertura.xml
flags: unittests # optional
name: codecov-nmoneys # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
25 changes: 14 additions & 11 deletions scripts/NMoneys.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,27 @@ task Test {
exec {
& dotnet test --no-build -c $configuration --nologo -v $verbosity $tests_dir `
--results-directory $RELEASE_DIR `
--collect:"XPlat Code Coverage" `
-l:"console;verbosity=minimal;NoSummary=true" `
-l:"trx;LogFileName=$trx" `
-l:"html;LogFileName=$html" `
-- NUnit.TestOutputXml=TestResults NUnit.OutputXmlFolderMode=RelativeToResultDirectory
}
}

$test_results_dir = Join-Path $RELEASE_DIR TestResults
# copy coverage file to $RELEASE_DIR/TestResults
$RELEASE_DIR |
Get-ChildItem -exclude TestResults |
Get-ChildItem -Recurse |
Where-Object { $_.Name -match 'coverage.cobertura.xml' } |
Copy-Item -Destination $test_results_dir

# clean coverage directories
$RELEASE_DIR |
Get-ChildItem -Directory -Exclude 'TestResults' |
Remove-Item -Recurse

# TODO: generate extra HTML reports
}

Expand All @@ -69,17 +83,6 @@ task Publish -depends Restore, Compile, Pack {
push
}

task VerifyCI {
$artifacts_dir = Join-Path $RELEASE_DIR artifacts
$workflow = Join-Path $BASE_DIR .github workflows build.yml
exec { & act `
-W $workflow `
-P ubuntu-22.04=catthehacker/ubuntu:pwsh-22.04 `
--artifact-server-path $artifacts_dir `
-q
}
}

function push {
param (
[Parameter(ValueFromPipeline = $true)][System.IO.FileInfo]$nupkg
Expand Down
11 changes: 11 additions & 0 deletions scripts/Verify-CI.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$BASE_DIR = Resolve-Path .. -RelativeBasePath $PSScriptRoot
$RELEASE_DIR = Join-Path $BASE_DIR release

$artifacts_dir = Join-Path $RELEASE_DIR artifacts

$workflow = Join-Path $BASE_DIR .github workflows build.yml

& act `
-W $workflow `
-P ubuntu-22.04=catthehacker/ubuntu:pwsh-22.04 `
--artifact-server-path "$artifacts_dir"
2 changes: 1 addition & 1 deletion tests/NMoneys.Tests/NMoneys.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.8.0" />
Expand Down

0 comments on commit 96d95e1

Please sign in to comment.