Skip to content

Commit 5ed5864

Browse files
committed
Major updates to CI process
Still uses AppVeyor for releases but now also includes GitHub Actions for cross platform testing and code coverage.
1 parent c547cfc commit 5ed5864

12 files changed

+211
-39
lines changed

.appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
version: 'Build {build}'
22
image: Visual Studio 2019
33
skip_branch_with_pr: true
4-
5-
install:
6-
- choco install opencover.portable codecov
7-
84

95
build_script:
106
- ps: .\build.appveyor.ps1

.github/release-drafter.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name-template: '$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
categories:
4+
- title: '🚀 Features'
5+
labels:
6+
- 'feature'
7+
- 'enhancement'
8+
- title: '🐛 Bug Fixes'
9+
labels:
10+
- 'bug'
11+
- 'bugfix'
12+
- title: '🧰 Maintenance'
13+
label:
14+
- 'dependencies'
15+
- 'maintenance'
16+
change-template: '- $TITLE by @$AUTHOR (#$NUMBER)'
17+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
18+
version-resolver:
19+
major:
20+
labels:
21+
- 'major'
22+
minor:
23+
labels:
24+
- 'minor'
25+
patch:
26+
labels:
27+
- 'patch'
28+
default: patch
29+
template: |
30+
## Changes
31+
32+
$CHANGES
33+
34+
## 👨🏼‍💻 Contributors
35+
36+
$CONTRIBUTORS

