Skip to content

Commit

Permalink
update nuke
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasteles committed Apr 4, 2024
1 parent 33b9e3d commit bfcd812
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 191 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
GITHUB_ACTIONS: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,9 +59,8 @@ jobs:
output_text_description_file: TestReport/Summary.md
output: '{"summary":"Created by Report-Generator"}'

- name: Generate Docs
run: dotnet docfx
working-directory: docfx
- name: Build Docs
run: dotnet nuke build-docs

- name: Generate Coverage Badges
run: dotnet nuke generate-badges --no-logo
Expand Down
4 changes: 4 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"enum": [
"BrowseReport",
"Build",
"BuildDocs",
"Clean",
"Docs",
"Format",
"GenerateBadges",
"GenerateReport",
Expand All @@ -108,7 +110,9 @@
"enum": [
"BrowseReport",
"Build",
"BuildDocs",
"Clean",
"Docs",
"Format",
"GenerateBadges",
"GenerateReport",
Expand Down
56 changes: 30 additions & 26 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class MainBuild : NukeBuild
[Parameter] readonly string TestResultFile = "test_result.xml";
AbsolutePath CoverageFiles => RootDirectory / "**" / "coverage.cobertura.xml";
AbsolutePath TestReportDirectory => RootDirectory / "TestReport";
AbsolutePath DocsPath => RootDirectory / "docfx";
AbsolutePath DocsSitePath => DocsPath / "_site";
const string MainBranch = "master";

Target Clean => _ => _
.Description("Clean project directories")
Expand Down Expand Up @@ -70,7 +73,7 @@ class MainBuild : NukeBuild
))
.Executes(() =>
{
ReportGenerator(r => r.LocalTool(Solution, "reportgenerator")
ReportGenerator(r => r
.SetReports(CoverageFiles)
.SetTargetDirectory(TestReportDirectory)
.SetReportTypes(ReportTypes.TextSummary));
Expand All @@ -85,7 +88,6 @@ class MainBuild : NukeBuild
.OnlyWhenDynamic(() => CoverageFiles.GlobFiles().Any())
.Executes(() =>
ReportGenerator(r => r
.LocalTool(Solution, "reportgenerator")
.SetReports(CoverageFiles)
.SetTargetDirectory(TestReportDirectory)
.SetReportTypes(
Expand Down Expand Up @@ -119,38 +121,40 @@ class MainBuild : NukeBuild
{
var output = RootDirectory / "docfx" / "_site";
if (!output.DirectoryExists()) output.CreateDirectory();
Badges.ForCoverage(Solution, output, CoverageFiles);
Badges.ForCoverage(output, CoverageFiles);
Badges.ForDotNetVersion(output, GlobalJson);
Badges.ForTests(output, TestResultFile);
});

Target BuildDocs => _ => _
.Description("Build DocFX")
.Executes(() =>
{
DocsSitePath.CreateOrCleanDirectory();
(DocsPath / "api").CreateOrCleanDirectory();
DotNetBuild(s => s.SetProjectFile(Solution).SetConfiguration(Configuration.Release));
DocFX.Build(c => c
.SetProcessWorkingDirectory(DocsPath)
.SetProcessEnvironmentVariable(DocFX.DocFXSourceBranchName, MainBranch)
);
});

Target Docs => _ => _
.Description("View DocFX")
.Executes(() =>
{
DotNetBuild(s => s.SetProjectFile(Solution).SetConfiguration(Configuration.Release));
DocFX.Serve(c => c
.SetProcessWorkingDirectory(DocsPath)
.SetProcessEnvironmentVariable(DocFX.DocFXSourceBranchName, MainBranch));
});

Target UpdateTools => _ => _
.Description("Update all project .NET tools")
.Executes(() => DotNet($"tool list", logOutput: false)
.Skip(2)
.Select(c => c.Text.Split(' ',
StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
.ForEach(line =>
{
try
{
if (line is not [{ } tool, { } version, ..]) return;
Log.Information("* Updating {Tool}:", tool);
var isPre =
new[] { "rc", "preview", "beta", "alpha" }.Any(version.ToLower().Contains)
? "--prerelease"
: string.Empty;
DotNet($"tool update {tool} {isPre}");
}
catch (Exception e)
{
Log.Warning("Tool Update: {Message}", e.Message);
}
})
);
.Executes(UpdateLocalTools);

public static int Main() => Execute<MainBuild>();

protected override void OnBuildInitialized() =>
DotNetToolRestore(c => c.DisableProcessLogOutput());
}
}
72 changes: 0 additions & 72 deletions build/Helpers/Badges.cs

This file was deleted.

38 changes: 0 additions & 38 deletions build/Helpers/Commands.cs

This file was deleted.

25 changes: 0 additions & 25 deletions build/Helpers/Configuration.cs

This file was deleted.

20 changes: 0 additions & 20 deletions build/Helpers/Extensions.cs

This file was deleted.

10 changes: 3 additions & 7 deletions build/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
global using System;
global using System.ComponentModel;
global using System.Collections.Generic;
global using System.Threading.Tasks;
global using System.Linq;
global using Helpers;
global using Nuke.Common;
global using Nuke.Common.IO;
global using Nuke.Common.ProjectModel;
Expand All @@ -15,10 +11,10 @@
global using Nuke.Common.Utilities;
global using Nuke.Common.Utilities.Collections;
global using Serilog;
global using static Helpers.Commands;
global using static Nuke.Common.EnvironmentInfo;
global using static Nuke.Common.IO.FileSystemTasks;
global using static Nuke.Common.Tools.Docker.DockerTasks;
global using static Nuke.Common.Tools.DotNet.DotNetTasks;
global using static Nuke.Common.Tools.EntityFramework.EntityFrameworkTasks;
global using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
global using NukePlus;
global using static NukePlus.NukePlus;
global using static NukePlus.DotnetLocalTools;
1 change: 1 addition & 0 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.0.0" />
<PackageReference Include="NukePlus" Version="1.1.2" />
</ItemGroup>
</Project>

0 comments on commit bfcd812

Please sign in to comment.