Skip to content

Commit

Permalink
Merge branch 'release/0.8.0'
Browse files Browse the repository at this point in the history
* release/0.8.0:
  (#50) Add consistency to skip reasons
  (#50) Use specific conditions in WithCriteria
  (#49) Remove criteria on testing tasks
  • Loading branch information
gep13 committed May 5, 2022
2 parents eb373d9 + ef641f7 commit 9125bbc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 53 deletions.
16 changes: 10 additions & 6 deletions Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ BuildParameters.Tasks.CreateReleaseNotesTask = Task("Create-Release-Notes")
);

BuildParameters.Tasks.ExportReleaseNotesTask = Task("Export-Release-Notes")
.WithCriteria(() => BuildParameters.ShouldDownloadMilestoneReleaseNotes || BuildParameters.ShouldDownloadFullReleaseNotes, "Exporting Release notes has been disabled")
.WithCriteria(() => !BuildParameters.IsLocalBuild || BuildParameters.PrepareLocalRelease, "Is local build, and is not preparing local release")
.WithCriteria(() => !BuildParameters.IsPullRequest || BuildParameters.PrepareLocalRelease, "Is pull request, and is not preparing local release")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix || BuildParameters.PrepareLocalRelease, "Is not a releasable branch, and is not preparing local release")
.WithCriteria(() => BuildParameters.IsTagged || BuildParameters.PrepareLocalRelease, "Is not a tagged build, and is not preparing local release")
.WithCriteria(() => BuildParameters.ShouldDownloadMilestoneReleaseNotes || BuildParameters.ShouldDownloadFullReleaseNotes, "Skipping because exporting Release notes has been disabled")
.WithCriteria(() => !BuildParameters.IsLocalBuild || BuildParameters.PrepareLocalRelease, "Skipping because this is local build, and is not preparing local release")
.WithCriteria(() => !BuildParameters.IsPullRequest || BuildParameters.PrepareLocalRelease, "Skipping because this is pull request, and is not preparing local release")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix || BuildParameters.PrepareLocalRelease, "Skipping because this is not a releasable branch, and is not preparing local release")
.WithCriteria(() => BuildParameters.IsTagged || BuildParameters.PrepareLocalRelease, "Skipping because this is not a tagged build, and is not preparing local release")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
{
Expand Down Expand Up @@ -60,7 +60,11 @@ BuildParameters.Tasks.ExportReleaseNotesTask = Task("Export-Release-Notes")

BuildParameters.Tasks.PublishGitHubReleaseTask = Task("Publish-GitHub-Release")
.IsDependentOn("Package")
.WithCriteria(() => BuildParameters.ShouldPublishGitHub)
.WithCriteria(() => !BuildParameters.IsLocalBuild, "Skipping because this is a local build")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because this is pull request")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix, "Skipping because this is not a releasable branch")
.WithCriteria(() => BuildParameters.IsTagged, "Skipping because this is not a tagged build")
.WithCriteria(() => BuildParameters.ShouldPublishGitHub, "Skipping because this publishing GitHub Release is disabled via parameters (perhaps the default value?")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
{
Expand Down
4 changes: 2 additions & 2 deletions Chocolatey.Cake.Recipe/Content/packages.cake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BuildParameters.Tasks.CreateNuGetPackagesTask = Task("Create-NuGet-Packages")
.IsDependentOn("Clean")
.IsDependentOn("Copy-Nuspec-Folders")
.WithCriteria(() => BuildParameters.ShouldRunNuGet, "Skipping because execution of NuGet has been disabled")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.NuGetNuspecDirectory), "NuGet nuspec directory does not exist")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.NuGetNuspecDirectory), "Skipping because NuGet nuspec directory does not exist")
.Does(() =>
{
var nuspecFiles = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/**/*.nuspec");
Expand Down Expand Up @@ -97,7 +97,7 @@ BuildParameters.Tasks.CreateNuGetPackagesTask = Task("Create-NuGet-Packages")

BuildParameters.Tasks.DotNetCorePackTask = Task("DotNetCorePack")
.IsDependentOn("DotNetCoreBuild")
.WithCriteria(() => BuildParameters.ShouldRunDotNetCorePack, "Packaging through .NET Core is disabled")
.WithCriteria(() => BuildParameters.ShouldRunDotNetCorePack, "Skipping because packaging through .NET Core is disabled")
.Does(() =>
{
var projects = GetFiles(BuildParameters.SourceDirectoryPath + "/**/*.csproj")
Expand Down
30 changes: 1 addition & 29 deletions Chocolatey.Cake.Recipe/Content/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,6 @@ public static class BuildParameters
}
}

public static bool CanPullTranslations
{
get
{
return TransifexEnabled &&
Transifex.HasCredentials &&
!IsPullRequest &&
(!IsLocalBuild || string.Equals(BuildParameters.Target, "Transifex-Pull-Translations", StringComparison.OrdinalIgnoreCase));
}
}

public static bool CanPushTranslations
{
get
{
return TransifexEnabled &&
Transifex.HasCredentials &&
!IsPullRequest &&
(!IsLocalBuild || string.Equals(BuildParameters.Target, "Transifex-Push-SourceFiles", StringComparison.OrdinalIgnoreCase));
}
}

public static void SetBuildVersion(BuildVersion version)
{
Version = version;
Expand Down Expand Up @@ -199,8 +177,6 @@ public static class BuildParameters
context.Information("UseChocolateyGuiStrongNameKey: {0}", UseChocolateyGuiStrongNameKey);
context.Information("AllowedAssemblyName: {0}", string.Join(", ", AllowedAssemblyNames));
context.Information("TransifexEnabled: {0}", TransifexEnabled);
context.Information("CanPullTranslations: {0}", CanPullTranslations);
context.Information("CanPushTranslations: {0}", CanPushTranslations);
context.Information("PreferDotNetGlobalToolUsage: {0}", PreferDotNetGlobalToolUsage);

if (TransifexEnabled)
Expand Down Expand Up @@ -496,11 +472,7 @@ public static class BuildParameters
ShouldDownloadFullReleaseNotes = shouldDownloadFullReleaseNotes;
ShouldDownloadMilestoneReleaseNotes = shouldDownloadMilestoneReleaseNotes;

ShouldPublishGitHub = (!IsLocalBuild &&
!IsPullRequest &&
(BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix) &&
IsTagged &&
shouldPublishGitHub);
ShouldPublishGitHub = shouldPublishGitHub;

if (packageSourceDatas?.Any() ?? false)
{
Expand Down
14 changes: 3 additions & 11 deletions Chocolatey.Cake.Recipe/Content/testing.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ using System.Xml.XPath;
///////////////////////////////////////////////////////////////////////////////

BuildParameters.Tasks.InstallOpenCoverTask = Task("Install-OpenCover")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Not running on windows")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on windows")
.Does(() => RequireTool(ToolSettings.OpenCoverTool, () => {
}));

BuildParameters.Tasks.TestNUnitTask = Task("Test-NUnit")
.IsDependentOn("Install-OpenCover")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.PublishedNUnitTests), "No published NUnit tests")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.PublishedNUnitTests), "Skipping because there are no published NUnit tests")
.Does(() => RequireTool(ToolSettings.NUnitTool, () => {
EnsureDirectoryExists(BuildParameters.Paths.Directories.NUnitTestResults);

Expand All @@ -40,8 +38,7 @@ BuildParameters.Tasks.TestNUnitTask = Task("Test-NUnit")

BuildParameters.Tasks.TestxUnitTask = Task("Test-xUnit")
.IsDependentOn("Install-OpenCover")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.PublishedxUnitTests), "No published xUnit tests")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.PublishedxUnitTests), "Skipping because there are no published xUnit tests")
.Does(() => RequireTool(ToolSettings.XUnitTool, () => {
EnsureDirectoryExists(BuildParameters.Paths.Directories.xUnitTestResults);

Expand All @@ -68,7 +65,6 @@ BuildParameters.Tasks.TestxUnitTask = Task("Test-xUnit")
);

BuildParameters.Tasks.DotNetCoreTestTask = Task("DotNetCoreTest")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.IsDependentOn("Install-OpenCover")
.Does(() => {

Expand Down Expand Up @@ -183,7 +179,6 @@ BuildParameters.Tasks.DotNetCoreTestTask = Task("DotNetCoreTest")
BuildParameters.Tasks.GenerateFriendlyTestReportTask = Task("Generate-FriendlyTestReport")
.IsDependentOn("Test-NUnit")
.IsDependentOn("Test-xUnit")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows")
.Does(() => RequireTool(ToolSettings.ReportUnitTool, () =>
{
Expand All @@ -200,7 +195,6 @@ BuildParameters.Tasks.GenerateFriendlyTestReportTask = Task("Generate-FriendlyTe
);

BuildParameters.Tasks.ReportUnitTestResultsTask = Task("Report-UnitTestResults")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildSystem.IsRunningOnTeamCity, "Skipping due to not running on TeamCity")
.Does(() => {
Information("Reporting Unit Test results to TeamCity if any exist...");
Expand All @@ -218,7 +212,6 @@ BuildParameters.Tasks.ReportUnitTestResultsTask = Task("Report-UnitTestResults")
});

BuildParameters.Tasks.ReportCodeCoverageMetricsTask = Task("Report-Code-Coverage-Metrics")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildSystem.IsRunningOnTeamCity, "Skipping due to not running on TeamCity")
.Does(() => {
var coverageFiles = GetFiles(BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml");
Expand Down Expand Up @@ -301,7 +294,6 @@ private void ReportCoverageMetric(
}

BuildParameters.Tasks.GenerateLocalCoverageReportTask = Task("Generate-LocalCoverageReport")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildParameters.IsLocalBuild, "Skipping due to not running a local build")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.ReportGeneratorGlobalTool : ToolSettings.ReportGeneratorTool, () => {
var coverageFiles = GetFiles(BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml");
Expand Down
16 changes: 11 additions & 5 deletions Chocolatey.Cake.Recipe/Content/transifex.cake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public static bool TransifexIsConfiguredForRepository(ICakeContext context)
// Because we expect the repository to already be configured to use
// transifex, we cannot run tx init, or it would replace the repository configuration file.
BuildParameters.Tasks.TransifexSetupTask = Task("Transifex-Setup")
.WithCriteria(() => BuildParameters.TransifexEnabled, "Transifex is not enabled")
.WithCriteria(() => !TransifexUserSettingsExists(Context), "Transifex user settings already exist")
.WithCriteria(() => BuildParameters.Transifex.HasCredentials, "Missing transifex credentials")
.WithCriteria(() => BuildParameters.TransifexEnabled, "Skipping because Transifex is not enabled")
.WithCriteria(() => !TransifexUserSettingsExists(Context), "Skipping because Transifex user settings already exist")
.WithCriteria(() => BuildParameters.Transifex.HasCredentials, "Skipping because the Transifex credentials are missing")
.Does(() =>
{
var path = GetTransifexUserSettingsPath();
Expand All @@ -32,7 +32,10 @@ BuildParameters.Tasks.TransifexSetupTask = Task("Transifex-Setup")
});

BuildParameters.Tasks.TransifexPushSourceResourceTask = Task("Transifex-Push-SourceFiles")
.WithCriteria(() => BuildParameters.CanPushTranslations)
.WithCriteria(() => BuildParameters.TransifexEnabled, "Skipping because Transifex is not enabled")
.WithCriteria(() => BuildParameters.Transifex.HasCredentials, "Skipping because the Transifex credentials are missing")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because current build is from a Pull Request")
.WithCriteria(() => !BuildParameters.IsLocalBuild || string.Equals(BuildParameters.Target, "Transifex-Push-Translations", StringComparison.OrdinalIgnoreCase), "Skipping because this is a local build, and target name is not Transifex-Push-Translations")
.IsDependentOn("Transifex-Setup")
.Does(() =>
{
Expand All @@ -43,7 +46,10 @@ BuildParameters.Tasks.TransifexPushSourceResourceTask = Task("Transifex-Push-Sou
});

BuildParameters.Tasks.TransifexPullTranslationsTask = Task("Transifex-Pull-Translations")
.WithCriteria(() => BuildParameters.CanPullTranslations)
.WithCriteria(() => BuildParameters.TransifexEnabled, "Skipping because Transifex is not enabled")
.WithCriteria(() => BuildParameters.Transifex.HasCredentials, "Skipping because the Transifex credentials are missing")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because current build is from a Pull Request")
.WithCriteria(() => !BuildParameters.IsLocalBuild || string.Equals(BuildParameters.Target, "Transifex-Pull-Translations", StringComparison.OrdinalIgnoreCase), "Skipping because this is a local build, and target name is not Transifex-Pull-Translations")
.IsDependentOn("Transifex-Push-SourceFiles")
.Does(() =>
{
Expand Down

0 comments on commit 9125bbc

Please sign in to comment.