Skip to content

Commit a3b35e6

Browse files
committed
Fix coverage. Publish coverage only on push
1 parent cb53623 commit a3b35e6

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/dotnet-releaser/ReleaserApp.Configuring.cs

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public partial class ReleaserApp
102102
return null;
103103
}
104104

105+
buildInformation.IsPush = gitHubInfo.EventName == "push";
106+
105107
// Automatically convert a run into a publish if we have a release tag
106108
if (gitHubInfo.EventName == "push" && gitHubInfo.RefType == GitHubActionRefType.Tag)
107109
{

src/dotnet-releaser/ReleaserApp.Coverage.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class ReleaserApp
1515
{
1616
private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformation buildInfo, HitCoverage coverage)
1717
{
18-
if (!_config.Coverage.BadgeUploadToGist) return;
18+
if (!_config.Coverage.BadgeUploadToGist || !buildInfo.IsPush) return;
1919

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

27-
var rate = (int)(Math.Round((double)coverage.Rate) * 100);
27+
var rate = (int)Math.Round((double)coverage.Rate * 100);
2828
var svg = $"""
2929
<svg xmlns="http://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>
3030
""";
@@ -36,7 +36,7 @@ private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformatio
3636

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

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

src/dotnet-releaser/ReleaserApp.Projects.cs

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public BuildInformation(ProjectPackageInfoCollection[] projectPackageInfoCollect
4343

4444
public bool PublishNuGet { get; set; }
4545

46+
public bool IsPush { get; set; }
47+
4648
public bool AllowPublishDraft { get; set; }
4749

4850
public BuildKind BuildKind { get; set; }

0 commit comments

Comments
 (0)