From d4bf1639c77bfb96250ad75b9502e040d4f3a0fb Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 12 Nov 2017 12:40:13 +0100 Subject: [PATCH] ci changes --- README.md | 1 + appveyor.yml | 34 +++++++++++++++++++ build.ps1 | 32 +++++++++++++++++ src/Ben.Demystifier/Ben.Demystifier.csproj | 4 ++- .../Enumerable/EnumerableIList.cs | 2 +- .../DynamicCompilation.cs | 13 ++++--- 6 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 appveyor.yml create mode 100644 build.ps1 diff --git a/README.md b/README.md index 9c36e3a..945dd4e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Ben.Demystifier [![NuGet version (Ben.Demystifier)](https://img.shields.io/nuget/v/Ben.Demystifier.svg?style=flat-square)](https://www.nuget.org/packages/Ben.Demystifier/) +[![Build status](https://ci.appveyor.com/api/projects/status/rlhygchfph287fq0?svg=true)](https://ci.appveyor.com/project/benaadams/ben-demystifier) ## High performance understanding for stack traces diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..75a183e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,34 @@ +image: Visual Studio 2017 + +shallow_clone: true + +branches: + only: + - master + +skip_branch_with_pr: true + +skip_tags: true + +skip_commits: + files: + - BUILDING.md + - CONTRIBUTING.md + - ISSUE_TEMPLATE.md + - LICENCE + - README.md + +nuget: + disable_publish_on_pr: true + +build_script: +- ps: .\build.ps1 -target appveyor -buildAssemblyVersion ($env:BuildVersion + $env:APPVEYOR_BUILD_NUMBER) -buildSemanticVersion ($env:BuildSemanticVersion + $env:APPVEYOR_BUILD_NUMBER) + +test: off + +deploy: off + +artifacts: +- path: artifacts/build +- path: artifacts/packages +- path: artifacts/test \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..d0bacc3 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,32 @@ +<# +.SYNOPSIS + This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode + to see if an error occcured. If an error is detected then an exception is thrown. + This function allows you to run command-line programs without having to + explicitly check the $lastexitcode variable. +.EXAMPLE + exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed" +#> +function Exec +{ + [CmdletBinding()] + param( + [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, + [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd) + ) + & $cmd + if ($lastexitcode -ne 0) { + throw ("Exec: " + $errorMessage) + } +} + +if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } + +exec { & dotnet restore } + +$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; +$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10) + +exec { & dotnet test .\test\Ben.Demystifier.Test -c Release } + +exec { & dotnet pack .\src\Ben.Demystifier -c Release -o .\artifacts --version-suffix=$revision } \ No newline at end of file diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index fdce526..e1da478 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -6,6 +6,8 @@ High performance understanding for stack traces (Make error logs more productive) ben_a_adams https://github.com/benaadams/Ben.Demystifier + https://github.com/benaadams/Ben.Demystifier + https://github.com/benaadams/Ben.Demystifier/blob/master/LICENSE git true true @@ -14,7 +16,7 @@ netstandard2.0;net46 - 7.2 + 7.1 diff --git a/src/Ben.Demystifier/Enumerable/EnumerableIList.cs b/src/Ben.Demystifier/Enumerable/EnumerableIList.cs index 6dc5bf7..58ced0b 100644 --- a/src/Ben.Demystifier/Enumerable/EnumerableIList.cs +++ b/src/Ben.Demystifier/Enumerable/EnumerableIList.cs @@ -8,7 +8,7 @@ namespace System.Collections.Generic.Enumerable public static EnumerableIList Create(IList list) => new EnumerableIList(list); } - public readonly struct EnumerableIList : IEnumerableIList, IList + public struct EnumerableIList : IEnumerableIList, IList { private readonly IList _list; diff --git a/test/Ben.Demystifier.Test/DynamicCompilation.cs b/test/Ben.Demystifier.Test/DynamicCompilation.cs index 81fa9a7..a6767f1 100644 --- a/test/Ben.Demystifier.Test/DynamicCompilation.cs +++ b/test/Ben.Demystifier.Test/DynamicCompilation.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Linq; using System.Linq.Expressions; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -37,15 +38,19 @@ namespace Demystify // Assert var stackTrace = demystifiedException.ToString(); stackTrace = ReplaceLineEndings.Replace(stackTrace, ""); - var trace = stackTrace.Split(Environment.NewLine); + var trace = stackTrace.Split(Environment.NewLine) + // Remove items that vary between test runners + .Where(s => + s != " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)" && + s != " at Task Demystify.DynamicCompilation.DoesNotPreventStackTrace()+()=>{}" + ) + .ToArray(); Assert.Equal( new[] { "System.ArgumentException: Message", " at void lambda_method(Closure)", - " at Task Demystify.DynamicCompilation.DoesNotPreventThrowStackTrace()+()=>{}", - " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)", - " at async Task Demystify.DynamicCompilation.DoesNotPreventThrowStackTrace()"}, + " at async Task Demystify.DynamicCompilation.DoesNotPreventStackTrace()"}, trace); }