From 96d95e150412d9acd50e6afa214c3c481401352e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gonza=CC=81lez=20Garci=CC=81a?= Date: Tue, 9 Jan 2024 17:09:15 +0100 Subject: [PATCH] upload codecov coverage --- .github/workflows/build.yml | 14 ++++++++++--- scripts/NMoneys.build.ps1 | 25 +++++++++++++----------- scripts/Verify-CI.ps1 | 11 +++++++++++ tests/NMoneys.Tests/NMoneys.Tests.csproj | 2 +- 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 scripts/Verify-CI.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17716a1..0b117e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/test-reporter@v1.6.0 @@ -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) diff --git a/scripts/NMoneys.build.ps1 b/scripts/NMoneys.build.ps1 index a55ef46..cc2f28d 100644 --- a/scripts/NMoneys.build.ps1 +++ b/scripts/NMoneys.build.ps1 @@ -37,6 +37,7 @@ 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" ` @@ -44,6 +45,19 @@ task Test { } } + $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 } @@ -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 diff --git a/scripts/Verify-CI.ps1 b/scripts/Verify-CI.ps1 new file mode 100644 index 0000000..6a52052 --- /dev/null +++ b/scripts/Verify-CI.ps1 @@ -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" diff --git a/tests/NMoneys.Tests/NMoneys.Tests.csproj b/tests/NMoneys.Tests/NMoneys.Tests.csproj index 0650d53..9e606aa 100644 --- a/tests/NMoneys.Tests/NMoneys.Tests.csproj +++ b/tests/NMoneys.Tests/NMoneys.Tests.csproj @@ -10,7 +10,7 @@ - +