diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2c7950..3da6ac7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }} AZURE_SOURCE: ${{ secrets.AZURE_SOURCE }} AZURE_USER: ${{ secrets.AZURE_USER }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITTER_ROOM_ID: ${{ secrets.GITTER_ROOM_ID }} GITTER_TOKEN: ${{ secrets.GITTER_TOKEN }} diff --git a/.jscpd.json b/.jscpd.json new file mode 100644 index 0000000..86ad77a --- /dev/null +++ b/.jscpd.json @@ -0,0 +1,10 @@ +{ + "absolute": true, + "ignore": [ + "Source/*.Tests/**" + ], + "reporters": [ + "consoleFull" + ], + "threshold": 0.1 +} diff --git a/Source/Cake.Codecov.Tests/CodecovRunnerTests.cs b/Source/Cake.Codecov.Tests/CodecovRunnerTests.cs index e8d00da..b35ee3a 100644 --- a/Source/Cake.Codecov.Tests/CodecovRunnerTests.cs +++ b/Source/Cake.Codecov.Tests/CodecovRunnerTests.cs @@ -1,10 +1,11 @@ +using System; +using System.Runtime.InteropServices; using Cake.Codecov.Internals; using Cake.Codecov.Tests.Attributes; using Cake.Core; using Cake.Testing; using FluentAssertions; using Moq; -using System; using Xunit; namespace Cake.Codecov.Tests @@ -107,6 +108,7 @@ public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Windows() [Theory] [InlineData("linux-x64/codecov")] + [InlineData("codecov-linux")] [InlineData("codecov")] public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Linux(string path) { @@ -129,6 +131,7 @@ public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Linux(string [Theory] [InlineData("linux-x64/codecov")] + [InlineData("codecov-macos")] [InlineData("codecov")] public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_osx(string path) { @@ -216,6 +219,32 @@ public void Should_Set_Build() result.Args.Should().Be(@"--build ""1"""); } + [Fact] + public void Should_EnableClean() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { CleanReports = true } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be(@"--clean"); + } + + [Fact] + public void Should_Not_Enable_Clean() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { CleanReports = false } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().BeNullOrEmpty(); + } + [Fact] public void Should_Set_Commit() { @@ -229,8 +258,8 @@ public void Should_Set_Commit() result.Args.Should().Be(@"--sha ""603e02d40093d0649cfa787d846ae4ccc038085c"""); } - [Fact] - public void Should_Enable_DisableNetwork() + [Fact, Obsolete("Remove test in v2.0.0")] + public void Should_Enable_DryRun_When_DisableNetwork_Is_Set() { // Given var fixture = new CodecovRunnerFixture { Settings = { DisableNetwork = true } }; @@ -239,11 +268,11 @@ public void Should_Enable_DisableNetwork() var result = fixture.Run(); // Then - result.Args.Should().Be("--disable-network"); + result.Args.Should().Be("--dryRun"); } - [Fact] - public void Should_Enable_Dump() + [Fact, Obsolete("Remove test in v2.0.0")] + public void Should_Enable_DryRun_When_Dump_Is_Set() { // Given var fixture = new CodecovRunnerFixture { Settings = { Dump = true } }; @@ -252,7 +281,20 @@ public void Should_Enable_Dump() var result = fixture.Run(); // Then - result.Args.Should().Be("--dump"); + result.Args.Should().Be("--dryRun"); + } + + [Fact] + public void Should_Enable_DryRun() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { DryRun = true } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be("--dryRun"); } [Fact] @@ -307,6 +349,32 @@ public void Should_Set_Flags() result.Args.Should().Be(@"--flag ""ut,chrome"""); } + [Fact] + public void Should_Enable_GCov() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { EnableGcovSupport = true } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be(@"--gcov"); + } + + [Fact] + public void Should_Not_Enable_GCov() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { EnableGcovSupport = false } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().BeNullOrEmpty(); + } + [Fact] public void Should_Set_Name() { @@ -316,12 +384,12 @@ public void Should_Set_Name() // When var result = fixture.Run(); - // Then + // ThenRæ result.Args.Should().Be(@"--name ""custom name"""); } - [Fact] - public void Should_Enable_NoColor() + [Fact, Obsolete("Remove test in v2.0.0")] + public void Should_Ignore_NoColor() { // Given var fixture = new CodecovRunnerFixture { Settings = { NoColor = true } }; @@ -330,7 +398,7 @@ public void Should_Enable_NoColor() var result = fixture.Run(); // Then - result.Args.Should().Be("--no-color"); + result.Args.Should().BeNullOrEmpty(); } [Fact] @@ -346,8 +414,8 @@ public void Should_Set_Pr() result.Args.Should().Be(@"--pr ""1"""); } - [Fact] - public void Should_Enable_Required() + [Fact, Obsolete("Remove in v2.0.0")] + public void Should_Enable_NonZero_When_Required_Is_Set() { // Given var fixture = new CodecovRunnerFixture { Settings = { Required = true } }; @@ -356,11 +424,37 @@ public void Should_Enable_Required() var result = fixture.Run(); // Then - result.Args.Should().Be("--required"); + result.Args.Should().Be("--nonZero"); } [Fact] - public void Should_Set_Root() + public void Should_Enable_NonZero() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { NonZero = true } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be("--nonZero"); + } + + [Fact] + public void Should_Sete_ParentSha() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { ParentSha = "some-kind-of-sha" } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be(@"--parent ""some-kind-of-sha"""); + } + + [Fact, Obsolete("Remove test in v2.0.0")] + public void Should_Set_RootDirectory_When_Root_Is_Set() { // Given var fixture = new CodecovRunnerFixture { Settings = { Root = @".\working" } }; @@ -369,7 +463,35 @@ public void Should_Set_Root() var result = fixture.Run(); // Then - result.Args.Should().Be(@"--root ""working"""); + result.Args.Should().Be(@"--rootDir ""working"""); + } + + [Fact] + public void Should_Set_RootDirectory() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { RootDirectory = @".\working" } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be(@"--rootDir ""working"""); + } + + [Fact] + public void Should_Set_SearchDirectory() + { + var directory = Environment.CurrentDirectory.Replace("\\", "/"); + + // Given + var fixture = new CodecovRunnerFixture { Settings = { SearchDirectory = Environment.CurrentDirectory } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be(@$"--dir ""{directory}"""); } [Fact] @@ -385,6 +507,32 @@ public void Should_Set_Slug() result.Args.Should().Be(@"--slug ""owner/repo"""); } + [Fact] + public void Should_Enable_Changelog() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { ShowChangelog = true } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().Be("--changelog"); + } + + [Fact] + public void Should_Not_Enable_Changelog() + { + // Given + var fixture = new CodecovRunnerFixture { Settings = { ShowChangelog = false } }; + + // When + var result = fixture.Run(); + + // Then + result.Args.Should().BeNullOrEmpty(); + } + [Fact] public void Should_Set_Tag() { diff --git a/Source/Cake.Codecov.Tests/CodecovSettingsTests.cs b/Source/Cake.Codecov.Tests/CodecovSettingsTests.cs index e4565b2..ebb8c1d 100644 --- a/Source/Cake.Codecov.Tests/CodecovSettingsTests.cs +++ b/Source/Cake.Codecov.Tests/CodecovSettingsTests.cs @@ -72,6 +72,20 @@ public void Should_Set_Commit_Value() } [Fact] + public void Should_Set_Clean_Value() + { + // Given + var settings = new CodecovSettings + { + // When + CleanReports = true + }; + + // Then + settings.CleanReports.Should().BeTrue(); + } + + [Fact, Obsolete("Remove test in v2.0.0")] public void Should_Set_DisableNetwork_Value() { // Given @@ -85,7 +99,7 @@ public void Should_Set_DisableNetwork_Value() settings.DisableNetwork.Should().BeTrue(); } - [Fact] + [Fact, Obsolete("Remove test in v2.0.0")] public void Should_Set_Dump_Value() { // Given @@ -99,6 +113,20 @@ public void Should_Set_Dump_Value() settings.Dump.Should().BeTrue(); } + [Fact] + public void Should_Set_EnableGcovSupport_Value() + { + // Given + var settings = new CodecovSettings + { + // When + EnableGcovSupport = true + }; + + // Then + settings.EnableGcovSupport.Should().BeTrue(); + } + [Fact] public void Should_Set_Envs_Value() { @@ -174,8 +202,8 @@ public void Should_Set_Name_Value() settings.Name.Should().Be(expected); } - [Fact] - public void Should_Set_NoColor_Value() + [Fact, Obsolete("Remove test in v2.0.0")] + public void Should_Not_Set_NoColor_Value() { // Given var settings = new CodecovSettings @@ -185,7 +213,22 @@ public void Should_Set_NoColor_Value() }; // Then - settings.NoColor.Should().BeTrue(); + settings.NoColor.Should().BeFalse(); + } + + [Fact] + public void Should_Set_ParentSha_Value() + { + // Given + const string expected = "some-sha"; + var settings = new CodecovSettings + { + // When + ParentSha = expected + }; + + // Then + settings.ParentSha.Should().Be(expected); } [Fact] @@ -203,7 +246,7 @@ public void Should_Set_Pr_Value() settings.Pr.Should().Be(expected); } - [Fact] + [Fact, Obsolete("Remove test in v2.0.0")] public void Should_Set_Required_Value() { // Given @@ -217,7 +260,7 @@ public void Should_Set_Required_Value() settings.Required.Should().BeTrue(); } - [Fact] + [Fact, Obsolete("Remove test in v2.0.0")] public void Should_Set_Root_Value() { // Given @@ -232,6 +275,50 @@ public void Should_Set_Root_Value() settings.Root.Should().BeEquivalentTo(expected); } + [Fact] + public void Should_Set_RootDirectory_Value() + { + // Given + var expected = (DirectoryPath)"root/other"; + var settings = new CodecovSettings + { + // When + RootDirectory = expected + }; + + // Then + settings.RootDirectory.Should().BeEquivalentTo(expected); + } + + [Fact] + public void Should_Set_SearchDirectory_Value() + { + // Given + var expected = (DirectoryPath)"some-search-path"; + var settings = new CodecovSettings + { + // When + SearchDirectory = expected + }; + + // Then + settings.SearchDirectory.Should().BeEquivalentTo(expected); + } + + [Fact] + public void Should_Set_ShowChangelog_Value() + { + // Given + var settings = new CodecovSettings + { + // When + ShowChangelog = true + }; + + // Then + settings.ShowChangelog.Should().BeTrue(); + } + [Fact] public void Should_Set_Slug_Value() { diff --git a/Source/Cake.Codecov/CodecovRunner.cs b/Source/Cake.Codecov/CodecovRunner.cs index 07e33cd..b35cfa9 100644 --- a/Source/Cake.Codecov/CodecovRunner.cs +++ b/Source/Cake.Codecov/CodecovRunner.cs @@ -43,11 +43,13 @@ protected override IEnumerable GetToolExecutableNames() { if (_platformDetector.IsLinuxPlatform()) { + yield return "codecov-linux"; yield return "linux-x64/codecov"; yield return "codecov"; } else if (_platformDetector.IsOsxPlatform()) { + yield return "codecov-macos"; yield return "osx-x64/codecov"; yield return "codecov"; } diff --git a/Source/Cake.Codecov/CodecovSettings.cs b/Source/Cake.Codecov/CodecovSettings.cs index 191bcdb..cb3438b 100644 --- a/Source/Cake.Codecov/CodecovSettings.cs +++ b/Source/Cake.Codecov/CodecovSettings.cs @@ -5,20 +5,14 @@ using System; using System.Collections.Generic; - using Cake.Core.IO; using Cake.Core.Tooling; namespace Cake.Codecov { /// - /// Contains settings used by . See CommandLineOptions - /// or run. - /// - /// .\codecov.exe --help - /// - /// for more details. + /// Contains settings used by for the new Codecov Uploader provided + /// by their team. /// public sealed class CodecovSettings : ToolSettings { @@ -44,6 +38,19 @@ public string Build set => SetValue("--build", value); } + /// + /// Gets or sets a value indicating whether Discovered coverage reports should be moved to + /// the trash. + /// + /// + /// A value indicating whether Discovered coverage reports should be moved to the trash. + /// + public bool CleanReports + { + get => GetValue("--clean"); + set => SetValue("--clean", value); + } + /// /// Gets or sets a property specifing the commit sha. /// @@ -55,27 +62,52 @@ public string Commit } /// - /// Gets or sets a value indicating whether to toggle functionalities. (1) --disable-network. - /// Disable uploading the file network. + /// Gets or sets a value indicating whether to toggle functionalities. (1) + /// --disable-network. Disable uploading the file network. /// /// /// A value indicating whether to toggle functionalities. (1) --disable-network. Disable /// uploading the file network. /// + /// + /// This function has been made a no-op, and do not have any functionality. + /// + [Obsolete("This property have been deprecated, and will be removed in v2.0.0. Use property 'DryRun' instead.")] public bool DisableNetwork { - get => GetValue("--disable-network"); - set => SetValue("--disable-network", value); + get => DryRun; + set => DryRun = value; } /// /// Gets or sets a value indicating whether to don't upload and dump to stdin. /// /// A value indicating whether to don't upload and dump to stdin. + [Obsolete("This property have been deprecated, and will be removed in v2.0.0. Use property 'DryRun' instead.")] public bool Dump { - get => GetValue("--dump"); - set => SetValue("--dump", value); + get => DryRun; + set => DryRun = value; + } + + /// + /// Gets or sets a value indicating whether files should be uploaded to Codecov. + /// + /// A value indicating whether files should be uploaded to Codecov. + public bool DryRun + { + get => GetValue("--dryRun"); + set => SetValue("--dryRun", value); + } + + /// + /// Gets or sets a value indicating whether Codecov should run with gcov support or not. + /// + /// A value indicating whether Codecov should run with gcov support or not. + public bool EnableGcovSupport + { + get => GetValue("--gcov"); + set => SetValue("--gcov", value); } /// @@ -95,9 +127,7 @@ public IEnumerable Envs /// /// Gets or sets a value specifying which flags should be toggled on/off. /// - /// - /// A value specifying which features should be toggled on or off. - /// + /// A value specifying which features should be toggled on or off. public IEnumerable Features { get => GetValue>("--feature"); @@ -112,9 +142,7 @@ public IEnumerable Features /// A value specifing the target file(s) to upload. (1) -f 'path/to/file'. Only upload this /// file. (2) -f 'path/to/file1 path/to/file2'. Only upload these files. /// - /// - /// Globbing in file paths are supported, but not when path starts with './'. - /// + /// Globbing in file paths are supported, but not when path starts with './'. public IEnumerable Files { get => GetValue>("--file"); @@ -153,10 +181,34 @@ public string Name /// Gets or sets a value indicating whether to remove color from the output. /// /// A value indicating whether to remove color from the output. + [Obsolete("This property have been deprecated, and will be removed in v2.0.0.")] public bool NoColor { - get => GetValue("--no-color"); - set => SetValue("--no-color", value); + get => false; + set { } + } + + /// + /// Gets or sets a value indicating whether Codecov should exit with a non-zero exit code on errors. + /// + /// Whether Codecov should exit with a non-zero exit code on errors. + public bool NonZero + { + get => GetValue("--nonZero"); + set => SetValue("--nonZero", value); + } + + /// + /// Gets or sets the commit SHA of the parent for which you are uploading coverage. If not + /// set, the parent will be determined using the API of your repository provider. When using + /// the repository provider's API, the parent is determined via finding the closest ancestor + /// of the commit. + /// + /// The commit SHA of the parent for which you are uploading coverage. + public string ParentSha + { + get => GetValue("--parent"); + set => SetValue("--parent", value); } /// @@ -176,25 +228,57 @@ public string Pr /// /// A value indicating whether to exit with 1 if not successful. Default will Exit with 0. /// + [Obsolete("This property have been deprecated, and will be removed in v2.0.0. Use property 'NonZero' instead.")] public bool Required { - get => GetValue("--required"); - set => SetValue("--required", value); + get => NonZero; + set => NonZero = value; } /// /// Gets or sets a value used when not in git project to identify project root directory. /// /// A value used when not in git project to identify project root directory. + [Obsolete("This property have been deprecated, and will be removed in v2.0.0. Use property 'RootDirectory' instead.")] public DirectoryPath Root { - get => GetValue("--root"); - set => SetValue("--root", value?.ToString()); + get => RootDirectory; + set => RootDirectory = value; + } + + /// + /// Gets or sets the root directory when it is not a git repository. + /// + /// The root directory when it is not a git repository. + public DirectoryPath RootDirectory + { + get => GetValue("--rootDir"); + set => SetValue("--rootDir", value); + } + + /// + /// Gets or sets the directory to use when searching for coverage reports. + /// + /// The directory to use when searching for coverage reports. + public DirectoryPath SearchDirectory + { + get => GetValue("--dir"); + set => SetValue("--dir", value); } /// - /// Gets or sets a value specifing the owner/repo slug used instead of the private repo token - /// in Enterprise. (option) Set environment variable CODECOV_SLUG=:owner/:repo. + /// Gets or sets a value indicating whether the a link should be displayed to the current changelog. + /// + /// A value indicating whether a link should be showed to the changelog. + public bool ShowChangelog + { + get => GetValue("--changelog"); + set => SetValue("--changelog", value); + } + + /// + /// Gets or sets a value specifing the owner/repo slug used instead of the private repo + /// token in Enterprise. (option) Set environment variable CODECOV_SLUG=:owner/:repo. /// /// /// A value specifing the owner/repo slug used instead of the private repo token in @@ -217,8 +301,8 @@ public string Tag } /// - /// Gets or sets a value specifing the private repository token. (option) set the enviornment - /// variable CODECOV_TOKEN-uuid. (1) -t @/path/to/token_file. (2) -t uuid. + /// Gets or sets a value specifing the private repository token. (option) set the + /// enviornment variable CODECOV_TOKEN-uuid. (1) -t @/path/to/token_file. (2) -t uuid. /// /// /// A value specifing the private repository token. (option) set the enviornment variable @@ -257,6 +341,17 @@ public bool Verbose internal IDictionary GetAllArguments() => _arguments; + /// + /// Gets a value that is already set in the underlying dictionary. If no value is set, then + /// is returned instead. + /// + /// The type of the value expected in the dictionary. + /// The key or name of the value. + /// The default value if no value is found. + /// + /// The found value with the specified , or the i no value is found. + /// private TValue GetValue(string key, TValue defaultValue = default) { if (_arguments.TryGetValue(key, out var objValue) && objValue is TValue value) @@ -267,6 +362,12 @@ private TValue GetValue(string key, TValue defaultValue = default) return defaultValue; } + /// + /// Sets the specified in the underlying dictionary using the + /// specified . + /// + /// The key to use when adding/updating the dictionary. + /// The value to insert. private void SetValue(string key, object value) { if (value is string stringValue && string.IsNullOrWhiteSpace(stringValue)) diff --git a/setup.cake b/setup.cake index 1a71280..fec7372 100644 --- a/setup.cake +++ b/setup.cake @@ -1,7 +1,10 @@ #load nuget:?package=Cake.Recipe&version=3.1.1 #tool nuget:?package=NuGet.CommandLine&version=5.7.0 // Workaround necessary due to incompatibility with GHA nuget +#tool nuget:?package=CodecovUploader&version=0.7.3 -Environment.SetVariableNames(); +Environment.SetVariableNames( + codecovRepoTokenVariable: "CODECOV_TOKEN" // This is the name that codecov themself expect +); BuildParameters.SetParameters( context: Context, @@ -13,7 +16,7 @@ BuildParameters.SetParameters( appVeyorAccountName: "cakecontrib", shouldRunDotNetCorePack: true, shouldGenerateDocumentation: false, - shouldRunCodecov: false, + shouldRunCodecov: true, shouldRunCoveralls: false, shouldUseDeterministicBuilds: true, shouldUseTargetFrameworkPath: false, @@ -25,38 +28,49 @@ BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings( context: Context, testCoverageFilter: "+[Cake.Codecov]*"); +ToolSettings.SetToolPreprocessorDirectives(codecovTool: "#tool nuget:?package=CodecovUploader&version=0.7.3"); // Tasks we want to override -// ((CakeTask)BuildParameters.Tasks.UploadCodecovReportTask.Task).Actions.Clear(); -// BuildParameters.Tasks.UploadCodecovReportTask -// .IsDependentOn("DotNetCore-Pack") -// .Does((version) => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.CodecovGlobalTool : ToolSettings.CodecovTool, () => { -// var nugetPkg = $"nuget:file://{MakeAbsolute(BuildParameters.Paths.Directories.NuGetPackages)}?package=Cake.Codecov&version={version.SemVersion}&prerelease"; -// Information("PATH: " + nugetPkg); - -// var coverageFilter = BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml"; -// Information($"Passing coverage filter to codecov: \"{coverageFilter}\""); - -// var environmentVariables = new Dictionary(); - -// if (version != null && !string.IsNullOrEmpty(version.FullSemVersion) && BuildParameters.BuildProvider.SupportsTokenlessCodecov) -// { -// var buildVersion = string.Format("{0}.build.{1}", -// version.FullSemVersion, -// BuildSystem.AppVeyor.Environment.Build.Number); -// environmentVariables.Add("APPVEYOR_BUILD_VERSION", buildVersion); -// } - -// var script = string.Format(@"#addin ""{0}"" -// Codecov(new CodecovSettings {{ -// Files = new[] {{ ""{1}"" }}, -// Root = ""{2}"", -// Required = true -// }});", -// nugetPkg, coverageFilter, BuildParameters.RootDirectoryPath); - -// RequireAddin(script, environmentVariables); -// }) -// ); +((CakeTask)BuildParameters.Tasks.UploadCodecovReportTask.Task).Actions.Clear(); +BuildParameters.Tasks.UploadCodecovReportTask + .IsDependentOn("DotNetCore-Pack") + .Does((version) => RequireTool(ToolSettings.CodecovTool, () => { + var nugetPkg = $"nuget:file://{MakeAbsolute(BuildParameters.Paths.Directories.NuGetPackages)}?package=Cake.Codecov&version={version.SemVersion}&prerelease"; + Information("PATH: " + nugetPkg); + + var coverageFilter = BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml"; + Information($"Passing coverage filter to codecov: \"{coverageFilter}\""); + + var environmentVariables = new Dictionary(); + + if (version != null && !string.IsNullOrEmpty(version.FullSemVersion) && (BuildParameters.BuildProvider.SupportsTokenlessCodecov || !string.IsNullOrEmpty(BuildParameters.Codecov.RepoToken))) + { + var buildVersion = string.Format("{0}.build.{1}", + version.FullSemVersion, + BuildSystem.AppVeyor.Environment.Build.Number); + environmentVariables.Add("APPVEYOR_BUILD_VERSION", buildVersion); + } + + if (!string.IsNullOrEmpty(BuildParameters.Codecov.RepoToken)) + { + environmentVariables.Add("CODECOV_TOKEN", BuildParameters.Codecov.RepoToken); + environmentVariables.Add("CODECOV_REQUIRED", "true"); + } + else if (BuildParameters.BuildProvider.SupportsTokenlessCodecov) + { + environmentVariables.Add("CODECOV_REQUIRED", "true"); + } + + var script = string.Format(@"#addin ""{0}"" +Codecov(new CodecovSettings {{ + Files = new[] {{ ""{1}"" }}, + RootDirectory = ""{2}"", + NonZero = EnvironmentVariable(""CODECOV_REQUIRED"", false), +}});", + nugetPkg, coverageFilter, BuildParameters.RootDirectoryPath); + + RequireAddin(script, environmentVariables); + }) +); Build.RunDotNetCore();