Skip to content

Commit 331f802

Browse files
Updated build, enabled github actions, and workflow automations (#281)
* Updated build, enabled github actions, and workflow automations * turns out settlers weren't working as expected... who knew unit tests were so useful???!?
1 parent 0a0d9b1 commit 331f802

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2736
-367
lines changed

.build/.build.csproj

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
6-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
7-
<RootNamespace></RootNamespace>
8-
<IsPackable>False</IsPackable>
9-
<NoWarn>CS0649;CS0169</NoWarn>
10-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
7+
<RootNamespace></RootNamespace>
8+
<IsPackable>False</IsPackable>
9+
<NoWarn>CS0649;CS0169</NoWarn>
10+
</PropertyGroup>
1111

12-
<ItemGroup>
13-
<PackageReference Include="Nuke.Common" />
14-
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
15-
<PackageReference Include="GitVersion.Tool" ExcludeAssets="All" />
16-
<PackageReference Include="ReportGenerator" ExcludeAssets="All" />
17-
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
18-
<PackageReference Include="Rocket.Surgery.Nuke.DotNetCore" />
19-
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
14+
<PackageReference Include="GitVersion.Tool" ExcludeAssets="All" />
15+
<PackageReference Include="ReportGenerator" ExcludeAssets="All" />
16+
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
17+
<PackageReference Include="Rocket.Surgery.Nuke" />
18+
</ItemGroup>
2019

21-
<ItemGroup>
22-
<NukeSpecificationFiles Include="**\*.json" Exclude="bin\**;obj\**" />
23-
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
24-
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
25-
</ItemGroup>
20+
<ItemGroup>
21+
<NukeSpecificationFiles Include="**\*.json" Exclude="bin\**;obj\**" />
22+
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
23+
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
24+
</ItemGroup>
2625

2726
</Project>

.build/Build.cs

+41-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
using JetBrains.Annotations;
22
using Nuke.Common;
33
using Nuke.Common.Execution;
4+
using Nuke.Common.Git;
5+
using Nuke.Common.Tools.DotNet;
6+
using Nuke.Common.Tools.GitVersion;
7+
using Nuke.Common.Tools.MSBuild;
48
using Rocket.Surgery.Nuke;
59
using Rocket.Surgery.Nuke.DotNetCore;
610

711
[PublicAPI]
812
[CheckBuildProjectConfigurations]
913
[UnsetVisualStudioEnvironmentVariables]
10-
[AzurePipelinesSteps(
11-
InvokedTargets = new[] { nameof(Default) },
12-
NonEntryTargets = new[] { nameof(BuildVersion), nameof(Generate_Code_Coverage_Reports), nameof(Default) },
13-
ExcludedTargets = new[] { nameof(Restore), nameof(DotnetToolRestore) },
14-
Parameters = new[] { nameof(CoverageDirectory), nameof(ArtifactsDirectory), nameof(Verbosity), nameof(Configuration) }
15-
)]
16-
internal class Solution : DotNetCoreBuild, IDotNetCoreBuild
14+
[PackageIcon("http://www.omnisharp.net/images/logo.png")]
15+
[EnsureGitHooks(GitHook.PreCommit)]
16+
[EnsureReadmeIsUpdated]
17+
[DotNetVerbosityMapping]
18+
[MSBuildVerbosityMapping]
19+
[NuGetVerbosityMapping]
20+
public partial class Solution : NukeBuild,
21+
ICanRestoreWithDotNetCore,
22+
ICanBuildWithDotNetCore,
23+
ICanTestWithDotNetCore,
24+
ICanPackWithDotNetCore,
25+
IHaveDataCollector,
26+
ICanClean,
27+
ICanUpdateReadme,
28+
IGenerateCodeCoverageReport,
29+
IGenerateCodeCoverageSummary,
30+
IGenerateCodeCoverageBadges,
31+
IHaveConfiguration<Configuration>,
32+
ICanLint
1733
{
1834
/// <summary>
1935
/// Support plugins are available for:
@@ -24,17 +40,31 @@ internal class Solution : DotNetCoreBuild, IDotNetCoreBuild
2440
/// </summary>
2541
public static int Main() => Execute<Solution>(x => x.Default);
2642

43+
[OptionalGitRepository]
44+
public GitRepository? GitRepository { get; }
45+
2746
private Target Default => _ => _
2847
.DependsOn(Restore)
2948
.DependsOn(Build)
3049
.DependsOn(Test)
3150
.DependsOn(Pack);
3251

33-
public Target Restore => _ => _.With(this, DotNetCoreBuild.Restore);
52+
public Target Build => _ => _.Inherit<ICanBuildWithDotNetCore>(x => x.CoreBuild);
53+
54+
public Target Pack => _ => _.Inherit<ICanPackWithDotNetCore>(x => x.CorePack)
55+
.DependsOn(Clean);
56+
57+
[ComputedGitVersion]
58+
public GitVersion GitVersion { get; } = null!;
3459

35-
public Target Build => _ => _.With(this, DotNetCoreBuild.Build);
60+
public Target Clean => _ => _.Inherit<ICanClean>(x => x.Clean);
61+
public Target Restore => _ => _.Inherit<ICanRestoreWithDotNetCore>(x => x.CoreRestore);
62+
public Target Test => _ => _.Inherit<ICanTestWithDotNetCore>(x => x.CoreTest);
3663

37-
public Target Test => _ => _.With(this, DotNetCoreBuild.Test);
64+
public Target BuildVersion => _ => _.Inherit<IHaveBuildVersion>(x => x.BuildVersion)
65+
.Before(Default)
66+
.Before(Clean);
3867

39-
public Target Pack => _ => _.With(this, DotNetCoreBuild.Pack);
68+
[Parameter("Configuration to build")]
69+
public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release;
4070
}

.build/Configuration.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.ComponentModel;
2+
using Nuke.Common.Tooling;
3+
4+
[TypeConverter(typeof(TypeConverter<Configuration>))]
5+
public class Configuration : Enumeration
6+
{
7+
public static readonly Configuration Debug = new Configuration { Value = nameof(Debug) };
8+
public static readonly Configuration Release = new Configuration { Value = nameof(Release) };
9+
10+
public static implicit operator string(Configuration configuration) => configuration.Value;
11+
}

.build/Solution.cs

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Nuke.Common.CI.GitHubActions;
4+
using Rocket.Surgery.Nuke;
5+
using Rocket.Surgery.Nuke.ContinuousIntegration;
6+
using Rocket.Surgery.Nuke.DotNetCore;
7+
using Rocket.Surgery.Nuke.GithubActions;
8+
9+
[AzurePipelinesSteps(
10+
AutoGenerate = false,
11+
InvokeTargets = new[] { nameof(Default) },
12+
NonEntryTargets = new[]
13+
{
14+
nameof(ICIEnvironment.CIEnvironment),
15+
nameof(ITriggerCodeCoverageReports.Trigger_Code_Coverage_Reports),
16+
nameof(ITriggerCodeCoverageReports.Generate_Code_Coverage_Report_Cobertura),
17+
nameof(IGenerateCodeCoverageBadges.Generate_Code_Coverage_Badges),
18+
nameof(IGenerateCodeCoverageReport.Generate_Code_Coverage_Report),
19+
nameof(IGenerateCodeCoverageSummary.Generate_Code_Coverage_Summary),
20+
nameof(Default)
21+
},
22+
ExcludedTargets = new[]
23+
{ nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.Restore), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) },
24+
Parameters = new[]
25+
{
26+
nameof(IHaveCodeCoverage.CoverageDirectory), nameof(IHaveOutputArtifacts.ArtifactsDirectory), nameof(Verbosity),
27+
nameof(IHaveConfiguration.Configuration)
28+
}
29+
)]
30+
[GitHubActionsSteps("ci", GitHubActionsImage.MacOsLatest, GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest,
31+
AutoGenerate = false,
32+
On = new[] { GitHubActionsTrigger.Push },
33+
OnPushTags = new[] { "v*" },
34+
OnPushBranches = new[] { "master", "next" },
35+
OnPullRequestBranches = new[] { "master", "next" },
36+
InvokedTargets = new[] { nameof(Default) },
37+
NonEntryTargets = new[]
38+
{
39+
nameof(ICIEnvironment.CIEnvironment),
40+
nameof(ITriggerCodeCoverageReports.Trigger_Code_Coverage_Reports),
41+
nameof(ITriggerCodeCoverageReports.Generate_Code_Coverage_Report_Cobertura),
42+
nameof(IGenerateCodeCoverageBadges.Generate_Code_Coverage_Badges),
43+
nameof(IGenerateCodeCoverageReport.Generate_Code_Coverage_Report),
44+
nameof(IGenerateCodeCoverageSummary.Generate_Code_Coverage_Summary),
45+
nameof(Default)
46+
},
47+
ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) },
48+
Enhancements = new[] { nameof(Middleware) }
49+
)]
50+
[PrintBuildVersion, PrintCIEnvironment, UploadLogs]
51+
public partial class Solution
52+
{
53+
public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration)
54+
{
55+
var buildJob = configuration.Jobs.First(z => z.Name == "Build");
56+
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single();
57+
// For fetch all
58+
checkoutStep.FetchDepth = 0;
59+
buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] {
60+
new RunStep("Fetch all history for all tags and branches") {
61+
Run = "git fetch --prune"
62+
},
63+
new SetupDotNetStep("Use .NET Core 2.1 SDK") {
64+
DotNetVersion = "2.1.x"
65+
},
66+
new SetupDotNetStep("Use .NET Core 3.1 SDK") {
67+
DotNetVersion = "3.1.x"
68+
},
69+
new RunStep("🪓 **DOTNET HACK** 🪓") {
70+
Shell = GithubActionShell.Pwsh,
71+
Run = @"$version = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Leaf;
72+
$root = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Parent;
73+
$directories = Get-ChildItem $root | Where-Object { $_.Name -ne $version };
74+
foreach ($dir in $directories) {
75+
$from = $dir.FullName;
76+
$to = ""$root/$version"";
77+
Write-Host Copying from $from to $to;
78+
Copy-Item ""$from\*"" $to -Recurse -Force;
79+
}
80+
"
81+
},
82+
});
83+
84+
buildJob.Steps.Add(new UsingStep("Publish Coverage")
85+
{
86+
Uses = "codecov/codecov-action@v1",
87+
With = new Dictionary<string, string>
88+
{
89+
["name"] = "actions-${{ matrix.os }}",
90+
["fail_ci_if_error"] = "true",
91+
}
92+
});
93+
94+
buildJob.Steps.Add(new UploadArtifactStep("Publish logs")
95+
{
96+
Name = "logs",
97+
Path = "artifacts/logs/",
98+
If = "always()"
99+
});
100+
101+
buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data")
102+
{
103+
Name = "coverage",
104+
Path = "coverage/",
105+
If = "always()"
106+
});
107+
108+
buildJob.Steps.Add(new UploadArtifactStep("Publish test data")
109+
{
110+
Name = "test data",
111+
Path = "artifacts/test/",
112+
If = "always()"
113+
});
114+
115+
buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages")
116+
{
117+
Name = "nuget",
118+
Path = "artifacts/nuget/",
119+
If = "always()"
120+
});
121+
122+
123+
/*
124+
125+
- publish: "${{ parameters.Artifacts }}/logs/"
126+
displayName: Publish Logs
127+
artifact: "Logs${{ parameters.Postfix }}"
128+
condition: always()
129+
130+
- publish: ${{ parameters.Coverage }}
131+
displayName: Publish Coverage
132+
artifact: "Coverage${{ parameters.Postfix }}"
133+
condition: always()
134+
135+
- publish: "${{ parameters.Artifacts }}/nuget/"
136+
displayName: Publish NuGet Artifacts
137+
artifact: "NuGet${{ parameters.Postfix }}"
138+
condition: always()
139+
*/
140+
return configuration;
141+
}
142+
}

