Skip to content

Commit 0fe434b

Browse files
committed
ci: use dotcover for code coverage
1 parent 0fc736e commit 0fe434b

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

.github/workflows/build-test.yml

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
2323
steps:
2424
- uses: actions/checkout@v2
25-
25+
with:
26+
fetch-depth: 0
27+
2628
- name: Setup .NET Core
2729
uses: actions/setup-dotnet@v1
2830
with:
@@ -39,43 +41,73 @@ jobs:
3941
strategy:
4042
fail-fast: false
4143
matrix:
42-
os: [ubuntu, windows, macos]
44+
# Windows testing is combined with code coverage
45+
os: [ubuntu, macos]
4346
target: [netcoreapp3.1]
44-
include:
45-
- os: windows
46-
target: net46
4747
steps:
4848
- uses: actions/checkout@v2
49-
49+
with:
50+
fetch-depth: 0
51+
5052
- name: Setup .NET Core
5153
if: matrix.target == 'netcoreapp3.1'
5254
uses: actions/setup-dotnet@v1
5355
with:
5456
dotnet-version: '3.1.x'
5557

56-
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
57-
- name: Cleanup before restore
58-
if: ${{ matrix.os == 'windows' }}
59-
run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
60-
6158
- name: Restore test dependencies
6259
run: dotnet restore
6360

6461
- name: Run tests (Debug)
6562
run: dotnet test -c debug -f ${{ matrix.target }} --no-restore
6663

6764
- name: Run tests (Release)
68-
# Only upload code coverage for windows in an attempt to fix the broken code coverage
69-
if: ${{ matrix.os == 'windows' }}
70-
run: dotnet test -c release -f ${{ matrix.target }} --no-restore --collect="XPlat Code Coverage"
71-
72-
- name: Run tests with coverage (Release)
73-
# Only upload code coverage for windows in an attempt to fix the broken code coverage
74-
if: ${{ matrix.os != 'windows' }}
7565
run: dotnet test -c release -f ${{ matrix.target }} --no-restore
7666

67+
68+
CodeCov:
69+
name: Code Coverage
70+
runs-on: windows-latest
71+
env:
72+
DOTCOVER_VER: 2021.1.2
73+
DOTCOVER_PKG: jetbrains.dotcover.commandlinetools
74+
COVER_SNAPSHOT: SharpZipLib.dcvr
75+
steps:
76+
- uses: actions/checkout@v2
77+
with:
78+
fetch-depth: 0
79+
80+
- name: Setup .NET
81+
uses: actions/setup-dotnet@v1
82+
with:
83+
dotnet-version: '3.1.x'
84+
85+
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
86+
- name: Cleanup before restore
87+
run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
88+
89+
- name: Install codecov
90+
run: nuget install -o tools -version ${{env.DOTCOVER_VER}} ${{env.DOTCOVER_PKG}}
91+
92+
- name: Add dotcover to path
93+
run: echo "$(pwd)\tools\${{env.DOTCOVER_PKG}}.${{env.DOTCOVER_VER}}\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
94+
95+
- name: Run tests with code coverage
96+
run: dotcover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c release
97+
98+
- name: Create code coverage report
99+
run: dotcover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml
100+
77101
- name: Upload coverage to Codecov
78102
uses: codecov/codecov-action@v1.2.2
103+
with:
104+
files: dotcover-report.xml
105+
106+
- name: Upload coverage snapshot artifact
107+
uses: actions/upload-artifact@v2
108+
with:
109+
name: Code coverage snapshot
110+
path: ${{env.COVER_SNAPSHOT}}
79111

80112
Pack:
81113
needs: [Build, Test]

test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="coverlet.collector" Version="3.0.3">
12-
<PrivateAssets>all</PrivateAssets>
13-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14-
</PackageReference>
1511
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
1612
<PackageReference Include="nunit" Version="3.13.1" />
1713
<PackageReference Include="nunit.console" Version="3.12.0" />
1814
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
19-
<PackageReference Include="OpenCover" Version="4.6.519" />
2015
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
2116
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2217
</ItemGroup>

0 commit comments

Comments
 (0)