Skip to content

Commit

Permalink
Fix coverage. Publish coverage only on push
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Feb 8, 2024
1 parent cb53623 commit a3b35e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/dotnet-releaser/ReleaserApp.Configuring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ private async Task<(BuildInformation? buildInformation, IDevHosting? devHosting,
return null;
}

buildInformation.IsPush = gitHubInfo.EventName == "push";

// Automatically convert a run into a publish if we have a release tag
if (gitHubInfo.EventName == "push" && gitHubInfo.RefType == GitHubActionRefType.Tag)
{
Expand Down
6 changes: 3 additions & 3 deletions src/dotnet-releaser/ReleaserApp.Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class ReleaserApp
{
private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformation buildInfo, HitCoverage coverage)
{
if (!_config.Coverage.BadgeUploadToGist) return;
if (!_config.Coverage.BadgeUploadToGist || !buildInfo.IsPush) return;

var gistId = _config.Coverage.BadgeGistId;
if (string.IsNullOrWhiteSpace(gistId))
Expand All @@ -24,7 +24,7 @@ private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformatio
return;
}

var rate = (int)(Math.Round((double)coverage.Rate) * 100);
var rate = (int)Math.Round((double)coverage.Rate * 100);
var svg = $"""
<svg xmlns="http:https://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><rect rx="3" width="99" height="20" fill="#555"/><rect rx="3" x="63" width="36" height="20" fill="#97CA00"/><path fill="#97CA00" d="M63 0h4v20h-4z"/><rect rx="3" width="99" height="20" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="32.5" y="15" fill="#010101" fill-opacity=".3">coverage</text><text x="32.5" y="14">coverage</text><text x="80" y="15" fill="#010101" fill-opacity=".3">{rate:##}%</text><text x="80" y="14">{rate:##}%</text></g></svg>
""";
Expand All @@ -36,7 +36,7 @@ private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformatio

private async Task PublishCoveralls(IDevHosting devHosting, BuildInformation buildInfo)
{
if (!_config.Coveralls.Publish || _assemblyCoverages.Count == 0) return;
if (!_config.Coveralls.Publish || _assemblyCoverages.Count == 0 || !buildInfo.IsPush) return;

var ownerRepo = $"{devHosting.Configuration.User}/{devHosting.Configuration.Repo}";

Expand Down
2 changes: 2 additions & 0 deletions src/dotnet-releaser/ReleaserApp.Projects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public BuildInformation(ProjectPackageInfoCollection[] projectPackageInfoCollect

public bool PublishNuGet { get; set; }

public bool IsPush { get; set; }

public bool AllowPublishDraft { get; set; }

public BuildKind BuildKind { get; set; }
Expand Down

0 comments on commit a3b35e6

Please sign in to comment.