.editorconfig

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
[*]
1+
root=true
2+
3+
[*.{cs,cshtml}]
4+
charset=utf-8
5+
indent_style=space
6+
indent_size=4
7+
insert_final_newline=true
8+
9+
[*.{js,ts,vue}]
10+
indent_style=space
11+
indent_size=4
12+
insert_final_newline=true
13+
14+
[*.{json,xml,yml,yaml}]
15+
indent_style=space
16+
indent_size=2
17+
insert_final_newline=true
18+
19+
[*.{xml,csproj,props,targets}]
20+
indent_style = space
21+
22+
[*]
223
charset = utf-8
324
indent_style = space
425
indent_size = 4
526
trim_trailing_whitespace = true
627
insert_final_newline = true
728
max_line_length = 180
829

9-
[*.xml]
10-
indent_style = space
11-
1230
[*.{cs,vb}]
1331
# Sort using and Import directives with System.* appearing first
1432
dotnet_sort_system_directives_first = true

.github/dependabot.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'
7+
assignees:
8+
- 'david-driscoll'
9+
open-pull-requests-limit: 100
10+
11+
- package-ecosystem: 'npm'
12+
directory: '/'
13+
schedule:
14+
interval: 'daily'
15+
assignees:
16+
- 'david-driscoll'
17+
open-pull-requests-limit: 100
18+
19+
- package-ecosystem: 'nuget'
20+
directory: '/'
21+
schedule:
22+
interval: 'daily'
23+
assignees:
24+
- 'david-driscoll'
25+
ignore:
26+
- dependency-name: Microsoft.Extensions.*
27+
- dependency-name: Microsoft.AspNetCore.*
28+
open-pull-requests-limit: 100
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
labels:
2+
- name: 'merge'
3+
labeled:
4+
pr:
5+
body: '@dependabot squash and merge'

0 commit comments

Comments
 (0)