11name : Build and Test
22
33on :
4+ workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : ' Tag Ref'
8+ required : true
49 pull_request :
510 branches : [ master ]
611 push :
914
1015jobs :
1116 Build :
12- runs-on : ${{ matrix.os }}-latest
17+ runs-on : ${{ matrix.os }}
1318 strategy :
1419 fail-fast : false
1520 matrix :
16- os : [ubuntu, windows, macos]
21+ os : [ubuntu-latest , windows-2019 , macos-latest ]
1722 target : [netstandard2.0, netstandard2.1]
1823 include :
19- - os : windows
24+ - os : windows-2019
2025 target : net45
2126 env :
2227 LIB_PROJ : src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
2328 steps :
2429 - uses : actions/checkout@v2
25-
30+ with :
31+ ref : ${{ github.events.inputs.tag }}
32+ fetch-depth : 0
33+
2634 - name : Setup .NET Core
2735 uses : actions/setup-dotnet@v1
2836 with :
2937 dotnet-version : ' 3.1.x'
38+
39+ - name : Show .NET info
40+ run : dotnet --info
3041
3142 - name : Build library (Debug)
3243 run : dotnet build -c debug -f ${{ matrix.target }} ${{ env.LIB_PROJ }}
@@ -39,47 +50,77 @@ jobs:
3950 strategy :
4051 fail-fast : false
4152 matrix :
42- os : [ubuntu, windows, macos]
53+ # Windows testing is combined with code coverage
54+ os : [ubuntu, macos]
4355 target : [netcoreapp3.1]
44- include :
45- - os : windows
46- target : net46
4756 steps :
4857 - uses : actions/checkout@v2
49-
58+ with :
59+ fetch-depth : 0
60+
5061 - name : Setup .NET Core
5162 if : matrix.target == 'netcoreapp3.1'
5263 uses : actions/setup-dotnet@v1
5364 with :
5465 dotnet-version : ' 3.1.x'
5566
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-
6167 - name : Restore test dependencies
6268 run : dotnet restore
6369
6470 - name : Run tests (Debug)
6571 run : dotnet test -c debug -f ${{ matrix.target }} --no-restore
6672
6773 - 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' }}
7574 run : dotnet test -c release -f ${{ matrix.target }} --no-restore
7675
76+
77+ CodeCov :
78+ name : Code Coverage
79+ runs-on : windows-2019
80+ env :
81+ DOTCOVER_VER : 2021.1.2
82+ DOTCOVER_PKG : jetbrains.dotcover.commandlinetools
83+ COVER_SNAPSHOT : SharpZipLib.dcvr
84+ steps :
85+ - uses : actions/checkout@v2
86+ with :
87+ fetch-depth : 0
88+
89+ - name : Setup .NET
90+ uses : actions/setup-dotnet@v1
91+ with :
92+ dotnet-version : ' 3.1.x'
93+
94+ # NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
95+ - name : Cleanup before restore
96+ run : dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
97+
98+ - name : Install codecov
99+ run : nuget install -o tools -version ${{env.DOTCOVER_VER}} ${{env.DOTCOVER_PKG}}
100+
101+ - name : Add dotcover to path
102+ run : echo "$(pwd)\tools\${{env.DOTCOVER_PKG}}.${{env.DOTCOVER_VER}}\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
103+
104+ - name : Run tests with code coverage
105+ run : dotcover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c release
106+
107+ - name : Create code coverage report
108+ run : dotcover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml
109+
77110 - name : Upload coverage to Codecov
78111112+ with :
113+ files : dotcover-report.xml
114+
115+ - name : Upload coverage snapshot artifact
116+ uses : actions/upload-artifact@v2
117+ with :
118+ name : Code coverage snapshot
119+ path : ${{env.COVER_SNAPSHOT}}
79120
80121 Pack :
81- needs : [Build, Test]
82- runs-on : windows-latest
122+ needs : [Build, Test, CodeCov ]
123+ runs-on : windows-2019
83124 env :
84125 PKG_SUFFIX : ' '
85126 PKG_PROJ : src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
88129 steps :
89130 - uses : actions/checkout@v2
90131 with :
132+ ref : ${{ github.events.inputs.tag }}
91133 fetch-depth : 0
92134
93135 - name : Setup .NET Core
@@ -106,8 +148,18 @@ jobs:
106148 if : ${{ github.event_name == 'pull_request' }}
107149 run : echo "PKG_SUFFIX=-PR" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
108150
151+ - name : Set package version
152+ continue-on-error : true
153+ run : |-
154+ $PKG_GIT_VERSION="$(git describe --tags --abbrev | % { $_.substring(1) })"
155+ Write-Output "::notice::Git describe: $PKG_GIT_VERSION"
156+ Write-Output "::notice::Package suffix: $env:PKG_SUFFIX"
157+ $PKG_VERSION = "${PKG_GIT_VERSION}${env:PKG_SUFFIX}"
158+ Write-Output "::notice::Package version: $PKG_VERSION"
159+ Write-Output "PKG_VERSION=$PKG_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
160+
109161 - name : Create nuget package
110- run : dotnet pack ${{ env.PKG_PROJ }} -c Release --output dist ${{ env.PKG_PROPS }} /p:Version=$(git describe --abbrev | % { $_.substring(1) })${{ env.PKG_SUFFIX }}
162+ run : dotnet pack ${{ env.PKG_PROJ }} -c Release --output dist ${{ env.PKG_PROPS }} /p:Version=${{ env.PKG_VERSION }}
111163
112164 - name : Upload nuget package artifact
113165 uses : actions/upload-artifact@v2
0 commit comments