.github/workflows/build.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
release:
8+
types: [ published ]
9+
10+
env:
11+
# Disable the .NET logo in the console output.
12+
DOTNET_NOLOGO: true
13+
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
14+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
15+
# Disable sending .NET CLI telemetry to Microsoft.
16+
DOTNET_CLI_TELEMETRY_OPTOUT: true
17+
18+
BUILD_ARTIFACT_PATH: ${{github.workspace}}/build-artifacts
19+
20+
jobs:
21+
22+
version:
23+
name: Identify build version
24+
runs-on: ubuntu-latest
25+
outputs:
26+
BuildVersion: ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
- name: Fetch all Git tags
31+
run: git fetch --prune --unshallow --tags
32+
- name: Configure build version
33+
id: configureBuildVersion
34+
run: |
35+
$githubRunId = $env:GITHUB_RUN_ID;
36+
$prNumber = $env:PR_NUMBER;
37+
$gitSourceVersion = git describe --tags --abbrev=7 --always 2>$1;
38+
$gitSourceVersionSplit = [regex]::split($gitSourceVersion, "-(?=\d+-\w+)");
39+
$version = $(if($gitSourceVersionSplit.length -eq 1){"0.0.0"}else{$gitSourceVersionSplit[0]});
40+
$commitsSinceTag = '0';
41+
$commitHash = $gitSourceVersionSplit[0];
42+
if ($gitSourceVersionSplit.length -eq 2) {
43+
$gitMetadata = $gitSourceVersionSplit[1].split("-");
44+
$commitsSinceTag = $gitMetadata[0];
45+
$commitHash = $gitMetadata[1];
46+
}
47+
$buildMetadata = "$($commitHash)-$($githubRunId)";
48+
$customSuffix = $(if($prNumber -ne ''){"-PR$($prNumber)"}elseif($commitsSinceTag -ne '0'){"-dev"});
49+
echo "::set-output name=BUILD_VERSION::$($version)$($customSuffix)+$($buildMetadata)";
50+
shell: pwsh
51+
env:
52+
PR_NUMBER: ${{github.event.number}}
53+
- name: Print build version
54+
run: echo ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
55+
56+
57+
build:
58+
name: Build ${{matrix.os}}
59+
runs-on: ${{matrix.os}}
60+
needs: version
61+
env:
62+
BUILD_VERSION: ${{needs.version.outputs.BuildVersion}}
63+
strategy:
64+
matrix:
65+
os: [ubuntu-latest, windows-latest, macOS-latest]
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
- name: Setup dotnet 2.1
70+
uses: actions/setup-dotnet@v1
71+
with:
72+
dotnet-version: '2.1.x'
73+
- name: Setup dotnet 3.1
74+
uses: actions/setup-dotnet@v1
75+
with:
76+
dotnet-version: '3.1.x'
77+
- name: Setup dotnet 5.0
78+
uses: actions/setup-dotnet@v1
79+
with:
80+
dotnet-version: '5.0.x'
81+
- name: Install dependencies
82+
run: dotnet restore
83+
- name: Build
84+
run: dotnet build -c Release --no-restore /p:Version=${{env.BUILD_VERSION}}
85+
- name: Test with Coverage
86+
run: dotnet test --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings
87+
- name: Pack
88+
run: dotnet pack -c Release --no-build /p:Version=${{env.BUILD_VERSION}} /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
89+
- name: Publish artifacts
90+
uses: actions/upload-artifact@v2
91+
with:
92+
name: ${{matrix.os}}
93+
path: ${{env.BUILD_ARTIFACT_PATH}}
94+
95+
coverage:
96+
name: Process code coverage
97+
runs-on: ubuntu-latest
98+
needs: build
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v2
102+
- name: Download coverage reports
103+
uses: actions/download-artifact@v2
104+
- name: Install ReportGenerator tool
105+
run: dotnet tool install -g dotnet-reportgenerator-globaltool
106+
- name: Prepare coverage reports
107+
run: reportgenerator -reports:*/coverage/*/coverage.cobertura.xml -targetdir:./ -reporttypes:Cobertura
108+
- name: Upload coverage report
109+
uses: codecov/[email protected]
110+
with:
111+
file: Cobertura.xml
112+
fail_ci_if_error: false
113+
- name: Save combined coverage report as artifact
114+
uses: actions/upload-artifact@v2
115+
with:
116+
name: coverage-report
117+
path: Cobertura.xml
118+
119+
release:
120+
name: Release
121+
runs-on: ubuntu-latest
122+
needs: build
123+
if: github.event_name == 'release'
124+
steps:
125+
- name: Download build
126+
uses: actions/download-artifact@v2
127+
- run: ls /ubuntu-latest
128+
# TODO: Upload to NuGet & GitHub Packages

.github/workflows/release-drafter.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
update_release_draft:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
env:
14+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

CodeCoverage.runsettings

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

InfinityCrawler.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{F0B4D0
1212
build.appveyor.ps1 = build.appveyor.ps1
1313
build.ps1 = build.ps1
1414
buildconfig.json = buildconfig.json
15+
CodeCoverage.runsettings = CodeCoverage.runsettings
1516
License.txt = License.txt
1617
README.md = README.md
1718
EndProjectSection

build.appveyor.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if ($isTagBuild) {
2929
.\build.ps1 -CreatePackages $True -BuildVersion $buildVersion
3030
}
3131
else {
32-
.\build.ps1 -CheckCoverage $True -BuildVersion $buildVersion
32+
.\build.ps1 -BuildVersion $buildVersion
3333
}
3434

3535
Exit $LastExitCode

build.ps1

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[CmdletBinding(PositionalBinding=$false)]
22
param(
33
[bool] $RunTests = $true,
4-
[bool] $CheckCoverage,
54
[bool] $CreatePackages,
65
[string] $BuildVersion
76
)
@@ -22,12 +21,10 @@ if (-not $BuildVersion) {
2221

2322
Write-Host "Run Parameters:" -ForegroundColor Cyan
2423
Write-Host " RunTests: $RunTests"
25-
Write-Host " CheckCoverage: $CheckCoverage"
2624
Write-Host " CreatePackages: $CreatePackages"
2725
Write-Host " BuildVersion: $BuildVersion"
2826
Write-Host "Configuration:" -ForegroundColor Cyan
2927
Write-Host " TestProject: $($config.TestProject)"
30-
Write-Host " TestCoverageFilter: $($config.TestCoverageFilter)"
3128
Write-Host "Environment:" -ForegroundColor Cyan
3229
Write-Host " .NET Version:" (dotnet --version)
3330
Write-Host " Artifact Path: $packageOutputFolder"
@@ -41,34 +38,13 @@ if ($LastExitCode -ne 0) {
4138
Write-Host "Solution built!" -ForegroundColor "Green"
4239

4340
if ($RunTests) {
44-
if (-Not $CheckCoverage) {
45-
Write-Host "Running tests without coverage..." -ForegroundColor "Magenta"
46-
dotnet test $config.TestProject
47-
if ($LastExitCode -ne 0) {
48-
Write-Host "Tests failed, aborting build!" -Foreground "Red"
49-
Exit 1
50-
}
51-
Write-Host "Tests passed!" -ForegroundColor "Green"
52-
}
53-
else {
54-
Write-Host "Running tests with coverage..." -ForegroundColor "Magenta"
55-
OpenCover.Console.exe -register:user -target:"dotnet" -targetargs:"test $($config.TestProject) /p:DebugType=Full" -filter:"$($config.TestCoverageFilter)" -output:"$packageOutputFolder\coverage.xml" -oldstyle
56-
if ($LastExitCode -ne 0 -Or -Not $?) {
57-
Write-Host "Failure performing tests with coverage, aborting!" -Foreground "Red"
58-
Exit 1
59-
}
60-
else {
61-
Write-Host "Tests passed!" -ForegroundColor "Green"
62-
Write-Host "Saving code coverage..." -ForegroundColor "Magenta"
63-
codecov -f "$packageOutputFolder\coverage.xml"
64-
if ($LastExitCode -ne 0 -Or -Not $?) {
65-
Write-Host "Failure saving code coverage!" -Foreground "Red"
66-
}
67-
else {
68-
Write-Host "Coverage saved!" -ForegroundColor "Green"
69-
}
70-
}
41+
Write-Host "Running tests..." -ForegroundColor "Magenta"
42+
dotnet test $config.TestProject
43+
if ($LastExitCode -ne 0) {
44+
Write-Host "Tests failed, aborting build!" -Foreground "Red"
45+
Exit 1
7146
}
47+
Write-Host "Tests passed!" -ForegroundColor "Green"
7248
}
7349

7450
if ($CreatePackages) {

buildconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"TestProject": "tests/InfinityCrawler.Tests/InfinityCrawler.Tests.csproj",
3-
"TestCoverageFilter": "+[InfinityCrawler]* -[InfinityCrawler.Tests]*"
2+
"TestProject": "tests/InfinityCrawler.Tests/InfinityCrawler.Tests.csproj"
43
}

tests/InfinityCrawler.Tests.Benchmarks/BasicSiteCrawlBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace InfinityCrawler.Tests.Benchmarks
1212
{
13-
[SimpleJob(RuntimeMoniker.NetCoreApp21), SimpleJob(RuntimeMoniker.Net461, baseline: true)]
13+
[SimpleJob(RuntimeMoniker.NetCoreApp50)]
1414
[MemoryDiagnoser]
1515
public class BasicSiteCrawlBenchmark
1616
{

tests/InfinityCrawler.Tests.Benchmarks/InfinityCrawler.Tests.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
5+
<TargetFrameworks>net5.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

tests/InfinityCrawler.Tests/InfinityCrawler.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1414
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
1515
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
16+
<PackageReference Include="coverlet.collector" Version="1.3.0">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
1621
</ItemGroup>
1722

1823
<ItemGroup>

0 commit comments

Comments
 (0)