-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from RocketSurgeonsGuild/feature/latest-nuke
Updated to latest nuke version and other build chores
- Loading branch information
Showing
24 changed files
with
737 additions
and
202 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Nuke.Common.CI.GitHubActions; | ||
using Rocket.Surgery.Nuke; | ||
using Rocket.Surgery.Nuke.ContinuousIntegration; | ||
using Rocket.Surgery.Nuke.DotNetCore; | ||
using Rocket.Surgery.Nuke.GithubActions; | ||
|
||
[AzurePipelinesSteps( | ||
AutoGenerate = false, | ||
InvokeTargets = new[] { nameof(Default) }, | ||
NonEntryTargets = new[] | ||
{ | ||
nameof(ICIEnvironment.CIEnvironment), | ||
nameof(ITriggerCodeCoverageReports.Trigger_Code_Coverage_Reports), | ||
nameof(ITriggerCodeCoverageReports.Generate_Code_Coverage_Report_Cobertura), | ||
nameof(IGenerateCodeCoverageBadges.Generate_Code_Coverage_Badges), | ||
nameof(IGenerateCodeCoverageReport.Generate_Code_Coverage_Report), | ||
nameof(IGenerateCodeCoverageSummary.Generate_Code_Coverage_Summary), | ||
nameof(Default) | ||
}, | ||
ExcludedTargets = new[] | ||
{ nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.Restore), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) }, | ||
Parameters = new[] | ||
{ | ||
nameof(IHaveCodeCoverage.CoverageDirectory), nameof(IHaveOutputArtifacts.ArtifactsDirectory), nameof(Verbosity), | ||
nameof(IHaveConfiguration.Configuration) | ||
} | ||
)] | ||
[GitHubActionsSteps("ci", GitHubActionsImage.MacOsLatest, GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest, | ||
AutoGenerate = false, | ||
On = new[] { GitHubActionsTrigger.Push }, | ||
OnPushTags = new[] { "v*" }, | ||
OnPushBranches = new[] { "master", "next" }, | ||
OnPullRequestBranches = new[] { "master", "next" }, | ||
InvokedTargets = new[] { nameof(Default) }, | ||
NonEntryTargets = new[] | ||
{ | ||
nameof(ICIEnvironment.CIEnvironment), | ||
nameof(ITriggerCodeCoverageReports.Trigger_Code_Coverage_Reports), | ||
nameof(ITriggerCodeCoverageReports.Generate_Code_Coverage_Report_Cobertura), | ||
nameof(IGenerateCodeCoverageBadges.Generate_Code_Coverage_Badges), | ||
nameof(IGenerateCodeCoverageReport.Generate_Code_Coverage_Report), | ||
nameof(IGenerateCodeCoverageSummary.Generate_Code_Coverage_Summary), | ||
nameof(Default) | ||
}, | ||
ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) }, | ||
Enhancements = new[] { nameof(Middleware) } | ||
)] | ||
[PrintBuildVersion, PrintCIEnvironment, UploadLogs] | ||
public partial class Solution | ||
{ | ||
public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) | ||
{ | ||
var buildJob = configuration.Jobs.First(z => z.Name == "Build"); | ||
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single(); | ||
// For fetch all | ||
// checkoutStep.FetchDepth = 0; | ||
buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] { | ||
new RunStep("Fetch all history for all tags and branches") { | ||
Run = "git fetch --prune --unshallow" | ||
}, | ||
new SetupDotNetStep("Use .NET Core 2.1 SDK") { | ||
DotNetVersion = "2.1.x" | ||
}, | ||
new SetupDotNetStep("Use .NET Core 3.1 SDK") { | ||
DotNetVersion = "3.1.x" | ||
}, | ||
new RunStep("🪓 **DOTNET HACK** 🪓") { | ||
Shell = GithubActionShell.Pwsh, | ||
Run = @"$version = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Leaf; | ||
$root = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Parent; | ||
$directories = Get-ChildItem $root | Where-Object { $_.Name -ne $version }; | ||
foreach ($dir in $directories) { | ||
$from = $dir.FullName; | ||
$to = ""$root/$version""; | ||
Write-Host Copying from $from to $to; | ||
Copy-Item ""$from\*"" $to -Recurse -Force; | ||
} | ||
" | ||
}, | ||
}); | ||
|
||
buildJob.Steps.Add(new UsingStep("Publish Coverage") | ||
{ | ||
Uses = "codecov/codecov-action@v1", | ||
With = new Dictionary<string, string> | ||
{ | ||
["name"] = "actions-${{ matrix.os }}", | ||
["fail_ci_if_error"] = "true", | ||
} | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish logs") | ||
{ | ||
Name = "logs", | ||
Path = "artifacts/logs/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data") | ||
{ | ||
Name = "coverage", | ||
Path = "coverage/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish test data") | ||
{ | ||
Name = "test data", | ||
Path = "artifacts/test/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages") | ||
{ | ||
Name = "nuget", | ||
Path = "artifacts/nuget/", | ||
If = "always()" | ||
}); | ||
|
||
|
||
/* | ||
- publish: "${{ parameters.Artifacts }}/logs/" | ||
displayName: Publish Logs | ||
artifact: "Logs${{ parameters.Postfix }}" | ||
condition: always() | ||
- publish: ${{ parameters.Coverage }} | ||
displayName: Publish Coverage | ||
artifact: "Coverage${{ parameters.Postfix }}" | ||
condition: always() | ||
- publish: "${{ parameters.Artifacts }}/nuget/" | ||
displayName: Publish NuGet Artifacts | ||
artifact: "NuGet${{ parameters.Postfix }}" | ||
condition: always() | ||
*/ | ||
return configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,72 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Nuke.Common; | ||
using Nuke.Common.Execution; | ||
using Rocket.Surgery.Nuke.DotNetCore; | ||
using Nuke.Common.Git; | ||
using Nuke.Common.Tools.DotNet; | ||
using Nuke.Common.Tools.GitVersion; | ||
using Nuke.Common.Tools.MSBuild; | ||
using Rocket.Surgery.Nuke; | ||
using JetBrains.Annotations; | ||
using Rocket.Surgery.Nuke.DotNetCore; | ||
|
||
[PublicAPI] | ||
[CheckBuildProjectConfigurations] | ||
[UnsetVisualStudioEnvironmentVariables] | ||
[AzurePipelinesSteps( | ||
InvokedTargets = new[] { nameof(Default) }, | ||
NonEntryTargets = new[] { nameof(BuildVersion), nameof(Generate_Code_Coverage_Reports), nameof(Default) }, | ||
ExcludedTargets = new[] { nameof(Restore), nameof(DotnetToolRestore) }, | ||
Parameters = new[] { nameof(CoverageDirectory), nameof(ArtifactsDirectory), nameof(Verbosity), nameof(Configuration) } | ||
)] | ||
[PackageIcon("https://raw.githubusercontent.com/RocketSurgeonsGuild/graphics/master/png/social-square-thrust-rounded.png")] | ||
[EnsurePackageSourceHasCredentials("RocketSurgeonsGuild")] | ||
[EnsureGitHooks(GitHook.PreCommit)] | ||
class Solution : DotNetCoreBuild, IDotNetCoreBuild | ||
[DotNetVerbosityMapping] | ||
[MSBuildVerbosityMapping] | ||
[NuGetVerbosityMapping] | ||
public partial class Solution : NukeBuild, | ||
ICanRestoreWithDotNetCore, | ||
ICanBuildWithDotNetCore, | ||
ICanTestWithDotNetCore, | ||
ICanPackWithDotNetCore, | ||
IHaveDataCollector, | ||
ICanClean, | ||
ICanUpdateReadme, | ||
IGenerateCodeCoverageReport, | ||
IGenerateCodeCoverageSummary, | ||
IGenerateCodeCoverageBadges, | ||
IHaveConfiguration<Configuration>, | ||
ICanLint | ||
{ | ||
/// <summary> | ||
/// Support plugins are available for: | ||
/// - JetBrains ReSharper https://nuke.build/resharper | ||
/// - JetBrains Rider https://nuke.build/rider | ||
/// - Microsoft VisualStudio https://nuke.build/visualstudio | ||
/// - Microsoft VSCode https://nuke.build/vscode | ||
/// - JetBrains ReSharper https://nuke.build/resharper | ||
/// - JetBrains Rider https://nuke.build/rider | ||
/// - Microsoft VisualStudio https://nuke.build/visualstudio | ||
/// - Microsoft VSCode https://nuke.build/vscode | ||
/// </summary> | ||
|
||
public static int Main() => Execute<Solution>(x => x.Default); | ||
|
||
Target Default => _ => _ | ||
.DependsOn(Restore) | ||
.DependsOn(Build) | ||
.DependsOn(Test) | ||
.DependsOn(Pack) | ||
; | ||
[OptionalGitRepository] | ||
public GitRepository? GitRepository { get; } | ||
|
||
private Target Default => _ => _ | ||
.DependsOn(Restore) | ||
.DependsOn(Build) | ||
.DependsOn(Test) | ||
.DependsOn(Pack); | ||
|
||
public Target Build => _ => _.Inherit<ICanBuildWithDotNetCore>(x => x.CoreBuild); | ||
|
||
public Target Pack => _ => _.Inherit<ICanPackWithDotNetCore>(x => x.CorePack) | ||
.DependsOn(Clean); | ||
|
||
public new Target Restore => _ => _.With(this, DotNetCoreBuild.Restore); | ||
[ComputedGitVersion] | ||
public GitVersion GitVersion { get; } = null!; | ||
|
||
public new Target Build => _ => _.With(this, DotNetCoreBuild.Build); | ||
public Target Clean => _ => _.Inherit<ICanClean>(x => x.Clean); | ||
public Target Restore => _ => _.Inherit<ICanRestoreWithDotNetCore>(x => x.CoreRestore); | ||
public Target Test => _ => _.Inherit<ICanTestWithDotNetCore>(x => x.CoreTest); | ||
|
||
public new Target Test => _ => _.With(this, DotNetCoreBuild.Test); | ||
public Target BuildVersion => _ => _.Inherit<IHaveBuildVersion>(x => x.BuildVersion) | ||
.Before(Default) | ||
.Before(Clean); | ||
|
||
public new Target Pack => _ => _.With(this, DotNetCoreBuild.Pack); | ||
[Parameter("Configuration to build")] | ||
public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel; | ||
using Nuke.Common.Tooling; | ||
|
||
[TypeConverter(typeof(TypeConverter<Configuration>))] | ||
public class Configuration : Enumeration | ||
{ | ||
public static readonly Configuration Debug = new Configuration { Value = nameof(Debug) }; | ||
public static readonly Configuration Release = new Configuration { Value = nameof(Release) }; | ||
|
||
public static implicit operator string(Configuration configuration) => configuration.Value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.