From 31871cb4371f1b7fa8bea2ed974d459770df5c13 Mon Sep 17 00:00:00 2001 From: Jonathan Dickinson Date: Thu, 5 Oct 2017 19:00:17 -0700 Subject: [PATCH] Code Coverage - Copying code coverage stuff from Chasm --- Directory.Build.props | 26 ++++-- GenerateTestSolution.ps1 | 79 ++++++++++++++++ README.md | 1 + SourceCode.Clay.sln | 4 + appveyor.yml | 90 +++++++++---------- .../SourceCode.Clay.Buffers.Tests.csproj | 1 + .../SourceCode.Clay.Buffers.csproj | 3 +- .../SourceCode.Clay.Collections.Bench.csproj | 1 + .../SourceCode.Clay.Collections.Tests.csproj | 1 + .../SourceCode.Clay.Collections.csproj | 3 +- .../SourceCode.Clay.Data.Tests.csproj | 1 + .../SourceCode.Clay.Data.csproj | 3 +- .../SourceCode.Clay.Json.Tests.csproj | 1 + .../SourceCode.Clay.Json.csproj | 3 +- .../SourceCode.Clay.OpenApi.Tests.csproj | 1 + .../SourceCode.Clay.OpenApi.csproj | 10 ++- .../SourceCode.Clay.Tests.csproj | 1 + .../SourceCode.Clay.Text.Tests.csproj | 1 + .../SourceCode.Clay.Text.csproj | 2 + .../SourceCode.Clay.Threading.Tests.csproj | 1 + .../SourceCode.Clay.Threading.csproj | 2 + src/SourceCode.Clay/SourceCode.Clay.csproj | 5 +- 22 files changed, 174 insertions(+), 66 deletions(-) create mode 100644 GenerateTestSolution.ps1 diff --git a/Directory.Build.props b/Directory.Build.props index e13fc0a..abf1344 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,11 +1,10 @@ - - false - + + false + - - 1.0.0 + SourceCode Technology Holdings Inc. SourceCode.Clay Copyright © 2017 SourceCode Technology Holdings Inc. @@ -16,10 +15,21 @@ 1701;1702;1705;S3242 + + - https://github.com/k2workflow/Clay/ - https://github.com/k2workflow/Clay/blob/master/LICENSE - false + full + pdbonly + + + + false + true + + https://github.com/k2workflow/Clay/ + https://raw.githubusercontent.com/k2workflow/Clay/master/LICENSE + true + \ No newline at end of file diff --git a/GenerateTestSolution.ps1 b/GenerateTestSolution.ps1 new file mode 100644 index 0000000..a622571 --- /dev/null +++ b/GenerateTestSolution.ps1 @@ -0,0 +1,79 @@ +# Copyright (c) SourceCode Technology Holdings Inc. All rights reserved. +# Licensed under the MIT License. See LICENSE file in the project root for full license information. + +Param( + [Parameter(Mandatory=$True,Position=1)] + [string]$InputSolution, + [Parameter(Mandatory=$False,Position=2)] + [string]$OutputSolution, + [Parameter(Mandatory=$False,Position=3)] + [string]$TestPattern +) + +Write-Host "Test Solution Generator version 0.0.1" +Write-Host "Copyright (C) SourceCode Technology Holdings Inc. All rights reserved." + +if (-not $OutputSolution) { $OutputSolution = [IO.Path]::ChangeExtension($InputSolution, ".Tests.sln") } + +if (Test-Path $OutputSolution) { Remove-Item $OutputSolution } + +if (-not $TestPattern) { $TestPattern = '.+?\.Tests' } + +$TestPattern = "^\s*Project\("".+?""\)\s*=\s*""$TestPattern"",.+$" + +Write-Host "InputSolution: $InputSolution" +Write-Host "OutputSolution: $OutputSolution" +Write-Host "TestPattern: $TestPattern" + +$State = 0 + +foreach ($SlnLine in Get-Content $InputSolution) { + + if ($SlnLine -match '^\s*GlobalSection\(NestedProjects\)') { + + $State = 4 + + } elseif ($State -eq 4 -and $SlnLine -match '^\s*EndGlobalSection') { + + $State = 3 + continue; + + } elseif ($SlnLine -match '^\s*Global$') { + + $State = 3 + + } + + if ($State -eq 3) { + # Copy build configuration + + Add-Content $OutputSolution $SlnLine + + } elseif ($SlnLine -match $TestPattern) { + # Copy test projects + + $State = 2 + Add-Content $OutputSolution $SlnLine + Write-Host "Matched project: $SlnLine" + + } elseif ($SlnLine -match '^\s*Project\(') { + #Ignore any preceding non-test projects + + $State = 1 + + } elseif ($State -eq 2) { + # Copy project metadata + + Add-Content $OutputSolution $SlnLine + if ($SlnLine -match '^\s*EndProject$') { $State = 1 } + + } elseif ($State -eq 0) { + # Copy header + + Add-Content $OutputSolution $SlnLine + + } + +} + +Write-Host "Created $OutputSolution." diff --git a/README.md b/README.md index 51f8cb1..f5fd62d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ## Clay [![Build status](https://ci.appveyor.com/api/projects/status/yg5vnimungm86hf1/branch/master?svg=true)](https://ci.appveyor.com/project/jcdickinson/clay/branch/master) +[![Code Coverage](https://codecov.io/gh/k2workflow/Clay/coverage.svg)](https://codecov.io/gh/k2workflow/Clay) Tools and extensions to the .Net framework. diff --git a/SourceCode.Clay.sln b/SourceCode.Clay.sln index db18aa4..91acd4f 100644 --- a/SourceCode.Clay.sln +++ b/SourceCode.Clay.sln @@ -41,7 +41,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceCode.Clay.Threading.T EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "files", "files", "{B2F708DF-EF63-4F62-A95D-9A148D01421E}" ProjectSection(SolutionItems) = preProject + appveyor.yml = appveyor.yml + CodeMaid.config = CodeMaid.config + Directory.Build.props = Directory.Build.props LICENSE = LICENSE + README.md = README.md EndProjectSection EndProject Global diff --git a/appveyor.yml b/appveyor.yml index 177ba54..4d06343 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,63 +1,57 @@ -version: '1.0.{build}' +version: 'build-{build}' + +image: Visual Studio 2017 + configuration: - Release + platform: Any CPU + environment: DOTNET_CLI_TELEMETRY_OPTOUT: 1 + init: -- ps: $Env:LABEL = "preview1-" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") +- cmd: git config --global core.autocrlf true +- ps: $Env:NUGET_VERSION = "1.0.0-preview1-" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") - ps: if(-not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $env:is_not_pr = "true"; } -before_build: -- appveyor-retry dotnet restore -v Minimal - -build_script: -- dotnet build "src\SourceCode.Clay\SourceCode.Clay.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Tests\SourceCode.Clay.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Buffers\SourceCode.Clay.Buffers.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Buffers.Tests\SourceCode.Clay.Buffers.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Collections\SourceCode.Clay.Collections.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Collections.Tests\SourceCode.Clay.Collections.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Data\SourceCode.Clay.Data.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Data.Tests\SourceCode.Clay.Data.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Json\SourceCode.Clay.Json.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Json.Tests\SourceCode.Clay.Json.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Text\SourceCode.Clay.Text.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Text.Tests\SourceCode.Clay.Text.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.Threading\SourceCode.Clay.Threading.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.Threading.Tests\SourceCode.Clay.Threading.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -- dotnet build "src\SourceCode.Clay.OpenApi\SourceCode.Clay.OpenApi.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% -- dotnet build "src\SourceCode.Clay.OpenApi.Tests\SourceCode.Clay.OpenApi.Tests.csproj" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% - -after_build: - - dotnet pack "src\SourceCode.Clay\SourceCode.Clay.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Buffers\SourceCode.Clay.Buffers.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Collections\SourceCode.Clay.Collections.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Data\SourceCode.Clay.Data.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Json\SourceCode.Clay.Json.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Text\SourceCode.Clay.Text.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.Threading\SourceCode.Clay.Threading.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - - dotnet pack "src\SourceCode.Clay.OpenApi\SourceCode.Clay.OpenApi.csproj" -c %CONFIGURATION% --no-build --version-suffix %LABEL% - +install: +- pip install codecov + +dotnet_csproj: + patch: true + file: '**\*.csproj' + version: $(nuget_version) + package_version: $(nuget_version) + +build: + project: SourceCode.Clay.sln + verbosity: minimal + test_script: -- dotnet test "src\SourceCode.Clay.Tests\SourceCode.Clay.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Buffers.Tests\SourceCode.Clay.Buffers.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Collections.Tests\SourceCode.Clay.Collections.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Data.Tests\SourceCode.Clay.Data.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Json.Tests\SourceCode.Clay.Json.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Text.Tests\SourceCode.Clay.Text.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.Threading.Tests\SourceCode.Clay.Threading.Tests.csproj" -c %CONFIGURATION% --no-build -- dotnet test "src\SourceCode.Clay.OpenApi.Tests\SourceCode.Clay.OpenApi.Tests.csproj" -c %CONFIGURATION% --no-build +- ps: .\GenerateTestSolution.ps1 .\SourceCode.Clay.sln +- >- + OpenCover.Console.exe + -target:"dotnet.exe" + -targetargs:"test SourceCode.Clay.Tests.sln -c %CONFIGURATION% --no-build" + -filter:"+[*]* -[*.Tests]*" + -output:"%APPVEYOR_BUILD_FOLDER%\coverage.xml" + -excludebyattribute:*.ExcludeFromCodeCoverage* + -oldStyle + -register:user + -mergebyhash + -hideskipped:File + +after_test: +- >- + codecov + -X gcov + -f "%APPVEYOR_BUILD_FOLDER%\coverage.xml" artifacts: - path: '**\*.nupkg' + - path: 'coverage.xml' + deploy: provider: NuGet api_key: diff --git a/src/SourceCode.Clay.Buffers.Tests/SourceCode.Clay.Buffers.Tests.csproj b/src/SourceCode.Clay.Buffers.Tests/SourceCode.Clay.Buffers.Tests.csproj index 81f5994..f583fae 100644 --- a/src/SourceCode.Clay.Buffers.Tests/SourceCode.Clay.Buffers.Tests.csproj +++ b/src/SourceCode.Clay.Buffers.Tests/SourceCode.Clay.Buffers.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Buffers/SourceCode.Clay.Buffers.csproj b/src/SourceCode.Clay.Buffers/SourceCode.Clay.Buffers.csproj index 32f8b03..e0edf5b 100644 --- a/src/SourceCode.Clay.Buffers/SourceCode.Clay.Buffers.csproj +++ b/src/SourceCode.Clay.Buffers/SourceCode.Clay.Buffers.csproj @@ -18,8 +18,9 @@ SourceCode.Clay.Buffers SourceCode - false Tools and extensions for working with buffers. clay utility extension buffer byte array + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.Collections.Bench/SourceCode.Clay.Collections.Bench.csproj b/src/SourceCode.Clay.Collections.Bench/SourceCode.Clay.Collections.Bench.csproj index 04fcd94..145ba6f 100644 --- a/src/SourceCode.Clay.Collections.Bench/SourceCode.Clay.Collections.Bench.csproj +++ b/src/SourceCode.Clay.Collections.Bench/SourceCode.Clay.Collections.Bench.csproj @@ -17,6 +17,7 @@ + diff --git a/src/SourceCode.Clay.Collections.Tests/SourceCode.Clay.Collections.Tests.csproj b/src/SourceCode.Clay.Collections.Tests/SourceCode.Clay.Collections.Tests.csproj index 0760cec..666332c 100644 --- a/src/SourceCode.Clay.Collections.Tests/SourceCode.Clay.Collections.Tests.csproj +++ b/src/SourceCode.Clay.Collections.Tests/SourceCode.Clay.Collections.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Collections/SourceCode.Clay.Collections.csproj b/src/SourceCode.Clay.Collections/SourceCode.Clay.Collections.csproj index 0008769..f1d50aa 100644 --- a/src/SourceCode.Clay.Collections/SourceCode.Clay.Collections.csproj +++ b/src/SourceCode.Clay.Collections/SourceCode.Clay.Collections.csproj @@ -18,8 +18,9 @@ SourceCode.Clay.Collections SourceCode - false Tools and extensions for working with collections. clay utility extension dictionary switch list set + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.Data.Tests/SourceCode.Clay.Data.Tests.csproj b/src/SourceCode.Clay.Data.Tests/SourceCode.Clay.Data.Tests.csproj index 5c0eb3a..50a08de 100644 --- a/src/SourceCode.Clay.Data.Tests/SourceCode.Clay.Data.Tests.csproj +++ b/src/SourceCode.Clay.Data.Tests/SourceCode.Clay.Data.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Data/SourceCode.Clay.Data.csproj b/src/SourceCode.Clay.Data/SourceCode.Clay.Data.csproj index 3e90412..c4ff46e 100644 --- a/src/SourceCode.Clay.Data/SourceCode.Clay.Data.csproj +++ b/src/SourceCode.Clay.Data/SourceCode.Clay.Data.csproj @@ -22,8 +22,9 @@ SourceCode.Clay.Data SourceCode - false Tools and extensions for working with data. clay utility extension sql connection tsql parser + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.Json.Tests/SourceCode.Clay.Json.Tests.csproj b/src/SourceCode.Clay.Json.Tests/SourceCode.Clay.Json.Tests.csproj index 6e56f39..414245b 100644 --- a/src/SourceCode.Clay.Json.Tests/SourceCode.Clay.Json.Tests.csproj +++ b/src/SourceCode.Clay.Json.Tests/SourceCode.Clay.Json.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Json/SourceCode.Clay.Json.csproj b/src/SourceCode.Clay.Json/SourceCode.Clay.Json.csproj index 48c67ac..be54435 100644 --- a/src/SourceCode.Clay.Json/SourceCode.Clay.Json.csproj +++ b/src/SourceCode.Clay.Json/SourceCode.Clay.Json.csproj @@ -22,8 +22,9 @@ SourceCode.Clay.Json SourceCode - false Tools and extensions for working with json. clay utility extension json validate + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.OpenApi.Tests/SourceCode.Clay.OpenApi.Tests.csproj b/src/SourceCode.Clay.OpenApi.Tests/SourceCode.Clay.OpenApi.Tests.csproj index cabb501..af1c9ed 100644 --- a/src/SourceCode.Clay.OpenApi.Tests/SourceCode.Clay.OpenApi.Tests.csproj +++ b/src/SourceCode.Clay.OpenApi.Tests/SourceCode.Clay.OpenApi.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/SourceCode.Clay.OpenApi/SourceCode.Clay.OpenApi.csproj b/src/SourceCode.Clay.OpenApi/SourceCode.Clay.OpenApi.csproj index 46329fc..50278f5 100644 --- a/src/SourceCode.Clay.OpenApi/SourceCode.Clay.OpenApi.csproj +++ b/src/SourceCode.Clay.OpenApi/SourceCode.Clay.OpenApi.csproj @@ -7,6 +7,10 @@ false + + 1701;1702;1705;S3242;S4035 + + @@ -26,9 +30,7 @@ false DTOs for Open API 3.0.0. clay json open-api swagger - - - - 1701;1702;1705;S3242;S4035 + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.Tests/SourceCode.Clay.Tests.csproj b/src/SourceCode.Clay.Tests/SourceCode.Clay.Tests.csproj index f64f2cf..1232d06 100644 --- a/src/SourceCode.Clay.Tests/SourceCode.Clay.Tests.csproj +++ b/src/SourceCode.Clay.Tests/SourceCode.Clay.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Text.Tests/SourceCode.Clay.Text.Tests.csproj b/src/SourceCode.Clay.Text.Tests/SourceCode.Clay.Text.Tests.csproj index c11591f..c74e491 100644 --- a/src/SourceCode.Clay.Text.Tests/SourceCode.Clay.Text.Tests.csproj +++ b/src/SourceCode.Clay.Text.Tests/SourceCode.Clay.Text.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Text/SourceCode.Clay.Text.csproj b/src/SourceCode.Clay.Text/SourceCode.Clay.Text.csproj index 6550b6f..12a04c9 100644 --- a/src/SourceCode.Clay.Text/SourceCode.Clay.Text.csproj +++ b/src/SourceCode.Clay.Text/SourceCode.Clay.Text.csproj @@ -20,5 +20,7 @@ false Tools and extensions for working with text. clay utility extension string stringbuilder + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay.Threading.Tests/SourceCode.Clay.Threading.Tests.csproj b/src/SourceCode.Clay.Threading.Tests/SourceCode.Clay.Threading.Tests.csproj index 6c8be90..1d92590 100644 --- a/src/SourceCode.Clay.Threading.Tests/SourceCode.Clay.Threading.Tests.csproj +++ b/src/SourceCode.Clay.Threading.Tests/SourceCode.Clay.Threading.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/SourceCode.Clay.Threading/SourceCode.Clay.Threading.csproj b/src/SourceCode.Clay.Threading/SourceCode.Clay.Threading.csproj index d126e24..b6a4766 100644 --- a/src/SourceCode.Clay.Threading/SourceCode.Clay.Threading.csproj +++ b/src/SourceCode.Clay.Threading/SourceCode.Clay.Threading.csproj @@ -24,5 +24,7 @@ false Tools and extensions for working with threads. clay utility extension thread task parallel + 1.0.0-local + 1.0.0-local diff --git a/src/SourceCode.Clay/SourceCode.Clay.csproj b/src/SourceCode.Clay/SourceCode.Clay.csproj index e378670..50fd672 100644 --- a/src/SourceCode.Clay/SourceCode.Clay.csproj +++ b/src/SourceCode.Clay/SourceCode.Clay.csproj @@ -1,4 +1,4 @@ - + @@ -17,8 +17,9 @@ SourceCode.Clay SourceCode - false Tools and extensions to the .Net framework. clay utility extension string datetime number + 1.0.0-local + 1.0.0-local