diff --git a/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake b/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake index 36f8024..175f3f0 100644 --- a/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake +++ b/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake @@ -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) { @@ -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) { diff --git a/Chocolatey.Cake.Recipe/Content/packages.cake b/Chocolatey.Cake.Recipe/Content/packages.cake index 8b87ba3..c8c5d79 100644 --- a/Chocolatey.Cake.Recipe/Content/packages.cake +++ b/Chocolatey.Cake.Recipe/Content/packages.cake @@ -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"); @@ -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") diff --git a/Chocolatey.Cake.Recipe/Content/parameters.cake b/Chocolatey.Cake.Recipe/Content/parameters.cake index 48fcae3..ace9ad1 100644 --- a/Chocolatey.Cake.Recipe/Content/parameters.cake +++ b/Chocolatey.Cake.Recipe/Content/parameters.cake @@ -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; @@ -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) @@ -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) { diff --git a/Chocolatey.Cake.Recipe/Content/testing.cake b/Chocolatey.Cake.Recipe/Content/testing.cake index 3665f39..d0d5553 100644 --- a/Chocolatey.Cake.Recipe/Content/testing.cake +++ b/Chocolatey.Cake.Recipe/Content/testing.cake @@ -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); @@ -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); @@ -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(() => { @@ -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, () => { @@ -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..."); @@ -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"); @@ -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"); diff --git a/Chocolatey.Cake.Recipe/Content/transifex.cake b/Chocolatey.Cake.Recipe/Content/transifex.cake index 82af630..bce386d 100644 --- a/Chocolatey.Cake.Recipe/Content/transifex.cake +++ b/Chocolatey.Cake.Recipe/Content/transifex.cake @@ -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(); @@ -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(() => { @@ -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(() => {