Skip to content

Commit

Permalink
test: report coverage (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
FantasticFiasco authored Apr 5, 2021
1 parent e5b38d7 commit 794180e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 61 deletions.
23 changes: 5 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
.idea

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
bin/
obj/

# Test coverage
coverage.*.xml

# Visual Studio 2015 cache/options directory
.vs/
Expand All @@ -27,12 +23,3 @@ _ReSharper*/
# NuGet Packages
*.nupkg
*.snupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Serilog.Sinks.Http - A Serilog sink sending log events over HTTP

[![Build status](https://ci.appveyor.com/api/projects/status/ayvak8yo23k962sg/branch/master?svg=true)](https://ci.appveyor.com/project/FantasticFiasco/serilog-sinks-http)
[![codecov](https://codecov.io/gh/FantasticFiasco/mvvm-dialogs/branch/master/graph/badge.svg?token=kvhQQsqxZv)](https://codecov.io/gh/FantasticFiasco/mvvm-dialogs)
[![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.Http.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.Http/)
[![SemVer compatible](https://img.shields.io/badge/%E2%9C%85-SemVer%20compatible-blue)](https://semver.org/)
[![NuGet](https://img.shields.io/nuget/dt/Serilog.Sinks.Http.svg)](https://www.nuget.org/packages/Serilog.Sinks.Http/)
Expand Down
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
image: Visual Studio 2019

environment:
CODECOV_TOKEN:
secure: uzWFsXMOpyPLNJGvLp7wteEt8wnCNH/1MNq17Ky5WCEqQ2Bhfq8OIZZBqVmH6CDQ

version: '{build}'

configuration: Release
Expand Down
97 changes: 54 additions & 43 deletions build/build.ps1
Original file line number Diff line number Diff line change
@@ -1,73 +1,84 @@
$logo = (Invoke-WebRequest "https://raw.githubusercontent.com/FantasticFiasco/logo/master/logo.raw").toString();
Write-Host "$logo" -ForegroundColor Green

Write-Host "build: build started"
Write-Host "build: dotnet cli v$(dotnet --version)"

Push-Location $PSScriptRoot\..

# Clean artifacts
if (Test-Path .\artifacts)
{
Write-Host "build: cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}
Write-Host "[info] dotnet cli v$(dotnet --version)"

$tagged_build = if ($env:APPVEYOR_REPO_TAG -eq "true") { $true } else { $false }
Write-Host "build: triggered by git tag: $tagged_build"
Write-Host "[info] triggered by git tag: $tagged_build"

$git_sha = $env:APPVEYOR_REPO_COMMIT.Substring(0, 7)
Write-Host "build: git sha: $git_sha"
Write-Host "[info] git sha: $git_sha"

$is_pull_request = if ("$env:APPVEYOR_PULL_REQUEST_NUMBER" -eq "") { $false } else { $true }
Write-Host "[info] is pull request: $is_pull_request"

[xml]$build_props = Get-Content -Path .\Directory.Build.props
$version_prefix = $build_props.Project.PropertyGroup.VersionPrefix
Write-Host "build: build props version prefix: $version_prefix"
Write-Host "[info] build props version prefix: $version_prefix"
$version_suffix = $build_props.Project.PropertyGroup.VersionSuffix
Write-Host "build: build props version suffix: $version_suffix"
Write-Host "[info] build props version suffix: $version_suffix"

# Build and pack
foreach ($source in Get-ChildItem .\src\*)
# Clean artifacts
if (Test-Path .\artifacts)
{
Push-Location $source
Write-Host "[build] cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

Write-Host "build: packaging project in $source"
# Build and pack
if ($tagged_build)
{
Write-Host "[build] build"
& dotnet build -c Release

if ($tagged_build)
Write-Host "[build] pack"
& dotnet pack -c Release -o ..\..\artifacts --no-build
}
else
{
# Use git tag if version suffix isn't specified
if ($version_suffix -eq "")
{
& dotnet build -c Release
& dotnet pack -c Release -o ..\..\artifacts --no-build
$version_suffix = $git_sha
}
else
{
# Use git tag if version suffix isn't specified
if ($version_suffix -eq "")
{
$version_suffix = $git_sha
}

& dotnet build -c Release --version-suffix=$version_suffix
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$version_suffix --no-build
}
Write-Host "[build] build"
& dotnet build -c Release --version-suffix=$version_suffix

if ($LASTEXITCODE -ne 0)
{
exit 1
}
Write-Host "[build] pack"
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$version_suffix --no-build
}

Pop-Location
if ($LASTEXITCODE -ne 0)
{
exit 1
}

# Test
foreach ($test in Get-ChildItem test/*Tests)
Write-Host "[test] test"
& dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
if ($LASTEXITCODE -ne 0)
{
Push-Location $test
exit 1
}

Write-Host "build: testing project in $test"
If ($is_pull_request -eq $false)
{
foreach ($testResult in Get-ChildItem .\test\Serilog.Sinks.HttpTests\TestResults\*)
{
Push-Location $testResult

& dotnet test -c Release
if ($LASTEXITCODE -ne 0) { exit 2 }
Write-Host "[test] upload coverage report from $testResult"
Invoke-WebRequest -Uri "https://codecov.io/bash" -OutFile codecov.sh
bash codecov.sh -f "coverage.cobertura.xml"

Pop-Location
}
if ($LASTEXITCODE -ne 0)
{
exit 1
}

Pop-Location
Pop-Location
}
}
4 changes: 4 additions & 0 deletions test/Serilog.Sinks.HttpTests/Serilog.Sinks.HttpTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
Expand Down

0 comments on commit 794180e

Please sign in to comment.