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

chore: .net8 yak shaving #247

Merged
merged 15 commits into from
Feb 10, 2024
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
2 changes: 1 addition & 1 deletion .build/.build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
Expand Down
89 changes: 0 additions & 89 deletions .build/AirframeBuild.CI.cs

This file was deleted.

128 changes: 128 additions & 0 deletions .build/AirframeBuild.GitHubActions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using Nuke.Common;
using Nuke.Common.Tools.DotNet;
using System.Collections.Generic;
using System.Linq;
using Nuke.Common.CI.GitHubActions;
using Rocket.Surgery.Nuke.ContinuousIntegration;
using Rocket.Surgery.Nuke.DotNetCore;
using Rocket.Surgery.Nuke.GithubActions;
using System;
using static GitHubActionsTasks;

[GitHubActionsSteps(
"ci",
GitHubActionsImage.MacOsLatest,
AutoGenerate = true,
On = [RocketSurgeonGitHubActionsTrigger.Push],
OnPushTags = ["v*"],
OnPushBranches = ["master", "next", "feature/*"],
OnPullRequestBranches = ["master", "next"],
InvokedTargets = [nameof(GitHubActions)],
NonEntryTargets =
[
nameof(ICIEnvironment.CIEnvironment),
nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports),
nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura),
nameof(IGenerateCodeCoverageBadges.GenerateCodeCoverageBadges),
nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport),
nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary),
nameof(Default)
],
ExcludedTargets = [nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore)],
Enhancements = [nameof(Middleware)]
)]
[PrintBuildVersion, PrintCIEnvironment, UploadLogs]
[LocalBuildConventions]
[ContinuousIntegrationConventions]
public partial class AirframeBuild
{
public Target GitHubActions => definition => definition
.OnlyWhenStatic(IsRunningOnGitHubActions)
.DependsOn(Workloads)
.DependsOn(Restore)
.DependsOn(Build)
.DependsOn(Test)
.DependsOn(Pack)
.Executes();

public Target Workloads => definition => definition
.Before(Restore)
.Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.AddWorkloadId("ios")));

public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
var buildJob = configuration.Jobs.Cast<RocketSurgeonsGithubActionsJob>().First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase));
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 8 SDK")
{
DotNetVersion = "8.0.101"
}
}
);

buildJob.Steps.Add(
new UsingStep("Publish Coverage")
{
Uses = "codecov/codecov-action@v1",
With = new Dictionary<string, string>
{
["name"] = "actions-${{ matrix.os }}",
}
}
);

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()"
}
);

return configuration;
}
}

public static class GitHubActionsTasks
{
public static Func<bool> IsRunningOnGitHubActions => ()
=> NukeBuild.Host is GitHubActions || Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == true.ToString();
}
72 changes: 39 additions & 33 deletions .build/AirframeBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,56 @@
[NuGetVerbosityMapping]
[EnsureGitHooks(GitHook.CommitMsg)]
public partial class AirframeBuild : NukeBuild,
ICanClean,
ICanRestoreWithMsBuild,
ICanTestWithDotNetCoreNoBuild,
ICanPackWithMsBuild,
ICanUpdateReadme,
IHaveDataCollector,
IHaveConfiguration<Configuration>,
IGenerateCodeCoverageReport,
IGenerateCodeCoverageSummary,
IGenerateCodeCoverageBadges,
ICanLint
ICanRestoreWithDotNetCore,
ICanBuildWithDotNetCore,
ICanTestWithDotNetCore,
ICanPackWithDotNetCore,
IHaveDataCollector,
ICanClean,
ICanLintStagedFiles,
ICanDotNetFormat,
IHavePublicApis,
ICanUpdateReadme,
IGenerateCodeCoverageReport,
IGenerateCodeCoverageSummary,
IGenerateCodeCoverageBadges,
ICanRegenerateBuildConfiguration,
IHaveConfiguration<Configuration>

{
/// <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
/// 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
/// </summary>
public static int Main() => Execute<AirframeBuild>(x => x.Default);

[OptionalGitRepository]
public GitRepository? GitRepository { get; }

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

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

public Target Build => _ => _.Inherit<ICanBuildWithMsBuild>(x => x.NetBuild);
public Target Clean => definition => definition.Inherit<ICanClean>(canClean => canClean.Clean);
public Target Restore => definition => definition.Inherit<ICanRestoreWithDotNetCore>(dotNetCore => dotNetCore.CoreRestore);
public Target Build => definition => definition.Inherit<ICanBuildWithDotNetCore>(dotNetCore => dotNetCore.CoreBuild);
public Target Test => definition => definition.Inherit<ICanTestWithDotNetCore>(dotNetCore => dotNetCore.CoreTest);
public Target Pack => definition => definition.Inherit<ICanPackWithDotNetCore>(dotNetCore => dotNetCore.CorePack)
.DependsOn(Clean)
.After(Test);

[Solution(GenerateProjects = true)]
Solution Solution { get; } = null!;

Nuke.Common.ProjectModel.Solution IHaveSolution.Solution => Solution;

[OptionalGitRepository]
public GitRepository? GitRepository { get; }

public Target Pack => _ => _
.Inherit<ICanPackWithMsBuild>(x => x.NetPack)
.DependsOn(Clean);
public Target Clean => _ => _.Inherit<ICanClean>(x => x.Clean);
public Target Restore => _ => _.Inherit<ICanRestoreWithMsBuild>(x => x.NetRestore);
public Target Test => _ => _.Inherit<ICanTestWithDotNetCoreNoBuild>(x => x.CoreTest);
public Target BuildVersion => _ => _
.Inherit<IHaveBuildVersion>(x => x.BuildVersion)
.Before(Default)
.Before(Clean);
[ComputedGitVersion]
public GitVersion GitVersion { get; } = null!;

[Parameter("Configuration to build")]
public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release;
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ jobs:
- name: Fetch all history for all tags and branches
run: |
git fetch --prune
- name: 🔨 Use .NET 6 SDK
- name: 🔨 Use .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.100'
dotnet-version: '8.0.101'
- name: 🎁 dotnet tool restore
run: |
dotnet tool restore
- name: Workloads
id: workloads
run: |
dotnet nuke Workloads --skip
- name: 🎁 Restore
id: restore
run: |
Expand All @@ -78,6 +82,10 @@ jobs:
id: pack
run: |
dotnet nuke Pack --skip
- name: Git Hub Actions
id: gitHubActions
run: |
dotnet nuke GitHubActions --skip
- name: 🐿 Publish Coverage
uses: codecov/codecov-action@v3.1.4
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,5 @@ ASALocalRun/

# Code Coverage
coverage/
test/**/coverage.json
test/**/coverage.json
.nuke/temp/
Loading
Loading