Skip to content

Commit

Permalink
(maint) Upload to codecov only when token is present
Browse files Browse the repository at this point in the history
There is less support of running tokenless codecov upload in the latest
version of the Codecov uploader, and the only places that supports this
quite ofter results in a Rate Limit being hit.

As such, when a token is not present, let us just attempt to do a DryRun
instead of uploading the coverage results.
  • Loading branch information
AdmiringWorm committed May 2, 2024
1 parent 7403531 commit f5fd5dd
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions setup.cake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BuildParameters.Tasks.UploadCodecovReportTask

var environmentVariables = new Dictionary<string, string>();

if (version != null && !string.IsNullOrEmpty(version.FullSemVersion) && (BuildParameters.BuildProvider.SupportsTokenlessCodecov || !string.IsNullOrEmpty(BuildParameters.Codecov.RepoToken)))
if (version != null && !string.IsNullOrEmpty(version.FullSemVersion))
{
var buildVersion = string.Format("{0}.build.{1}",
version.FullSemVersion,
Expand All @@ -54,18 +54,14 @@ BuildParameters.Tasks.UploadCodecovReportTask
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<bool>(""CODECOV_REQUIRED"", false),
NonZero = true,
DryRun = !HasEnvironmentVariable(""CODECOV_TOKEN"")
}});",
nugetPkg, coverageFilter, BuildParameters.RootDirectoryPath);

Expand Down

0 comments on commit f5fd5dd

Please sign in to comment.