Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Oct 18, 2019
2 parents e17c9af + ada0f7f commit 9823ed8
Show file tree
Hide file tree
Showing 36 changed files with 1,172 additions and 44 deletions.
7 changes: 6 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#---------------------------------#
# Build Script #
#---------------------------------#
install:
# Update to latest NuGet version since we require 5.3.0 for embedded icon
- ps: nuget update -self

build_script:
- ps: .\build.ps1 -Target AppVeyor

# Tests
test: off
test_script:
- ps: .\build.ps1 -Target Run-Integration-Tests --exclusive

#---------------------------------#
# Branches to build #
Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These owners will be the default owners for everything in the repo and
# will be requested for review when someone opens a pull request.
* @pascalberger
4 changes: 2 additions & 2 deletions Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ See the Project Site for documentation and an overview of the whole ecosystem of
</description>
<license type="expression">MIT</license>
<projectUrl>https://cakeissues.net</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics@a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png</iconUrl>
<icon>icon.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.Recipe.git"/>
<copyright>Copyright © Pascal Berger</copyright>
<tags>Build Cake Cake.Issues Recipe</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.2.2</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.3.0</releaseNotes>
</metadata>
</package>
5 changes: 5 additions & 0 deletions Cake.Issues.Recipe/Content/IssuesBuildTasksDefinitions.cake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class IssuesBuildTaskDefinitions
/// </summary>
public CakeTaskBuilder PublishIssuesArtifactsTask { get; set; }

/// <summary>
/// Gets or sets the task for reporting issues to build server.
/// </summary>
public CakeTaskBuilder ReportIssuesToBuildServerTask { get; set; }

/// <summary>
/// Gets or sets the task for creating a summary issue report.
/// </summary>
Expand Down
17 changes: 9 additions & 8 deletions Cake.Issues.Recipe/Content/addins.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
///////////////////////////////////////////////////////////////////////////////

#addin nuget:?package=Cake.Git&version=0.21.0
#addin nuget:?package=Cake.Issues&version=0.7.0
#addin nuget:?package=Cake.Issues.MsBuild&version=0.7.0
#addin nuget:?package=Cake.Issues.InspectCode&version=0.7.1
#addin nuget:?package=Cake.Issues.Reporting&version=0.7.0
#addin nuget:?package=Cake.Issues.Reporting.Generic&version=0.7.1
#addin nuget:?package=Cake.Issues.PullRequests&version=0.7.0
#addin nuget:?package=Cake.Issues.PullRequests.Tfs&version=0.7.2
#addin nuget:?package=Cake.Tfs&version=0.3.2
#addin nuget:?package=Cake.Issues&version=0.8.0
#addin nuget:?package=Cake.Issues.MsBuild&version=0.8.0
#addin nuget:?package=Cake.Issues.InspectCode&version=0.8.0
#addin nuget:?package=Cake.Issues.Reporting&version=0.8.0
#addin nuget:?package=Cake.Issues.Reporting.Generic&version=0.8.0
#addin nuget:?package=Cake.Issues.PullRequests&version=0.8.0
#addin nuget:?package=Cake.Issues.PullRequests.AppVeyor&version=0.8.0
#addin nuget:?package=Cake.Issues.PullRequests.AzureDevOps&version=0.8.0
#addin nuget:?package=Cake.AzureDevOps&version=0.4.0
44 changes: 35 additions & 9 deletions Cake.Issues.Recipe/Content/build.cake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#load addins.cake
#load IssuesBuildTasksDefinitions.cake
#load version.cake
#load data/data.cake
#load parameters/parameters.cake

Expand All @@ -16,7 +19,7 @@ var IssuesBuildTasks = new IssuesBuildTaskDefinitions();

Setup<IssuesData>(setupContext =>
{
Information("Initializing Cake.Issues.Recipe (Version {0})...", BuildMetaData.Version);
Information("Initializing Cake.Issues.Recipe (Version {0})...", BuildMetaDataCakeIssuesRecipe.Version);
return new IssuesData(setupContext);
});

