Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ skip_branch_with_pr: true
services:
- mongodb
install:
- choco install opencover.portable codecov
- choco install Memurai-Developer --version 2.0.0
- ps: .\build\dotnet-install.ps1 -Version 3.0.100
- choco install Memurai-Developer

build_script:
- ps: .\build.appveyor.ps1
Expand Down
33 changes: 33 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- 'bugfix'
- title: '🧰 Maintenance'
label:
- 'dependencies'
- 'maintenance'
change-template: '- $TITLE by @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
## 👨🏼‍💻 Contributors
$CONTRIBUTORS
114 changes: 114 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build

on:
push:
branches: [ master ]
pull_request:

env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true

BUILD_ARTIFACT_PATH: ${{github.workspace}}/build-artifacts

jobs:

version:
name: Identify build version
runs-on: ubuntu-latest
outputs:
BuildVersion: ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch all Git tags
run: git fetch --prune --unshallow --tags
- name: Configure build version
id: configureBuildVersion
run: |
$githubRunId = $env:GITHUB_RUN_ID;
$prNumber = $env:PR_NUMBER;
$gitSourceVersion = git describe --tags --abbrev=7 --always 2>$1;
$gitSourceVersionSplit = [regex]::split($gitSourceVersion, "-(?=\d+-\w+)");
$version = $(if($gitSourceVersionSplit.length -eq 1){"0.0.0"}else{$gitSourceVersionSplit[0]});
$commitsSinceTag = '0';
$commitHash = $gitSourceVersionSplit[0];
if ($gitSourceVersionSplit.length -eq 2) {
$gitMetadata = $gitSourceVersionSplit[1].split("-");
$commitsSinceTag = $gitMetadata[0];
$commitHash = $gitMetadata[1];
}
$buildMetadata = "$($commitHash)-$($githubRunId)";
$customSuffix = $(if($prNumber -ne ''){"-PR$($prNumber)"}elseif($commitsSinceTag -ne '0'){"-dev"});
echo "::set-output name=BUILD_VERSION::$($version)$($customSuffix)+$($buildMetadata)";
shell: pwsh
env:
PR_NUMBER: ${{github.event.number}}
- name: Print build version
run: echo ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}


