Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to latest nuke version and other build chores #113

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions .automerge.yml

This file was deleted.

142 changes: 142 additions & 0 deletions .build/Build.CI.cs
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;
}
}
77 changes: 52 additions & 25 deletions .build/Build.cs
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;
}
11 changes: 11 additions & 0 deletions .build/Configuration.cs
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;
}
18 changes: 5 additions & 13 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@
"version": 1,
"isRoot": true,
"tools": {
"nukeeper": {
"version": "0.26.0",
"commands": ["nukeeper"]
},
"dotnet-outdated": {
"version": "2.8.0",
"version": "2.11.0",
"commands": ["dotnet-outdated"]
},
"gitversion.tool": {
"version": "5.1.3",
"version": "5.3.5",
"commands": ["dotnet-gitversion"]
},
"dotnet-reportgenerator-globaltool": {
"version": "4.4.0",
"version": "4.6.1",
"commands": ["reportgenerator"]
},
"nuke.globaltool": {
"version": "0.23.6",
"version": "0.24.11",
"commands": ["nuke"]
},
"gitreleasemanager.tool": {
"version": "0.10.0",
"commands": ["dotnet-gitreleasemanager"]
},
"codecov.tool": {
"version": "1.9.0",
"version": "1.11.1",
"commands": ["codecov"]
}
}
Expand Down
60 changes: 0 additions & 60 deletions .dependabot/config.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/auto_assign.yml

This file was deleted.