Expand All @@ -27,6 +30,7 @@ Setup<IssuesData>(setupContext =>
IssuesBuildTasks.IssuesTask = Task("Issues")
.Description("Main tasks for issue management integration.")
.IsDependentOn("Publish-IssuesArtifacts")
.IsDependentOn("Report-IssuesToBuildServer")
.IsDependentOn("Create-SummaryIssuesReport")
.IsDependentOn("Report-IssuesToPullRequest")
.IsDependentOn("Set-PullRequestIssuesState");
Expand All @@ -35,12 +39,6 @@ IssuesBuildTasks.ReadIssuesTask = Task("Read-Issues")
.Description("Reads issues from the provided log files.")
.Does<IssuesData>((data) =>
{
var settings =
new ReadIssuesSettings(data.RepositoryRootDirectory)
{
Format = IssueCommentFormat.Markdown
};

// Determine which issue providers should be used.
var issueProviders = new List<IIssueProvider>();

Expand Down Expand Up @@ -71,7 +69,7 @@ IssuesBuildTasks.ReadIssuesTask = Task("Read-Issues")
data.AddIssues(
ReadIssues(
issueProviders,
settings));
data.RepositoryRootDirectory));

Information("{0} issues are found.", data.Issues.Count());
});
Expand All @@ -82,7 +80,15 @@ IssuesBuildTasks.CreateFullIssuesReportTask = Task("Create-FullIssuesReport")
.IsDependentOn("Read-Issues")
.Does<IssuesData>((data) =>
{
data.FullIssuesReport = IssuesParameters.OutputDirectory.CombineWithFilePath("report.html");
var reportFileName = "report";
if (!string.IsNullOrWhiteSpace(IssuesParameters.BuildIdentifier))
{
reportFileName += $"-{IssuesParameters.BuildIdentifier}";
}
reportFileName += ".html";

data.FullIssuesReport =
IssuesParameters.OutputDirectory.CombineWithFilePath(reportFileName);
EnsureDirectoryExists(IssuesParameters.OutputDirectory);

// Create HTML report using DevExpress template.
Expand All @@ -99,6 +105,7 @@ IssuesBuildTasks.CreateFullIssuesReportTask = Task("Create-FullIssuesReport")

IssuesBuildTasks.PublishIssuesArtifactsTask = Task("Publish-IssuesArtifacts")
.Description("Publish issue artifacts to build server.")
.WithCriteria(() => !BuildSystem.IsLocalBuild, "Not running on build server")
.IsDependentOn("Create-FullIssuesReport")
.Does<IssuesData>((data) =>
{
Expand All @@ -111,8 +118,25 @@ IssuesBuildTasks.PublishIssuesArtifactsTask = Task("Publish-IssuesArtifacts")
data.BuildServer.PublishIssuesArtifacts(Context, data);
});

IssuesBuildTasks.ReportIssuesToBuildServerTask = Task("Report-IssuesToBuildServer")
.Description("Report issues to build server.")
.WithCriteria(() => !BuildSystem.IsLocalBuild, "Not running on build server")
.WithCriteria(() => IssuesParameters.BuildServer.ShouldReportIssuesToBuildServer, "Reporting of issues to build server is disabled")
.IsDependentOn("Read-Issues")
.Does<IssuesData>((data) =>
{
if (data.BuildServer == null)
{
Information("Not supported build server.");
return;
}

data.BuildServer.ReportIssuesToBuildServer(Context, data);
});

IssuesBuildTasks.CreateSummaryIssuesReportTask = Task("Create-SummaryIssuesReport")
.Description("Creates a summary issue report.")
.WithCriteria(() => !BuildSystem.IsLocalBuild, "Not running on build server")
.WithCriteria(() => IssuesParameters.BuildServer.ShouldCreateSummaryIssuesReport, "Creating of summary issues report is disabled")
.IsDependentOn("Read-Issues")
.Does<IssuesData>((data) =>
Expand All @@ -128,6 +152,7 @@ IssuesBuildTasks.CreateSummaryIssuesReportTask = Task("Create-SummaryIssuesRepor

IssuesBuildTasks.ReportIssuesToPullRequestTask = Task("Report-IssuesToPullRequest")
.Description("Report issues to pull request.")
.WithCriteria(() => !BuildSystem.IsLocalBuild, "Not running on build server")
.WithCriteria(() => IssuesParameters.PullRequestSystem.ShouldReportIssuesToPullRequest, "Reporting of issues to pull requests is disabled")
.WithCriteria<IssuesData>((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build")
.IsDependentOn("Read-Issues")
Expand All @@ -144,6 +169,7 @@ IssuesBuildTasks.ReportIssuesToPullRequestTask = Task("Report-IssuesToPullReques

IssuesBuildTasks.SetPullRequestIssuesStateTask = Task("Set-PullRequestIssuesState")
.Description("Set pull request status.")
.WithCriteria(() => !BuildSystem.IsLocalBuild, "Not running on build server")
.WithCriteria(() => IssuesParameters.PullRequestSystem.ShouldSetPullRequestStatus, "Setting of pull request status is disabled")
.WithCriteria<IssuesData>((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build")
.IsDependentOn("Read-Issues")
Expand Down
5 changes: 5 additions & 0 deletions Cake.Issues.Recipe/Content/data/IssuesData.cake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public class IssuesData
return new AzureDevOpsBuildServer();
}

if (context.AppVeyor().IsRunningOnAppVeyor)
{
return new AppVeyorBuildServer();
}

return null;
}

Expand Down
8 changes: 8 additions & 0 deletions Cake.Issues.Recipe/Content/parameters/IssuesParameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ public static class IssuesParameters
/// </summary>
public static DirectoryPath OutputDirectory { get; set; } = "BuildArtifacts";

/// <summary>
/// Gets or sets a identifier for the build run.
/// If set this identifier will be used to identify to artifacts provided by the
/// build if building on multiple configurations.
/// Default value is <c>string.Empty</c>.
/// </summary>
public static string BuildIdentifier { get; set; } = string.Empty;

/// <summary>
/// Gets the parameters for the input files.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
/// </summary>
public class IssuesParametersBuildServer
{
/// <summary>
/// Gets or sets a value indicating whether issues should be reported to the build server.
/// Default value is <c>true</c>.
/// </summary>
public bool ShouldReportIssuesToBuildServer { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether full issues report should be published as artifact to the build system.
/// Default value is <c>true</c>.
Expand Down
108 changes: 108 additions & 0 deletions Cake.Issues.Recipe/Content/tasks/buildservers/AppVeyorBuildServer.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/// <summary>
/// Support for AppVeyor builds.
/// </summary>
public class AppVeyorBuildServer : BaseBuildServer
{
/// <inheritdoc />
public override Uri DetermineRepositoryRemoteUrl(
ICakeContext context,
DirectoryPath repositoryRootDirectory)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

switch(context.AppVeyor().Environment.Repository.Provider)
{
case "bitBucket": return new System.Uri($"https://bitbucket.org/{context.AppVeyor().Environment.Repository.Name}/src");
case "gitHub": return new System.Uri($"https://github.com/{context.AppVeyor().Environment.Repository.Name}.git");
case "gitLab": return new System.Uri($"https://gitlab.com/{context.AppVeyor().Environment.Repository.Name}.git");
case "vso": return new System.Uri($"https://dev.azure.com/{context.AppVeyor().Environment.Repository.Name}");
default: return new System.Uri(context.AppVeyor().Environment.Repository.Name);
}
}

/// <inheritdoc />
public override bool DetermineIfPullRequest(ICakeContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

return context.AppVeyor().Environment.PullRequest.IsPullRequest;
}

/// <inheritdoc />
public override int? DeterminePullRequestId(ICakeContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

return context.AppVeyor().Environment.PullRequest.Number;
}

/// <inheritdoc />
public override void ReportIssuesToBuildServer(
ICakeContext context,
IssuesData data)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

if (data == null)
{
throw new ArgumentNullException(nameof(data));
}

context.ReportIssuesToPullRequest(
data.Issues,
context.AppVeyorBuilds(),
data.RepositoryRootDirectory);
}

/// <inheritdoc />
public override void CreateSummaryIssuesReport(
ICakeContext context,
IssuesData data,
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "")
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

if (data == null)
{
throw new ArgumentNullException(nameof(data));
}

// Summary issues report is not supported for AppVeyor.
}

/// <inheritdoc />
public override void PublishIssuesArtifacts(ICakeContext context, IssuesData data)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

if (data == null)
{
throw new ArgumentNullException(nameof(data));
}

if (IssuesParameters.BuildServer.ShouldPublishFullIssuesReport &&
data.FullIssuesReport != null &&
context.FileExists(data.FullIssuesReport))
{
context.AppVeyor().UploadArtifact(data.FullIssuesReport);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public class AzureDevOpsBuildServer : BaseBuildServer
}
}

/// <inheritdoc />
public override void ReportIssuesToBuildServer(
ICakeContext context,
IssuesData data)
{
// Not implemented for Azure DevOps
}

/// <inheritdoc />
public override void CreateSummaryIssuesReport(
Expand All @@ -63,17 +70,23 @@ public class AzureDevOpsBuildServer : BaseBuildServer
throw new ArgumentNullException(nameof(data));
}

var summaryFile = IssuesParameters.OutputDirectory.CombineWithFilePath("summary.md");
var summaryFileName = "summary";
if (!string.IsNullOrWhiteSpace(IssuesParameters.BuildIdentifier))
{
summaryFileName += $"-{IssuesParameters.BuildIdentifier}";
}
summaryFileName += ".md";
var summaryFilePath = IssuesParameters.OutputDirectory.CombineWithFilePath(summaryFileName);

// Create summary for Azure Pipelines using custom template.
context.CreateIssueReport(
data.Issues,
context.GenericIssueReportFormatFromFilePath(
new FilePath(sourceFilePath).GetDirectory().Combine("tasks").Combine("buildservers").CombineWithFilePath("AzurePipelineSummary.cshtml")),
data.RepositoryRootDirectory,
summaryFile);
summaryFilePath);

context.TFBuild().Commands.UploadTaskSummary(summaryFile);
context.TFBuild().Commands.UploadTaskSummary(summaryFilePath);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ There are @Model.Count() issues in the code.
@issue.Rule;
}
</td>
<td>@issue.Message</td>
<td>@issue.Message(IssueCommentFormat.Html)</td>
</tr>
}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public abstract class BaseBuildServer : IIssuesBuildServer
return null;
}

/// <inheritdoc />
public abstract void ReportIssuesToBuildServer(
ICakeContext context,
IssuesData data);

/// <inheritdoc />
public abstract void CreateSummaryIssuesReport(
ICakeContext context,
Expand Down
Loading

0 comments on commit 9823ed8

Please sign in to comment.