build:
name: Build ${{matrix.os}}
runs-on: ${{matrix.os}}
needs: version
env:
BUILD_VERSION: ${{needs.version.outputs.BuildVersion}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Configure Windows
if: matrix.os == 'windows-latest'
run: choco install Memurai-Developer
- name: Configure Ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo systemctl start mongod && sudo apt-get install redis-server
- name: Configure MacOS
if: matrix.os == 'macOS-latest'
run: brew services start mongodb-community && brew install redis && brew services start redis

- name: Checkout
uses: actions/checkout@v2

- name: Install dependencies
run: dotnet --version && dotnet nuget list source && dotnet restore --verbosity normal
- name: Build
run: dotnet build -c Release --no-restore /p:Version=${{env.BUILD_VERSION}}
- name: Test with Coverage
run: dotnet test --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings
- name: Pack
run: dotnet pack -c Release --no-build /p:Version=${{env.BUILD_VERSION}} /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
- name: Publish artifacts
uses: actions/upload-artifact@v2
with:
name: ${{matrix.os}}
path: ${{env.BUILD_ARTIFACT_PATH}}

coverage:
name: Process code coverage
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download coverage reports
uses: actions/download-artifact@v2
- name: Install ReportGenerator tool
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Prepare coverage reports
run: reportgenerator -reports:*/coverage/*/coverage.cobertura.xml -targetdir:./ -reporttypes:Cobertura
- name: Upload coverage report
uses: codecov/codecov-action@v1.0.13
with:
file: Cobertura.xml
fail_ci_if_error: false
- name: Save combined coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: Cobertura.xml
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1 change: 1 addition & 0 deletions CacheTower.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{28E0B5
build.appveyor.ps1 = build.appveyor.ps1
build.ps1 = build.ps1
buildconfig.json = buildconfig.json
CodeCoverage.runsettings = CodeCoverage.runsettings
License.txt = License.txt
README.md = README.md
EndProjectSection
Expand Down
46 changes: 16 additions & 30 deletions CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>CacheTower.Tests.dll</ModulePath>
<ModulePath>CacheTower.Benchmarks.dll</ModulePath>
<ModulePath>CacheTower.AlternativesBenchmark.dll</ModulePath>
</Exclude>
</ModulePaths>

<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>

</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>cobertura</Format>
<Exclude>[CacheTower.Tests]*,[CacheTower.Benchmarks]*,[CacheTower.AlternativesBenchmark]*</Exclude>
<Include>[CacheTower]*,[CacheTower.*]*</Include>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<UseSourceLink>true</UseSourceLink>
<SkipAutoProps>true</SkipAutoProps>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
2 changes: 1 addition & 1 deletion build.appveyor.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if ($isTagBuild) {
.\build.ps1 -CreatePackages $True -BuildVersion $buildVersion
}
else {
.\build.ps1 -CheckCoverage $True -BuildVersion $buildVersion
.\build.ps1 -BuildVersion $buildVersion
}

Exit $LastExitCode
36 changes: 6 additions & 30 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[CmdletBinding(PositionalBinding=$false)]
param(
[bool] $RunTests = $true,
[bool] $CheckCoverage,
[bool] $CreatePackages,
[string] $BuildVersion
)
Expand All @@ -22,12 +21,10 @@ if (-not $BuildVersion) {

Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host " RunTests: $RunTests"
Write-Host " CheckCoverage: $CheckCoverage"
Write-Host " CreatePackages: $CreatePackages"
Write-Host " BuildVersion: $BuildVersion"
Write-Host "Configuration:" -ForegroundColor Cyan
Write-Host " TestProject: $($config.TestProject)"
Write-Host " TestCoverageFilter: $($config.TestCoverageFilter)"
Write-Host "Environment:" -ForegroundColor Cyan
Write-Host " .NET Version:" (dotnet --version)
Write-Host " Artifact Path: $packageOutputFolder"
Expand All @@ -41,34 +38,13 @@ if ($LastExitCode -ne 0) {
Write-Host "Solution built!" -ForegroundColor "Green"

if ($RunTests) {
if (-Not $CheckCoverage) {
Write-Host "Running tests without coverage..." -ForegroundColor "Magenta"
dotnet test $config.TestProject
if ($LastExitCode -ne 0) {
Write-Host "Tests failed, aborting build!" -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}
else {
Write-Host "Running tests with coverage..." -ForegroundColor "Magenta"
OpenCover.Console.exe -register:user -target:"%LocalAppData%\Microsoft\dotnet\dotnet.exe" -targetargs:"test $($config.TestProject) /p:DebugType=Full" -filter:"$($config.TestCoverageFilter)" -output:"$packageOutputFolder\coverage.xml" -oldstyle
if ($LastExitCode -ne 0 -Or -Not $?) {
Write-Host "Failure performing tests with coverage, aborting!" -Foreground "Red"
Exit 1
}
else {
Write-Host "Tests passed!" -ForegroundColor "Green"
Write-Host "Saving code coverage..." -ForegroundColor "Magenta"
codecov -f "$packageOutputFolder\coverage.xml"
if ($LastExitCode -ne 0 -Or -Not $?) {
Write-Host "Failure saving code coverage!" -Foreground "Red"
}
else {
Write-Host "Coverage saved!" -ForegroundColor "Green"
}
}
Write-Host "Running tests..." -ForegroundColor "Magenta"
dotnet test $config.TestProject
if ($LastExitCode -ne 0) {
Write-Host "Tests failed, aborting build!" -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}

if ($CreatePackages) {
Expand Down
Loading