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

Feature/more maybe2 #1306

Merged
merged 6 commits into from
Sep 3, 2024
Merged
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
6 changes: 2 additions & 4 deletions .build/Build.cs
Original file line number Diff line number Diff line change
@@ -67,9 +67,7 @@ public static int Main()
[OptionalGitRepository]
public GitRepository? GitRepository { get; }

public Target Lint => _ => _.Inherit<ICanLint>(x => x.Lint)
//temp
.DependsOn(Build);
public Target Lint => _ => _.Inherit<ICanLint>(x => x.Lint);

public Target Pack => _ => _;

@@ -86,4 +84,4 @@ public static int Main()

[Parameter("Configuration to build")]
public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release;
}
}
18 changes: 7 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -75,10 +75,14 @@ jobs:
id: restore
run: |
dotnet nuke DotnetCoreRestore Restore --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: ⚙️ Build
id: build
- name: Dotnet Format
id: dotnetFormat
run: |
dotnet .build/bin/Debug/.build.dll DotnetFormat --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: Jet Brains Cleanup Code
id: jetBrainsCleanupCode
run: |
dotnet .build/bin/Debug/.build.dll DotnetCoreBuild Build --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
dotnet .build/bin/Debug/.build.dll JetBrainsCleanupCode --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: Generate Solution Items
id: generateSolutionItems
run: |
@@ -87,14 +91,6 @@ jobs:
id: generateReadme
run: |
dotnet .build/bin/Debug/.build.dll GenerateReadme --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: Dotnet Format
id: dotnetFormat
run: |
dotnet .build/bin/Debug/.build.dll DotnetFormat --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: Jet Brains Cleanup Code
id: jetBrainsCleanupCode
run: |
dotnet .build/bin/Debug/.build.dll JetBrainsCleanupCode --skip --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}"
- name: Add & Commit
env:
GITHUB_TOKEN: '${{ secrets.RSG_BOT_TOKEN }}'
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup>
<GlobalPackageReference Include="Rocket.Surgery.MSBuild.CI" Version="1.2.1" />
@@ -48,5 +47,6 @@
</ItemGroup>
<Import
Project="$(MSBuildThisFileDirectory)/Directory.Packages.support.props"
Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')" />
</Project>
Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')"
/>
</Project>
32 changes: 20 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -5,37 +5,45 @@ Every good Rocket Surgeon needs multiple choices of build systems to pick from t
# Status

<!-- badges -->

[![github-release-badge]][github-release]
[![github-license-badge]][github-license]
[![codecov-badge]][codecov]

<!-- badges -->

<!-- history badges -->
| GitHub Actions |
| -------------- |
| [![github-badge]][github] |

| GitHub Actions |
| --------------------------------- |
| [![github-badge]][github] |
| [![github-history-badge]][github] |

<!-- history badges -->

<!-- nuget packages -->
| Package | NuGet |
| ------- | ----- |

| Package | NuGet |
| ------------------- | ---------------------------------------------------------------------------------------------- |
| Rocket.Surgery.Nuke | [![nuget-version-6plqb7nwtdoa-badge]![nuget-downloads-6plqb7nwtdoa-badge]][nuget-6plqb7nwtdoa] |

<!-- nuget packages -->

<!-- generated references -->

