Skip to content

Commit

Permalink
ci: use dotcover for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
piksel committed May 13, 2021
1 parent 0fc736e commit 7debd7e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
60 changes: 42 additions & 18 deletions .github/workflows/build-test.yml
Expand Up @@ -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:
Expand All @@ -39,41 +41,63 @@ 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

- name: Run tests (Debug)
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

Expand Down
Expand Up @@ -8,15 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="nunit" Version="3.13.1" />
<PackageReference Include="nunit.console" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="OpenCover" Version="4.6.519" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
Expand Down

0 comments on commit 7debd7e

Please sign in to comment.