Skip to content

Commit

Permalink
Merge branch 'release/0.25.0'
Browse files Browse the repository at this point in the history
* release/0.25.0:
  (#110) Change logic for SonarQube/DependencyCheck
  (maint) synced local '.templates/' with remote '.github/GitReleaseManager/.templates/'
  (maint) Make indentation consistent
  (maint) synced local '.templates/' with remote '.github/GitReleaseManager/.templates/'
  (maint) Make GRM config match template
  (#120) Add ability to run dotnet-format
  (maint) Remove unnecessary parameters
  (#110) Be explicit about when tasks should run
  (#110) Convert FilePath to string
  (#110) Add missing properties to class
  (#110) Use path parameters for report locations
  (#110) Add optional Dependency-Check Step
  (maint) formatting
  (#119) Change dependencies are run time
  • Loading branch information
gep13 committed Oct 3, 2023
2 parents 3210c4d + 9e1a5be commit 2017b5d
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 41 deletions.
7 changes: 6 additions & 1 deletion .templates/default/issue-note.sbn
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
- {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}).
{{
if issue_label == "Bug" || issue_label == "Bug Fix" || issue_label == "Bug Fixes"
}}- Fix - {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}).
{{ else
}}- {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}).
{{ end -}}
1 change: 1 addition & 0 deletions Chocolatey.Cake.Recipe/Content/addins.cake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
///////////////////////////////////////////////////////////////////////////////

#addin nuget:?package=Cake.Coverlet&version=2.5.4
#addin nuget:?package=Cake.DependencyCheck&version=1.2.0
#addin nuget:?package=Cake.Discord&version=0.2.1
#addin nuget:?package=Cake.Docker&version=1.0.0
#addin nuget:?package=Cake.Eazfuscator.Net&version=0.1.0
Expand Down
29 changes: 29 additions & 0 deletions Chocolatey.Cake.Recipe/Content/analyzing.cake
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,36 @@ BuildParameters.Tasks.CreateIssuesReportTask = Task("CreateIssuesReport")
}
});

BuildParameters.Tasks.DotNetFormatCheckTask = Task("Run-DotNetFormatCheck")
.WithCriteria(() => BuildParameters.ShouldRunDotNetFormat, "Skipping because DotNetFormat has been disabled")
.WithCriteria(() => BuildParameters.ShouldRunAnalyze, "Skipping because running analysis tasks is not enabled")
.Does(() => RequireTool(ToolSettings.DotNetFormatGlobalTool, () =>
{
var dotNetFormatTool = Context.Tools.Resolve("dotnet-format.exe");
if (dotNetFormatTool == null)
{
dotNetFormatTool = Context.Tools.Resolve("dotnet-format");
}

StartProcess(dotNetFormatTool, new ProcessSettings{ Arguments = string.Format("{0} --report {1} --check --no-restore", MakeAbsolute(BuildParameters.SolutionFilePath), MakeAbsolute(BuildParameters.Paths.Files.DotNetFormatOutputFilePath)) });
})
);

BuildParameters.Tasks.DotNetFormatTask = Task("Run-DotNetFormat")
.Does(() => RequireTool(ToolSettings.DotNetFormatGlobalTool, () =>
{
var dotNetFormatTool = Context.Tools.Resolve("dotnet-format.exe");
if (dotNetFormatTool == null)
{
dotNetFormatTool = Context.Tools.Resolve("dotnet-format");
}

StartProcess(dotNetFormatTool, new ProcessSettings{ Arguments = string.Format("{0} --report {1} --no-restore", MakeAbsolute(BuildParameters.SolutionFilePath), MakeAbsolute(BuildParameters.Paths.Files.DotNetFormatOutputFilePath)) });
})
);

BuildParameters.Tasks.AnalyzeTask = Task("Analyze")
.IsDependentOn("InspectCode")
.IsDependentOn("Run-DotNetFormatCheck")
.IsDependentOn("CreateIssuesReport")
.WithCriteria(() => BuildParameters.ShouldRunAnalyze, "Skipping because running analysis tasks is not enabled");
57 changes: 57 additions & 0 deletions Chocolatey.Cake.Recipe/Content/dependencyCheck.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright © 2023 Chocolatey Software, Inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

BuildParameters.Tasks.DependencyCheckTask = Task("Dependency-Check")
.WithCriteria(() => BuildParameters.ShouldRunDependencyCheck, "Skipping because DependencyCheck has been disabled")
.WithCriteria(() => BuildParameters.ShouldRunSonarQube, "Skipping because running SonarQube has been disabled")
.WithCriteria(() => !string.IsNullOrEmpty(BuildParameters.SonarQubeToken), "Skipping because SonarQube Token is undefined")
.IsDependentOn("Initialize-SonarQube")
.IsDependeeOf("Finalise-SonarQube")
.Does(() => RequireTool(ToolSettings.DependencyCheckTool, () =>
{
DownloadFile(
"https://github.com/jeremylong/DependencyCheck/releases/download/v8.2.1/dependency-check-8.2.1-release.zip",
BuildParameters.RootDirectoryPath.CombineWithFilePath("dependency-check.zip")
);

Unzip(
BuildParameters.RootDirectoryPath.CombineWithFilePath("dependency-check.zip"),
BuildParameters.RootDirectoryPath.FullPath
);

CopyDirectory(
BuildParameters.RootDirectoryPath.Combine("dependency-check"),
BuildParameters.RootDirectoryPath.Combine("tools/DependencyCheck.Runner.Tool.3.2.1/tools")
);

DeleteDirectory(
BuildParameters.RootDirectoryPath.Combine("dependency-check"),
new DeleteDirectorySettings {
Recursive = true,
Force = true
}
);

DeleteFile(BuildParameters.RootDirectoryPath.CombineWithFilePath("dependency-check.zip"));

var DependencyCheckSettings = new DependencyCheckSettings {
Project = BuildParameters.ProductName,
Scan = BuildParameters.SourceDirectoryPath.FullPath,
Format = "ALL",
Out = BuildParameters.Paths.Directories.DependencyCheckReports.FullPath
};

DependencyCheck(DependencyCheckSettings);
}));
37 changes: 24 additions & 13 deletions Chocolatey.Cake.Recipe/Content/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum BranchType

public static class BuildParameters
{
private static Func<BuildVersion, object[]> _defaultNotificationArguments = (x) =>
private static Func<BuildVersion, object[]> _defaultNotificationArguments = (x) =>
{
var firstPortionOfQueryString = string.Empty;

Expand Down Expand Up @@ -115,8 +115,6 @@ public static class BuildParameters
public static bool IsLocalBuild { get; private set; }
public static bool IsPullRequest { get; private set; }
public static bool IsRepositoryHostedOnGitHub { get; private set; }
public static bool IsRunningOnGitHubActions { get; private set; }
public static bool IsRunningOnTeamCity { get; private set; }
public static bool IsTagged { get; private set; }
public static string MasterBranchName { get; private set; }
public static MastodonCredentials Mastodon { get; private set; }
Expand Down Expand Up @@ -165,7 +163,9 @@ public static class BuildParameters
public static bool ShouldReportUnitTestResults { get; private set; }
public static bool ShouldRunAnalyze { get; private set; }
public static bool ShouldRunChocolatey { get; private set; }
public static bool ShouldRunDependencyCheck { get; private set; }
public static bool ShouldRunDocker { get; private set; }
public static bool ShouldRunDotNetFormat { get; private set; }
public static bool ShouldRunDotNetPack { get; private set; }
public static bool ShouldRunDotNetTest { get; private set; }
public static bool ShouldRunGitReleaseManager { get; private set; }
Expand Down Expand Up @@ -295,7 +295,9 @@ public static class BuildParameters
context.Information("ShouldReportUnitTestResults: {0}", BuildParameters.ShouldReportUnitTestResults);
context.Information("ShouldRunAnalyze: {0}", BuildParameters.ShouldRunAnalyze);
context.Information("ShouldRunChocolatey: {0}", BuildParameters.ShouldRunChocolatey);
context.Information("ShouldRunDependencyCheck: {0}", BuildParameters.ShouldRunDependencyCheck);
context.Information("ShouldRunDocker: {0}", BuildParameters.ShouldRunDocker);
context.Information("ShouldRunDotNetFormat: {0}", BuildParameters.ShouldRunDotNetFormat);
context.Information("ShouldRunDotNetPack: {0}", BuildParameters.ShouldRunDotNetPack);
context.Information("ShouldRunDotNetTest: {0}", BuildParameters.ShouldRunDotNetTest);
context.Information("ShouldRunGitReleaseManager: {0}", BuildParameters.ShouldRunGitReleaseManager);
Expand Down Expand Up @@ -401,7 +403,9 @@ public static class BuildParameters
bool shouldReportUnitTestResults = true,
bool shouldRunAnalyze = true,
bool shouldRunChocolatey = true,
bool shouldRunDependencyCheck = false,
bool shouldRunDocker = true,
bool shouldRunDotNetFormat = true,
bool shouldRunDotNetPack = false,
bool shouldRunDotNetTest = true,
bool shouldRunGitReleaseManager = false,
Expand Down Expand Up @@ -490,8 +494,6 @@ public static class BuildParameters
IntegrationTestScriptPath = integrationTestScriptPath ?? context.MakeAbsolute((FilePath)"test.cake");
IsLocalBuild = buildSystem.IsLocalBuild;
IsPullRequest = BuildProvider.PullRequest.IsPullRequest;
IsRunningOnGitHubActions = BuildProvider.Type == BuildProviderType.GitHubActions;
IsRunningOnTeamCity = BuildProvider.Type == BuildProviderType.TeamCity;
IsTagged = BuildProvider.Repository.Tag.IsTag;
MasterBranchName = masterBranchName;
Mastodon = GetMastodonCredentials(context);
Expand Down Expand Up @@ -623,7 +625,7 @@ public static class BuildParameters
}

ShouldPublishReleasePackages = shouldPublishReleasePackages;

if (context.HasArgument("shouldPublishReleasePackages"))
{
ShouldPublishReleasePackages = context.Argument<bool>("shouldPublishReleasePackages");
Expand Down Expand Up @@ -657,13 +659,27 @@ public static class BuildParameters
ShouldRunChocolatey = context.Argument<bool>("shouldRunChocolatey");
}

ShouldRunDependencyCheck = shouldRunDependencyCheck;

if (context.HasArgument("shouldRunDependencyCheck"))
{
ShouldRunDependencyCheck = context.Argument<bool>("shouldRunDependencyCheck");
}

ShouldRunDocker = shouldRunDocker;

if (context.HasArgument("shouldRunDocker"))
{
ShouldRunDocker = context.Argument<bool>("shouldRunDocker");
}

ShouldRunDotNetFormat = shouldRunDotNetFormat;

if (context.HasArgument("shouldRunDotNetFormat"))
{
ShouldRunDotNetFormat = context.Argument<bool>("shouldRunDotNetFormat");
}

ShouldRunDotNetPack = shouldRunDotNetPack;

if (context.HasArgument("shouldRunDotNetPack"))
Expand Down Expand Up @@ -741,17 +757,12 @@ public static class BuildParameters
ShouldRunReportUnit = context.Argument<bool>("shouldRunReportUnit");
}

ShouldRunSonarQube = shouldRunSonarQube;

if (context.HasArgument("shouldRunSonarQube"))
{
ShouldRunSonarQube = context.Argument<bool>("shouldRunSonarQube");
}
else
{
if (BuildParameters.IsTagged && !BuildParameters.IsLocalBuild)
{
ShouldRunSonarQube = true;
}
}

ShouldRunTests = shouldRunTests;

Expand Down
31 changes: 27 additions & 4 deletions Chocolatey.Cake.Recipe/Content/paths.cake
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ public class BuildPaths
var nuGetPackagesOutputDirectory = packagesDirectory + "/NuGet";
var chocolateyPackagesOutputDirectory = packagesDirectory + "/Chocolatey";

var dependencyCheckReportsDirectory = buildDirectoryPath + "/DependencyCheckReports";

// Files
var dotNetFormatOutputFilePath = ((DirectoryPath)testResultsDirectory).CombineWithFilePath("dotnet-format.json");
var testCoverageOutputFilePath = ((DirectoryPath)testCoverageDirectory).CombineWithFilePath("OpenCover.xml");
var solutionInfoFilePath = ((DirectoryPath)BuildParameters.SourceDirectoryPath).CombineWithFilePath("SolutionVersion.cs");
var buildLogFilePath = ((DirectoryPath)buildDirectoryPath).CombineWithFilePath("MsBuild.log");
var dependencyCheckJsonReportFilePath = ((DirectoryPath)dependencyCheckReportsDirectory).CombineWithFilePath("dependency-check-report.json");
var dependencyCheckHtmlReportFilePath = ((DirectoryPath)dependencyCheckReportsDirectory).CombineWithFilePath("dependency-check-report.html");

var repoFilesPaths = new FilePath[] {
"LICENSE",
Expand All @@ -76,14 +81,18 @@ public class BuildPaths
nuGetPackagesOutputDirectory,
chocolateyPackagesOutputDirectory,
packagesDirectory,
environmentSettingsDirectory
environmentSettingsDirectory,
dependencyCheckReportsDirectory
);

var buildFiles = new BuildFiles(
repoFilesPaths,
dotNetFormatOutputFilePath,
testCoverageOutputFilePath,
solutionInfoFilePath,
buildLogFilePath
buildLogFilePath,
dependencyCheckJsonReportFilePath,
dependencyCheckHtmlReportFilePath
);

return new BuildPaths
Expand All @@ -98,23 +107,34 @@ public class BuildFiles
{
public ICollection<FilePath> RepoFilesPaths { get; private set; }

public FilePath DotNetFormatOutputFilePath { get; private set; }
public FilePath TestCoverageOutputFilePath { get; private set; }

public FilePath SolutionInfoFilePath { get; private set; }

public FilePath BuildLogFilePath { get; private set; }

public FilePath DependencyCheckJsonReportFilePath { get; private set; }

public FilePath DependencyCheckHtmlReportFilePath { get; private set; }

public BuildFiles(
FilePath[] repoFilesPaths,
FilePath dotNetFormatOutputFilePath,
FilePath testCoverageOutputFilePath,
FilePath solutionInfoFilePath,
FilePath buildLogFilePath
FilePath buildLogFilePath,
FilePath dependencyCheckJsonReportFilePath,
FilePath dependencyCheckHtmlReportFilePath
)
{
RepoFilesPaths = Filter(repoFilesPaths);
DotNetFormatOutputFilePath = dotNetFormatOutputFilePath;
TestCoverageOutputFilePath = testCoverageOutputFilePath;
SolutionInfoFilePath = solutionInfoFilePath;
BuildLogFilePath = buildLogFilePath;
DependencyCheckJsonReportFilePath = dependencyCheckJsonReportFilePath;
DependencyCheckHtmlReportFilePath = dependencyCheckHtmlReportFilePath;
}

private static FilePath[] Filter(FilePath[] files)
Expand Down Expand Up @@ -152,6 +172,7 @@ public class BuildDirectories
public DirectoryPath ChocolateyPackages { get; private set; }
public DirectoryPath Packages { get; private set; }
public DirectoryPath EnvironmentSettings { get; private set; }
public DirectoryPath DependencyCheckReports { get; private set; }
public ICollection<DirectoryPath> ToClean { get; private set; }

public BuildDirectories(
Expand All @@ -173,7 +194,8 @@ public class BuildDirectories
DirectoryPath nuGetPackages,
DirectoryPath chocolateyPackages,
DirectoryPath packages,
DirectoryPath environmentSettings
DirectoryPath environmentSettings,
DirectoryPath dependencyCheckReports
)
{
Build = build;
Expand All @@ -194,6 +216,7 @@ public class BuildDirectories
NuGetPackages = nuGetPackages;
ChocolateyPackages = chocolateyPackages;
EnvironmentSettings = environmentSettings;
DependencyCheckReports = dependencyCheckReports;
Packages = packages;

ToClean = new[] {
Expand Down
13 changes: 7 additions & 6 deletions Chocolatey.Cake.Recipe/Content/sign-powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,28 @@ Param(
[String]
$TimeStampServer,

[Parameter(ParameterSetName="File")]
[Parameter(ParameterSetName = "File")]
[String]
$CertificatePath,

[Parameter(ParameterSetName="File")]
[Parameter(ParameterSetName = "File")]
[String]
$CertificatePassword,

[Parameter()]
[String]
$CertificateAlgorithm,

[Parameter(ParameterSetName="Store")]
[Parameter(ParameterSetName = "Store")]
[String]
$CertificateSubjectName
)

$cert = if ($PSCmdlet.ParameterSetName -eq "File") {
New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertificatePath, $CertificatePassword)
} else {
Get-ChildItem Cert:\LocalMachine\My | Where-Object Subject -like "*$CertificateSubjectName*"
}
else {
Get-ChildItem Cert:\LocalMachine\My | Where-Object Subject -Like "*$CertificateSubjectName*"
}

Set-AuthenticodeSignature -Filepath $ScriptsToSign -Cert $cert -TimeStampServer $TimeStampServer -IncludeChain NotRoot -HashAlgorithm $CertificateAlgorithm
Set-AuthenticodeSignature -FilePath $ScriptsToSign -Cert $cert -TimestampServer $TimeStampServer -IncludeChain NotRoot -HashAlgorithm $CertificateAlgorithm
7 changes: 7 additions & 0 deletions Chocolatey.Cake.Recipe/Content/sonarqube.cake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ BuildParameters.Tasks.InitializeSonarQubeTask = Task("Initialize-SonarQube")
SonarQubeSettings.Url = BuildParameters.SonarQubeUrl;
};

if (BuildParameters.ShouldRunDependencyCheck)
{
SonarQubeSettings.ArgumentCustomization = args => args
.Append(string.Format("/d:sonar.dependencyCheck.jsonReportPath={0}", BuildParameters.Paths.Files.DependencyCheckJsonReportFilePath))
.Append(string.Format("/d:sonar.dependencyCheck.htmlReportPath={0}", BuildParameters.Paths.Files.DependencyCheckHtmlReportFilePath));
};

SonarBegin(SonarQubeSettings);
}));

Expand Down
5 changes: 5 additions & 0 deletions Chocolatey.Cake.Recipe/Content/tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ public class BuildTasks
// Analysing Tasks
public CakeTaskBuilder InspectCodeTask { get; set; }
public CakeTaskBuilder CreateIssuesReportTask { get; set; }
public CakeTaskBuilder DotNetFormatCheckTask { get; set; }
public CakeTaskBuilder DotNetFormatTask { get; set; }
public CakeTaskBuilder AnalyzeTask { get; set; }

// Dependency-Check Tasks
public CakeTaskBuilder DependencyCheckTask { get; set; }

// Docker Tasks
public CakeTaskBuilder DockerLogin { get; set; }
public CakeTaskBuilder DockerBuild { get; set; }
Expand Down
Loading

0 comments on commit 2017b5d

Please sign in to comment.