Skip to content

Commit 78903d8

Browse files
Update CI and coverage
1 parent 3ea7b27 commit 78903d8

8 files changed

Lines changed: 93 additions & 22 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,64 @@ jobs:
8585
CI: True
8686
XUNIT_PATH: .\tests\ImageSharp.Drawing.Tests # Required for xunit
8787

88+
# Avoid "Please provide the repository token to upload reports via `-t :repository-token`"
89+
# https://community.codecov.io/t/whitelist-github-action-servers-to-upload-without-a-token/491/10
90+
# https://github.community/t5/GitHub-Actions/Make-secrets-available-to-builds-of-forks/m-p/42814/highlight/true#M5129
8891
- name: Update Codecov
8992
uses: iansu/codecov-action-node@v1.0.0
90-
if: matrix.options.codecov == true
93+
if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors')
9194
with:
92-
token: ${{secrets.CODECOV_TOKEN}}
93-
file: "coverage.${{matrix.options.framework}}.xml"
95+
token: 0ef021c7-2679-4012-b42f-4bed33d99450
9496
flags: unittests
9597

96-
- name: Pack # We can use this filter as we know it happens only once and takes the most time to complete.
97-
if: (github.event_name == 'push') && (matrix.options.codecov == true)
98+
Publish:
99+
needs: [Build]
100+
101+
runs-on: windows-latest
102+
103+
if: (github.event_name == 'push')
104+
105+
steps:
106+
- uses: actions/checkout@v2
107+
108+
- name: Install NuGet
109+
uses: NuGet/setup-nuget@v1
110+
111+
- name: Setup Git
112+
shell: bash
113+
run: |
114+
git config --global core.autocrlf false
115+
git config --global core.longpaths true
116+
git fetch --prune --unshallow
117+
git submodule -q update --init --recursive
118+
119+
- name: Fetch Tags for GitVersion
120+
run: |
121+
git fetch --tags
122+
123+
- name: Fetch master for GitVersion
124+
if: github.ref != 'refs/heads/master'
125+
run: git branch --create-reflog master origin/master
126+
127+
- name: Install GitVersion
128+
uses: gittools/actions/setup-gitversion@v0.3
129+
with:
130+
versionSpec: "5.1.x"
131+
132+
- name: Use GitVersion
133+
id: gitversion # step id used as reference for output values
134+
uses: gittools/actions/execute-gitversion@v0.3
135+
136+
- name: Setup DotNet SDK
137+
uses: actions/setup-dotnet@v1
138+
with:
139+
dotnet-version: "3.1.101"
140+
141+
- name: Pack
98142
shell: pwsh
99-
run: ./ci-build.ps1 "${{steps.gitversion.outputs.nuGetVersion}}"
143+
run: ./ci-pack.ps1 "${{steps.gitversion.outputs.nuGetVersion}}"
100144

101145
- name: Publish to MyGet
102-
if: (github.event_name == 'push') && (matrix.options.codecov == true)
103146
shell: pwsh
104147
run: nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package
105148
# TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org

ImageSharp.Drawing.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
.gitignore = .gitignore
1111
.gitmodules = .gitmodules
1212
ci-build.ps1 = ci-build.ps1
13+
ci-pack.ps1 = ci-pack.ps1
1314
ci-test.ps1 = ci-test.ps1
1415
Directory.Build.props = Directory.Build.props
1516
Directory.Build.targets = Directory.Build.targets

ci-build.ps1

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
param(
22
[Parameter(Mandatory, Position = 0)]
33
[string]$version,
4-
[Parameter(Mandatory = $false, Position = 1)]
5-
[string]$targetFramework = 'ALL'
4+
[Parameter(Mandatory = $true, Position = 1)]
5+
[string]$targetFramework
66
)
77

88
dotnet clean -c Release
99

1010
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
11-
if ($targetFramework -ne 'ALL') {
1211

13-
# Building for a specific framework.
14-
dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
15-
}
16-
else {
17-
18-
# Building for packing and publishing.
19-
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
20-
}
12+
# Building for a specific framework.
13+
dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl

ci-pack.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
param(
2+
[Parameter(Mandatory, Position = 0)]
3+
[string]$version
4+
)
5+
6+
dotnet clean -c Release
7+
8+
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
9+
10+
# Building for packing and publishing.
11+
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Documentation: https://docs.codecov.io/docs/codecov-yaml
2+
3+
codecov:
4+
# Avoid "Missing base report"
5+
# https://github.com/codecov/support/issues/363
6+
# https://docs.codecov.io/docs/comparing-commits
7+
allow_coverage_offsets: true
8+
9+
# Avoid Report Expired
10+
# https://docs.codecov.io/docs/codecov-yaml#section-expired-reports
11+
max_report_age: off

tests/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
<ItemGroup Condition="'$(codecov)' == 'true' AND '$(IsTestProject)' == 'true'">
3737
<PackageReference Include="coverlet.collector" IsImplicitlyDefined="true" />
38-
<PackageReference Include="coverlet.msbuild" IsImplicitlyDefined="true" />
3938
</ItemGroup>
4039

4140
</Project>

tests/Directory.Build.targets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@
3939
<ItemGroup>
4040
<!--Test Dependencies-->
4141
<PackageReference Update="BenchmarkDotNet" Version="0.12.0" />
42-
<PackageReference Update="coverlet.collector" Version="1.1.0" PrivateAssets="All"/>
43-
<PackageReference Update="coverlet.msbuild" Version="2.8.0" PrivateAssets="All"/>
42+
<PackageReference Update="coverlet.collector" Version="1.2.0" PrivateAssets="All"/>
4443
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.14.4" />
45-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.4.0" />
44+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20200116-01" />
4645
<PackageReference Update="Moq" Version="4.10.0" />
4746
<PackageReference Update="System.Drawing.Common" Version="4.7.0" />
4847
<PackageReference Update="xunit" Version="2.4.1" />

tests/coverlet.runsettings

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<RunSettings>
3+
<DataCollectionRunSettings>
4+
<DataCollectors>
5+
<DataCollector friendlyName="XPlat code coverage">
6+
<Configuration>
7+
<Format>lcov</Format>
8+
<Include>[SixLabors.*]*</Include>
9+
<UseSourceLink>true</UseSourceLink>
10+
</Configuration>
11+
</DataCollector>
12+
</DataCollectors>
13+
</DataCollectionRunSettings>
14+
</RunSettings>

0 commit comments

Comments
 (0)