From b4a5b04d738716e24d7df54ec9fa48321449bcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Thu, 13 May 2021 15:33:26 +0200 Subject: [PATCH] ci: use dotcover for code coverage --- .github/workflows/build-test.yml | 70 ++++++++++++++----- .../ICSharpCode.SharpZipLib.Tests.csproj | 5 -- 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b9217ee3..254ff46e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,7 +22,9 @@ jobs: LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj steps: - uses: actions/checkout@v2 - + with: + fetch-depth: 0 + - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: @@ -39,25 +41,20 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu, windows, macos] + # Windows testing is combined with code coverage + os: [ubuntu, macos] target: [netcoreapp3.1] - include: - - os: windows - target: net46 steps: - uses: actions/checkout@v2 - + with: + fetch-depth: 0 + - name: Setup .NET Core if: matrix.target == 'netcoreapp3.1' uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.x' - # NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090 - - name: Cleanup before restore - if: ${{ matrix.os == 'windows' }} - run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear - - name: Restore test dependencies run: dotnet restore @@ -65,20 +62,55 @@ jobs: run: dotnet test -c debug -f ${{ matrix.target }} --no-restore - name: Run tests (Release) - # Only upload code coverage for windows in an attempt to fix the broken code coverage - if: ${{ matrix.os == 'windows' }} - run: dotnet test -c release -f ${{ matrix.target }} --no-restore --collect="XPlat Code Coverage" - - - name: Run tests with coverage (Release) - # Only upload code coverage for windows in an attempt to fix the broken code coverage - if: ${{ matrix.os != 'windows' }} run: dotnet test -c release -f ${{ matrix.target }} --no-restore + + CodeCov: + name: Code Coverage + runs-on: windows-latest + env: + DOTCOVER_VER: 2021.1.2 + DOTCOVER_PKG: jetbrains.dotcover.commandlinetools + COVER_SNAPSHOT: SharpZipLib.dcvr + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' + + # NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090 + - name: Cleanup before restore + run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear + + - name: Install codecov + run: nuget install -o tools -version ${{env.DOTCOVER_VER}} ${{env.DOTCOVER_PKG}} + + - name: Add dotcover to path + run: echo "$(pwd)\tools\${{env.DOTCOVER_PKG}}.${{env.DOTCOVER_VER}}\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Run tests with code coverage + run: dotcover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c release + + - name: Create code coverage report + run: dotcover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml + - name: Upload coverage to Codecov uses: codecov/codecov-action@v1.2.2 + with: + files: dotcover-report.xml + + - name: Upload coverage snapshot artifact + uses: actions/upload-artifact@v2 + with: + name: Code coverage snapshot + path: ${{env.COVER_SNAPSHOT}} Pack: - needs: [Build, Test] + needs: [Build, Test, CodeCov] runs-on: windows-latest env: PKG_SUFFIX: '' diff --git a/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj b/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj index 2c2a261d..fd6f61ae 100644 --- a/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj +++ b/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj @@ -8,15 +8,10 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - -