From 8efa8db7c1817e0e5b44e14d6d446028d0c313cb Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 14:26:19 +0000 Subject: [PATCH 1/8] Upload code coverage to codecov.io - Upload code coverage reports to codecov.io, generated with ReportGenerator in Cobertura format. - Update NuGet packages to their latest versions. - Remove `net461` as a test target. --- .github/workflows/build.yml | 6 +++++ .gitignore | 1 + src/Polly.Benchmarks/Polly.Benchmarks.csproj | 4 ++-- src/Polly.Specs/Polly.Specs.csproj | 25 +++++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1ce16af79a..f611fd21a27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,12 @@ jobs: NUGET_XMLDOC_MODE: skip TERM: xterm + - uses: codecov/codecov-action@v3 + name: Upload coverage to Codecov + with: + file: ./src/Polly.Specs/coverage-reports/Cobertura.xml + flags: ${{ matrix.os_name }} + - name: Publish NuGet packages uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index 444b9d4f606..2b50fe15803 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,4 @@ tools *.nuget.targets *.nuget.props coverage.*.json +coverage-reports/ diff --git a/src/Polly.Benchmarks/Polly.Benchmarks.csproj b/src/Polly.Benchmarks/Polly.Benchmarks.csproj index 6802e285a23..9af841249ab 100644 --- a/src/Polly.Benchmarks/Polly.Benchmarks.csproj +++ b/src/Polly.Benchmarks/Polly.Benchmarks.csproj @@ -6,8 +6,8 @@ net6.0 - - + + diff --git a/src/Polly.Specs/Polly.Specs.csproj b/src/Polly.Specs/Polly.Specs.csproj index 836efb51402..10b817f959b 100644 --- a/src/Polly.Specs/Polly.Specs.csproj +++ b/src/Polly.Specs/Polly.Specs.csproj @@ -2,7 +2,7 @@ netcoreapp3.1;net6.0 - $(TargetFrameworks);net461;net472 + $(TargetFrameworks);net472 true @@ -11,23 +11,30 @@ - - - - - - + + + + + + + - + - + true [xunit.*]* System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute 75,60,70 + + + + From 50ef916f895a6d174bbe126d28b2f7864e4fe93c Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 14:37:48 +0000 Subject: [PATCH 2/8] Add coverage badge Add a code coverage badge to the README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de2d848a734..9a2f873859d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ We are a member of the [.NET Foundation](https://www.dotnetfoundation.org/about) **Keep up to date with new feature announcements, tips & tricks, and other news through [www.thepollyproject.org](http://www.thepollyproject.org)** -[![NuGet version](https://badge.fury.io/nu/polly.svg)](https://badge.fury.io/nu/polly) [![Build status](https://github.com/App-vNext/Polly/workflows/build/badge.svg?branch=main&event=push)](https://github.com/App-vNext/Polly/actions?query=workflow%3Abuild+branch%3Amain+event%3Apush) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org) +[![NuGet version](https://badge.fury.io/nu/polly.svg)](https://badge.fury.io/nu/polly) [![Build status](https://github.com/App-vNext/Polly/workflows/build/badge.svg?branch=main&event=push)](https://github.com/App-vNext/Polly/actions?query=workflow%3Abuild+branch%3Amain+event%3Apush) [![Code coverage](https://codecov.io/gh/App-vNext/Polly/branch/main/graph/badge.svg)](https://codecov.io/gh/App-vNext/Polly) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org) ![Polly logo](https://raw.github.com/App-vNext/Polly/main/Polly-Logo.png) From 7a8d8f46e4898771b91ca592e5d01d6727ea4baa Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 15:29:19 +0000 Subject: [PATCH 3/8] Add GitHubActionsTestLogger Add GitHubActionsTestLogger for builds in GitHub Actions. Contributes to #980. --- build.cake | 8 ++++++++ src/Polly.Specs/Polly.Specs.csproj | 1 + 2 files changed, 9 insertions(+) diff --git a/build.cake b/build.cake index d275b2a2f0e..ddc3f437dc1 100644 --- a/build.cake +++ b/build.cake @@ -211,11 +211,19 @@ Task("__BuildSolutions") Task("__RunTests") .Does(() => { + var loggers = Array.Empty(); + + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_SHA"))) + { + loggers = new[] { "GitHubActions;report-warnings=false" }; + } + foreach(var specsProj in GetFiles("./src/**/*.Specs.csproj")) { DotNetTest(specsProj.FullPath, new DotNetTestSettings { Configuration = configuration, + Loggers = loggers, NoBuild = true, }); } diff --git a/src/Polly.Specs/Polly.Specs.csproj b/src/Polly.Specs/Polly.Specs.csproj index 10b817f959b..e20525f8175 100644 --- a/src/Polly.Specs/Polly.Specs.csproj +++ b/src/Polly.Specs/Polly.Specs.csproj @@ -13,6 +13,7 @@ + From ec2d6ff01acf584c2038672fd7b3b8166e4c12b5 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 15:39:25 +0000 Subject: [PATCH 4/8] Update Cake Update Cake to version 3, as well as all the related dependencies. --- .config/dotnet-tools.json | 2 +- build.cake | 14 +++++++------- build.ps1 | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index ed800ac9f70..23e1c931b4e 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "2.0.0", + "version": "3.0.0", "commands": [ "dotnet-cake" ] diff --git a/build.cake b/build.cake index ddc3f437dc1..e1c6e8b4655 100644 --- a/build.cake +++ b/build.cake @@ -9,17 +9,17 @@ var configuration = Argument("configuration", "Release"); // EXTERNAL NUGET TOOLS ////////////////////////////////////////////////////////////////////// -#Tool "GitVersion.CommandLine&version=5.8.1" -#Tool "xunit.runner.console&version=2.4.1" +#Tool "GitVersion.CommandLine&version=5.11.1" +#Tool "xunit.runner.console&version=2.4.2" ////////////////////////////////////////////////////////////////////// // EXTERNAL NUGET LIBRARIES ////////////////////////////////////////////////////////////////////// -#addin nuget:?package=Cake.FileHelpers&version=5.0.0 -#addin nuget:?package=Cake.Yaml&version=4.0.0 -#addin nuget:?package=Newtonsoft.Json&version=13.0.1 -#addin nuget:?package=YamlDotNet&version=11.2.1 +#addin nuget:?package=Cake.FileHelpers&version=6.0.0 +#addin nuget:?package=Cake.Yaml&version=6.0.0 +#addin nuget:?package=Newtonsoft.Json&version=13.0.2 +#addin nuget:?package=YamlDotNet&version=12.3.1 /////////////////////////////////////////////////////////////////////////////// // GLOBAL VARIABLES @@ -199,7 +199,7 @@ Task("__BuildSolutions") var dotNetCoreBuildSettings = new DotNetBuildSettings { Configuration = configuration, - Verbosity = DotNetCoreVerbosity.Minimal, + Verbosity = DotNetVerbosity.Minimal, NoRestore = true, MSBuildSettings = new DotNetMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }, }; diff --git a/build.ps1 b/build.ps1 index 6838e1e840c..26b0b37c28c 100755 --- a/build.ps1 +++ b/build.ps1 @@ -115,7 +115,7 @@ if (-Not $SkipToolPackageRestore.IsPresent) # Install just Cake if missing config else { - $NuGetOutput = Invoke-Expression "&`"$DOTNET`" tool install Cake.Tool --version 2.0.0" + $NuGetOutput = Invoke-Expression "&`"$DOTNET`" tool install Cake.Tool --version 3.0.0" Write-Verbose ($NuGetOutput | Out-String) } Pop-Location From ab0048d2a270c9cbe403deb856029138363d7527 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 15:48:52 +0000 Subject: [PATCH 5/8] Fix GitVersion in GitHub Actions See https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md#execute-gitversion-action-gitversionexecute-usage-examples. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f611fd21a27..1a29cf7e64d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup .NET SDK uses: actions/setup-dotnet@v3 From 8b8b2a1d6e2bfc4849273eb132adaebd66adcbca Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 17:36:46 +0000 Subject: [PATCH 6/8] Remove leftover AppVeyor task Remove leftover Cake task for AppVeyor. --- build.cake | 32 -------------------------------- src/Polly/Polly.csproj | 3 ++- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/build.cake b/build.cake index e1c6e8b4655..08571633fd9 100644 --- a/build.cake +++ b/build.cake @@ -158,37 +158,6 @@ Task("__UpdateAssemblyVersionInformation") Information("AssemblyInformationalVersion -> {0}", assemblySemver); }); -Task("__UpdateDotNetStandardAssemblyVersionNumber") - .WithCriteria(() => AppVeyor.IsRunningOnAppVeyor) - .Does(() => -{ - Information("Updating Assembly Version Information"); - - var attributeToValueMap = new Dictionary() - { - { "AssemblyVersion", assemblyVersion }, - { "FileVersion", assemblySemver }, - { "InformationalVersion", assemblySemver }, - { "Version", nugetVersion }, - { "PackageVersion", nugetVersion }, - { "ContinuousIntegrationBuild", "true" }, - }; - - var csproj = File("./src/" + projectName + "/" + projectName + ".csproj"); - - foreach(var attributeMap in attributeToValueMap) - { - var attribute = attributeMap.Key; - var value = attributeMap.Value; - - var replacedFiles = ReplaceRegexInFiles(csproj, $@"\<{attribute}\>[^\<]*\", $@"<{attribute}>{value}"); - if (!replacedFiles.Any()) - { - throw new Exception($"{attribute} version could not be updated in {csproj}."); - } - } -}); - Task("__BuildSolutions") .Does(() => { @@ -254,7 +223,6 @@ Task("Build") .IsDependentOn("__Clean") .IsDependentOn("__RestoreNuGetPackages") .IsDependentOn("__UpdateAssemblyVersionInformation") - .IsDependentOn("__UpdateDotNetStandardAssemblyVersionNumber") .IsDependentOn("__BuildSolutions") .IsDependentOn("__RunTests") .IsDependentOn("__CreateSignedNuGetPackage"); diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 06e80258193..f48a2c3c056 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -16,7 +16,8 @@ Michael Wolfenden, App vNext $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb true - false + true + true true From 0027aab0396f315b50c59dc54a10867c3685facd Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 17:59:25 +0000 Subject: [PATCH 7/8] Fix versions Fix the Cake build so that the correct version properties are set for the binary and NuGet package. Also modernises some terminology for .NET (Core). --- .github/ISSUE_TEMPLATE/how-to.md | 7 ++----- build.cake | 23 ++++++++++++++++++----- src/Polly/Polly.csproj | 1 - 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/how-to.md b/.github/ISSUE_TEMPLATE/how-to.md index af1600ae5f1..f4375500a66 100644 --- a/.github/ISSUE_TEMPLATE/how-to.md +++ b/.github/ISSUE_TEMPLATE/how-to.md @@ -7,18 +7,15 @@ about: You have something specific to achieve and the existing documentation has - **Summary: What are you wanting to achieve?** - **What code or approach do you have so far?** - It is _always_ useful to see: -+ **code of any policy declarations**, ++ **code of any policy declarations**, + **code of the calls to `.Execute/AndCapture/Async(...)`** diff --git a/build.cake b/build.cake index 08571633fd9..e57fbb57a51 100644 --- a/build.cake +++ b/build.cake @@ -165,15 +165,21 @@ Task("__BuildSolutions") { Information("Building {0}", solution); - var dotNetCoreBuildSettings = new DotNetBuildSettings + var dotNetBuildSettings = new DotNetBuildSettings { Configuration = configuration, Verbosity = DotNetVerbosity.Minimal, NoRestore = true, - MSBuildSettings = new DotNetMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }, + MSBuildSettings = new DotNetMSBuildSettings + { + AssemblyVersion = assemblyVersion, + FileVersion = assemblySemver, + TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error, + Version = nugetVersion, + }, }; - DotNetBuild(solution.ToString(), dotNetCoreBuildSettings); + DotNetBuild(solution.ToString(), dotNetBuildSettings); } }); @@ -205,14 +211,21 @@ Task("__CreateSignedNuGetPackage") Information("Building {0}.{1}.nupkg", packageName, nugetVersion); - var dotNetCorePackSettings = new DotNetPackSettings + var dotNetPackSettings = new DotNetPackSettings { Configuration = configuration, NoBuild = true, OutputDirectory = nupkgDestDir, + MSBuildSettings = new DotNetMSBuildSettings + { + AssemblyVersion = assemblyVersion, + FileVersion = assemblySemver, + TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error, + Version = nugetVersion, + }, }; - DotNetPack(System.IO.Path.Combine(srcDir, projectName + ".sln"), dotNetCorePackSettings); + DotNetPack(System.IO.Path.Combine(srcDir, projectName + ".sln"), dotNetPackSettings); }); ////////////////////////////////////////////////////////////////////// diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index f48a2c3c056..3a178d88f58 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -6,7 +6,6 @@ 7.0.0.0 7.2.4.0 7.2.4.0 - 7.2.4 App vNext Copyright (c) $([System.DateTime]::Now.ToString(yyyy)), App vNext Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From d79619bd22947acbe1429c4a67058e2c7f14a499 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 6 Jan 2023 18:20:58 +0000 Subject: [PATCH 8/8] Fix code coverage Output from coverlet in cobertura format so that ReportGenerator can process it. --- .gitignore | 1 + src/Polly.Specs/Polly.Specs.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2b50fe15803..75a1c0c03df 100644 --- a/.gitignore +++ b/.gitignore @@ -123,5 +123,6 @@ tools *.lock.json *.nuget.targets *.nuget.props +coverage.*.cobertura.xml coverage.*.json coverage-reports/ diff --git a/src/Polly.Specs/Polly.Specs.csproj b/src/Polly.Specs/Polly.Specs.csproj index e20525f8175..b23795e5d3a 100644 --- a/src/Polly.Specs/Polly.Specs.csproj +++ b/src/Polly.Specs/Polly.Specs.csproj @@ -27,6 +27,7 @@ true + cobertura [xunit.*]* System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute 75,60,70