Skip to content

Updated build, enabled github actions, and workflow automations #281

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

Merged
merged 19 commits into from
Aug 10, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions .build/.build.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" />
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
<PackageReference Include="GitVersion.Tool" ExcludeAssets="All" />
<PackageReference Include="ReportGenerator" ExcludeAssets="All" />
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
<PackageReference Include="Rocket.Surgery.Nuke.DotNetCore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
<PackageReference Include="GitVersion.Tool" ExcludeAssets="All" />
<PackageReference Include="ReportGenerator" ExcludeAssets="All" />
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
<PackageReference Include="Rocket.Surgery.Nuke" />
</ItemGroup>

<ItemGroup>
<NukeSpecificationFiles Include="**\*.json" Exclude="bin\**;obj\**" />
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
</ItemGroup>
<ItemGroup>
<NukeSpecificationFiles Include="**\*.json" Exclude="bin\**;obj\**" />
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
</ItemGroup>

</Project>
52 changes: 41 additions & 11 deletions .build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
using JetBrains.Annotations;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.MSBuild;
using Rocket.Surgery.Nuke;
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) }
)]
internal class Solution : DotNetCoreBuild, IDotNetCoreBuild
[PackageIcon("http://www.omnisharp.net/images/logo.png")]
[EnsureGitHooks(GitHook.PreCommit)]
[EnsureReadmeIsUpdated]
[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:
Expand All @@ -24,17 +40,31 @@ internal class Solution : DotNetCoreBuild, IDotNetCoreBuild
/// </summary>
public static int Main() => Execute<Solution>(x => x.Default);

[OptionalGitRepository]
public GitRepository? GitRepository { get; }

private Target Default => _ => _
.DependsOn(Restore)
.DependsOn(Build)
.DependsOn(Test)
.DependsOn(Pack);

public Target Restore => _ => _.With(this, DotNetCoreBuild.Restore);
public Target Build => _ => _.Inherit<ICanBuildWithDotNetCore>(x => x.CoreBuild);

public Target Pack => _ => _.Inherit<ICanPackWithDotNetCore>(x => x.CorePack)
.DependsOn(Clean);

[ComputedGitVersion]
public GitVersion GitVersion { get; } = null!;

public 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 Target Test => _ => _.With(this, DotNetCoreBuild.Test);
public Target BuildVersion => _ => _.Inherit<IHaveBuildVersion>(x => x.BuildVersion)
.Before(Default)
.Before(Clean);

public 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;
}
142 changes: 142 additions & 0 deletions .build/Solution.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"
},
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;
}
}
26 changes: 22 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
[*]
root=true

[*.{cs,cshtml}]
charset=utf-8
indent_style=space
indent_size=4
insert_final_newline=true

[*.{js,ts,vue}]
indent_style=space
indent_size=4
insert_final_newline=true

[*.{json,xml,yml,yaml}]
indent_style=space
indent_size=2
insert_final_newline=true

[*.{xml,csproj,props,targets}]
indent_style = space

[*]
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 180

[*.xml]
indent_style = space

[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
Expand Down
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
assignees:
- 'david-driscoll'
open-pull-requests-limit: 100

- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
assignees:
- 'david-driscoll'
open-pull-requests-limit: 100

- package-ecosystem: 'nuget'
directory: '/'
schedule:
interval: 'daily'
assignees:
- 'david-driscoll'
ignore:
- dependency-name: Microsoft.Extensions.*
- dependency-name: Microsoft.AspNetCore.*
open-pull-requests-limit: 100
5 changes: 5 additions & 0 deletions .github/label-commenter-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
labels:
- name: 'merge'
labeled:
pr:
body: '@dependabot squash and merge'
Loading