[github-release]: https://github.com/RocketSurgeonsGuild/Nuke/releases/latest
[github-release-badge]: https://img.shields.io/github/release/RocketSurgeonsGuild/Nuke.svg?logo=github&style=flat "Latest Release"
[github-release-badge]: https://img.shields.io/github/release/RocketSurgeonsGuild/Nuke.svg?logo=github&style=flat 'Latest Release'
[github-license]: https://github.com/RocketSurgeonsGuild/Nuke/blob/master/LICENSE
[github-license-badge]: https://img.shields.io/github/license/RocketSurgeonsGuild/Nuke.svg?style=flat "License"
[github-license-badge]: https://img.shields.io/github/license/RocketSurgeonsGuild/Nuke.svg?style=flat 'License'
[codecov]: https://codecov.io/gh/RocketSurgeonsGuild/Nuke
[codecov-badge]: https://img.shields.io/codecov/c/github/RocketSurgeonsGuild/Nuke.svg?color=E03997&label=codecov&logo=codecov&logoColor=E03997&style=flat "Code Coverage"
[codecov-badge]: https://img.shields.io/codecov/c/github/RocketSurgeonsGuild/Nuke.svg?color=E03997&label=codecov&logo=codecov&logoColor=E03997&style=flat 'Code Coverage'
[github]: https://github.com/RocketSurgeonsGuild/Nuke/actions?query=workflow%3Aci
[github-badge]: https://img.shields.io/github/workflow/status/RocketSurgeonsGuild/Nuke/ci.svg?label=github&logo=github&color=b845fc&logoColor=b845fc&style=flat "GitHub Actions Status"
[github-history-badge]: https://buildstats.info/github/chart/RocketSurgeonsGuild/Nuke?includeBuildsFromPullRequest=false "GitHub Actions History"
[github-badge]: https://img.shields.io/github/workflow/status/RocketSurgeonsGuild/Nuke/ci.svg?label=github&logo=github&color=b845fc&logoColor=b845fc&style=flat 'GitHub Actions Status'
[github-history-badge]: https://buildstats.info/github/chart/RocketSurgeonsGuild/Nuke?includeBuildsFromPullRequest=false 'GitHub Actions History'
[nuget-6plqb7nwtdoa]: https://www.nuget.org/packages/Rocket.Surgery.Nuke/
[nuget-version-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square "NuGet Version"
[nuget-downloads-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads"
[nuget-version-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square 'NuGet Version'
[nuget-downloads-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square 'NuGet Downloads'

<!-- generated references -->

<!-- nuke-data
13 changes: 11 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
# CONFIGURATION
###########################################################################

$IsCI = $env:CI -eq "true"
$BuildProjectFile = "$PSScriptRoot\.build\.build.csproj"
$TempDirectory = "$PSScriptRoot\\.nuke\temp"

@@ -63,7 +64,15 @@ else {
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
# only execute the build if not running in CI or if running in CI and the project has not been built
if ($IsCI) {
if (-not (Test-Path "$PSScriptRoot\.nuke\temp\ci")) {
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
New-Item -Type File = "$PSScriptRoot\.nuke\temp\ci" | Out-Null
}
} else {
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
}

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
2 changes: 1 addition & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@
<!-- />-->
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
</Project>
</Project>
14 changes: 12 additions & 2 deletions src/Nuke/DotNetCore/ICanDotNetFormat.cs
Original file line number Diff line number Diff line change
@@ -27,7 +27,18 @@ public interface ICanDotNetFormat : IHaveSolution, ICanLint, IHaveOutputLogs
/// <summary>
/// A list of diagnostic ids to exclude from the dotnet format
/// </summary>
public ImmutableArray<string> DotNetFormatExcludedDiagnostics => ["RCS1060",];
public ImmutableArray<string> DotNetFormatExcludedDiagnostics =>
[
"RCS1060",
"RCS1110",
"RCS1250",
"RCS1163",
"CS1591",
"CS0108",
"CS0246",
"IDE1006",
"RCS1175",
];

/// <summary>
/// A list of diagnostic ids to include in the dotnet format
@@ -41,7 +52,6 @@ public interface ICanDotNetFormat : IHaveSolution, ICanLint, IHaveOutputLogs
d
.TriggeredBy(Lint)
.Before(PostLint)
.TryAfter<ICanRestoreWithDotNetCore>(a => a.DotnetToolRestore)
.OnlyWhenDynamic(() => IsLocalBuild || LintPaths.HasPaths)
.Executes(
() =>
7 changes: 0 additions & 7 deletions src/Nuke/GithubActions/GitHubActionsStepsAttribute.cs
Original file line number Diff line number Diff line change
@@ -318,7 +318,6 @@ public override ConfigurationEntity GetConfiguration(IReadOnlyCollection<Executa
var requiredInputs = new List<GitHubActionsInput>();
var lookupTable = new LookupTable<ExecutableTarget, ExecutableTarget[]>();
var initialArguments = localTool ? new Arguments().Add("dotnet").Add("nuke") : new Arguments().Add("nuke");
var firstRun = true;
foreach (( var execute, var targets ) in relevantTargets
.Select(
x => ( ExecutableTarget: x,
@@ -366,12 +365,6 @@ public override ConfigurationEntity GetConfiguration(IReadOnlyCollection<Executa
"{key} {value}"
);

if (firstRun && localTool)
{
firstRun = false;
initialArguments = new Arguments().Add("dotnet").Add(NukeBuild.RootDirectory.GetUnixRelativePathTo(Assembly.GetEntryAssembly()!.Location));
}

steps.Add(
new RunStep(execute.Name.Humanize(LetterCasing.Title))
{
20 changes: 10 additions & 10 deletions src/Nuke/ICanLint.cs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
[PublicAPI]
public interface ICanLint : IHaveGitRepository, IHaveLintTarget
{
static IEnumerable<string> FilterFiles(TreeChanges patch)

Check warning on line 17 in src/Nuke/ICanLint.cs

GitHub Actions / lint

Missing XML comment for publicly visible type or member 'ICanLint.FilterFiles(TreeChanges)'

Check warning on line 17 in src/Nuke/ICanLint.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ICanLint.FilterFiles(TreeChanges)'
{
foreach (var item in patch)
{
@@ -79,16 +79,16 @@
/// The lint target
/// </summary>
[NonEntryTarget]
public Target Lint => t => t
.OnlyWhenDynamic(() => LintPaths.HasPaths)
.TryDependsOn<IHaveRestoreTarget>(a => a.Restore)
.Executes(
() =>
{
Log.Information("Linting {Count} files", LintPaths.Paths.Count());
WriteFileTreeWithEmoji(LintPaths.Paths);
}
);
public new Target Lint => t => t
.OnlyWhenDynamic(() => LintPaths.HasPaths)
.TryDependsOn<IHaveRestoreTarget>(a => a.Restore)
.Executes(
() =>
{
Log.Information("Linting {Count} files", LintPaths.Paths.Count());
WriteFileTreeWithEmoji(LintPaths.Paths);
}
);

/// <summary>
/// A lint target that runs last
3 changes: 2 additions & 1 deletion src/Nuke/ICanUpdateReadme.cs
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ public interface ICanUpdateReadme : IHaveSolution
/// </summary>
public Target GenerateReadme => d => d
.Unlisted()
.TryTriggeredBy<ICanLint>(z => z.Lint)
.TryTriggeredBy<ICanLint>(z => z.PostLint)
.TryAfter<ICanLint>(z => z.PostLint)
.Executes(
async () => File.WriteAllText(
ReadmeFilePath,
5 changes: 3 additions & 2 deletions src/Nuke/ICanUpdateSolution.cs
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ public interface ICanUpdateSolution : IHaveSolution
public Target GenerateSolutionItems
=> d => d
.Unlisted()
.TryTriggeredBy<ICanLint>(z => z.Lint)
.TryTriggeredBy<ICanLint>(z => z.PostLint)
.TryAfter<ICanLint>(z => z.PostLint)
.Executes(
() =>
{
@@ -29,4 +30,4 @@ public Target GenerateSolutionItems
);
}
);
}
}
12 changes: 9 additions & 3 deletions src/Nuke/IHavePublicApis.cs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Rocket.Surgery.Nuke.GithubActions;
using Rocket.Surgery.Nuke.ProjectModel;
using Serilog;

@@ -129,8 +128,15 @@ static async Task<List<string>> GetLines(AbsolutePath path)
private IAsyncEnumerable<ProjectAnalyzerModel> GetPublicApiAnalyzerProjects()
{
if (!LintPaths.HasPaths) return AsyncEnumerable.Empty<ProjectAnalyzerModel>();
return Solution
.AnalyzeAllProjects()
var binlog = LogsDirectory
.GlobFiles("*.binlog")
.OrderBy(z => File.GetLastWriteTimeUtc(z))
.FirstOrDefault();
if (binlog == null) return AsyncEnumerable.Empty<ProjectAnalyzerModel>();

return binlog
.AnalyzeBinLog()
.GetProjects()
.Where(
project => project
.PackageReferences
2 changes: 1 addition & 1 deletion src/Nuke/Rocket.Surgery.Nuke.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>$(NoWarn);CS0436</NoWarn>
<!-- This has to be turned on because in Nuke.Common.props it is turned off to false, which causes build failures when writing to the same dll multiple times with cross targeting -->
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
18 changes: 6 additions & 12 deletions src/Nuke/SolutionExtensions.cs
Original file line number Diff line number Diff line change
@@ -13,26 +13,20 @@ public static class SolutionExtensions
/// </summary>
/// <param name="solution">The solution.</param>
/// <returns>An enumerable of projects.</returns>
public static async IAsyncEnumerable<ProjectAnalyzerModel> WherePackable(this Solution solution)
public static IAsyncEnumerable<ProjectAnalyzerModel> WherePackable(this Solution solution)
{
foreach (var project in solution.AllProjects)
{
var analyzeProject = await project.Analyze();
if (analyzeProject is { IsPackable: true, IsTestProject: false, }) yield return analyzeProject;
}
return solution.AnalyzeAllProjects().Where(project => project is { IsPackable: true, IsTestProject: false, });
}

/// <summary>
/// Gets the test projects.
/// </summary>
/// <param name="solution">The solution.</param>
/// <returns></returns>
public static async IAsyncEnumerable<ProjectAnalyzerModel> GetTestProjects(this Solution solution)
public static IAsyncEnumerable<ProjectAnalyzerModel> GetTestProjects(this Solution solution)
{
foreach (var project in solution.AllProjects)
{
var analyzeProject = await project.Analyze();
if (analyzeProject.IsTestProject) yield return analyzeProject;
}
return solution
.AnalyzeAllProjects()
.Where(z => z.IsTestProject);
}
}
2 changes: 1 addition & 1 deletion test/Nuke.Tests/Rocket.Surgery.Nuke.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Nuke\Rocket.Surgery.Nuke.csproj" />
Loading