Skip to content

Add GitHub Actions artifact upload support for issue reports #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Cake.Frosting.Issues.Recipe;

using System;
using Cake.Common.Build;
using Cake.Core.IO;

Expand Down Expand Up @@ -64,6 +65,46 @@
context.NotNull(); // Summary issues report is not supported for GitHub Actions.

/// <inheritdoc />
public override void PublishIssuesArtifacts(IIssuesContext context) =>
context.NotNull(); // Publishing artifacts is currently not supported for GitHub Actions.
public override void PublishIssuesArtifacts(IIssuesContext context)
{
context.NotNull();

if (context.Parameters.BuildServer.ShouldPublishFullIssuesReport &&
context.State.FullIssuesReport != null &&
context.FileExists(context.State.FullIssuesReport))

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
{
// Set GitHub Actions output for full issues report
var outputFile = context.EnvironmentVariable("GITHUB_OUTPUT");

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 77 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
if (!string.IsNullOrEmpty(outputFile))
{
var outputContent = $"full-issues-report-path={context.State.FullIssuesReport.FullPath}";
System.IO.File.AppendAllText(outputFile, outputContent + Environment.NewLine);
context.Information($"Set GitHub Actions output: {outputContent}");

Check failure on line 82 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 82 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 82 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
}
else
{
// Fallback to workflow command for older GitHub Actions runners
context.Information($"::set-output name=full-issues-report-path::{context.State.FullIssuesReport.FullPath}");

Check failure on line 87 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 87 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 87 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
}
}

if (context.Parameters.BuildServer.ShouldPublishSarifReport &&
context.State.SarifReport != null &&
context.FileExists(context.State.SarifReport))

Check failure on line 93 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 93 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 93 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'FileExists' and no accessible extension method 'FileExists' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
{
// Set GitHub Actions output for SARIF report
var outputFile = context.EnvironmentVariable("GITHUB_OUTPUT");

Check failure on line 96 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'EnvironmentVariable' and no accessible extension method 'EnvironmentVariable' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
if (!string.IsNullOrEmpty(outputFile))
{
var outputContent = $"sarif-report-path={context.State.SarifReport.FullPath}";
System.IO.File.AppendAllText(outputFile, outputContent + Environment.NewLine);
context.Information($"Set GitHub Actions output: {outputContent}");

Check failure on line 101 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 101 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 101 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
}
else
{
// Fallback to workflow command for older GitHub Actions runners
context.Information($"::set-output name=sarif-report-path::{context.State.SarifReport.FullPath}");

Check failure on line 106 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 106 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 106 in Cake.Frosting.Issues.Recipe/Cake.Frosting.Issues.Recipe/BuildServers/GitHubActionsBuildServer.cs

View workflow job for this annotation

GitHub Actions / Build

'IIssuesContext' does not contain a definition for 'Information' and no accessible extension method 'Information' accepting a first argument of type 'IIssuesContext' could be found (are you missing a using directive or an assembly reference?)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,42 @@ public class GitHubActionsBuildServer : BaseBuildServer
context.NotNull();
data.NotNull();

// Publishing artifacts is currently not supported for GitHub Actions.
if (IssuesParameters.BuildServer.ShouldPublishFullIssuesReport &&
data.FullIssuesReport != null &&
context.FileExists(data.FullIssuesReport))
{
// Set GitHub Actions output for full issues report
var outputFile = context.EnvironmentVariable("GITHUB_OUTPUT");
if (!string.IsNullOrEmpty(outputFile))
{
var outputContent = $"full-issues-report-path={data.FullIssuesReport.FullPath}";
System.IO.File.AppendAllText(outputFile, outputContent + System.Environment.NewLine);
context.Information($"Set GitHub Actions output: {outputContent}");
}
else
{
// Fallback to workflow command for older GitHub Actions runners
context.Information($"::set-output name=full-issues-report-path::{data.FullIssuesReport.FullPath}");
}
}

if (IssuesParameters.BuildServer.ShouldPublishSarifReport &&
data.SarifReport != null &&
context.FileExists(data.SarifReport))
{
// Set GitHub Actions output for SARIF report
var outputFile = context.EnvironmentVariable("GITHUB_OUTPUT");
if (!string.IsNullOrEmpty(outputFile))
{
var outputContent = $"sarif-report-path={data.SarifReport.FullPath}";
System.IO.File.AppendAllText(outputFile, outputContent + System.Environment.NewLine);
context.Information($"Set GitHub Actions output: {outputContent}");
}
else
{
// Fallback to workflow command for older GitHub Actions runners
context.Information($"::set-output name=sarif-report-path::{data.SarifReport.FullPath}");
}
}
}
}
Loading