Skip to content
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
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
DOTNET_NOLOGO: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDKs
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
8.0.x

- name: Run NUKE
run: ./build.ps1
Expand All @@ -36,12 +36,12 @@ jobs:
ApiKey: ${{ secrets.NUGETAPIKEY }}

- name: coveralls
uses: coverallsapp/github-action@1.1.3
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: TestResults/reports/lcov.info
file: TestResults/reports/lcov.info

- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
path: ./Artifacts/*
139 changes: 69 additions & 70 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build Schema",
"$ref": "#/definitions/build",
"definitions": {
"build": {
"type": "object",
"Host": {
"type": "string",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"ExecutableTarget": {
"type": "string",
"enum": [
"ApiChecks",
"CalculateNugetVersion",
"Clean",
"CodeCoverage",
"Compile",
"Pack",
"Push",
"Restore",
"UnitTests"
]
},
"Verbosity": {
"type": "string",
"description": "",
"enum": [
"Verbose",
"Normal",
"Minimal",
"Quiet"
]
},
"NukeBuild": {
"properties": {
"ApiKey": {
"type": "string",
"description": "The key to push to Nuget"
},
"BranchSpec": {
"type": "string",
"description": "A branch specification such as develop or refs/pull/1775/merge"
},
"BuildNumber": {
"type": "string",
"description": "An incrementing build number as provided by the build engine"
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
Expand All @@ -27,24 +56,8 @@
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
"$ref": "#/definitions/Host"
},
"NoLogo": {
"type": "boolean",
Expand Down Expand Up @@ -73,53 +86,39 @@
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"ApiChecks",
"CalculateNugetVersion",
"Clean",
"CodeCoverage",
"Compile",
"Pack",
"Push",
"Restore",
"UnitTests"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"ApiChecks",
"CalculateNugetVersion",
"Clean",
"CodeCoverage",
"Compile",
"Pack",
"Push",
"Restore",
"UnitTests"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
"$ref": "#/definitions/Verbosity"
}
}
}
},
"allOf": [
{
"properties": {
"ApiKey": {
"type": "string",
"description": "The key to push to Nuget",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
}
}
},
{
"$ref": "#/definitions/NukeBuild"
}
}
}
]
}
35 changes: 17 additions & 18 deletions Build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand All @@ -11,13 +11,11 @@
using Nuke.Common.Tools.ReportGenerator;
using Nuke.Common.Tools.Xunit;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;

[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
[DotNetVerbosityMapping]
class Build : NukeBuild
{
/* Support plugins are available for:
Expand All @@ -28,19 +26,20 @@ class Build : NukeBuild
*/
public static int Main() => Execute<Build>(x => x.Push);

[Parameter("A branch specification such as develop or refs/pull/1775/merge")]
readonly string BranchSpec;
GitHubActions GitHubActions => GitHubActions.Instance;

[Parameter("An incrementing build number as provided by the build engine")]
readonly string BuildNumber;
string BranchSpec => GitHubActions?.Ref;

string BuildNumber => GitHubActions?.RunNumber.ToString();

[Parameter("The key to push to Nuget")]
[Secret]
readonly string ApiKey;

[Solution(GenerateProjects = true)]
readonly Solution Solution;

[GitVersion(Framework = "net5.0")]
[GitVersion(Framework = "net6.0")]
readonly GitVersion GitVersion;

AbsolutePath SourceDirectory => RootDirectory / "src";
Expand All @@ -54,9 +53,9 @@ class Build : NukeBuild
Target Clean => _ => _
.Executes(() =>
{
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
EnsureCleanDirectory(ArtifactsDirectory);
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(path => path.DeleteDirectory());
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(path => path.DeleteDirectory());
ArtifactsDirectory.CreateOrCleanDirectory();
});

Target CalculateNugetVersion => _ => _
Expand All @@ -75,7 +74,7 @@ class Build : NukeBuild
Serilog.Log.Information("SemVer = {semver}", SemVer);
});

bool IsPullRequest => BranchSpec != null && BranchSpec.Contains("pull", StringComparison.InvariantCultureIgnoreCase);
bool IsPullRequest => GitHubActions?.IsPullRequest ?? false;

Target Restore => _ => _
.DependsOn(Clean)
Expand Down Expand Up @@ -122,7 +121,7 @@ class Build : NukeBuild

DotNetTest(s => s
.SetProjectFile(Solution.FluentAssertions_Json_Specs)
.SetFramework("netcoreapp3.0")
.SetFramework("net8.0")
.SetConfiguration("Debug")
.EnableNoBuild()
.SetDataCollector("XPlat Code Coverage")
Expand All @@ -134,7 +133,7 @@ class Build : NukeBuild
.Executes(() =>
{
ReportGenerator(s => s
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net5.0"))
.SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net6.0"))
.SetTargetDirectory(RootDirectory / "TestResults" / "reports")
.AddReports(RootDirectory / "TestResults/**/coverage.cobertura.xml")
.AddReportTypes("HtmlInline_AzurePipelines_Dark", "lcov")
Expand Down Expand Up @@ -168,9 +167,9 @@ class Build : NukeBuild
.OnlyWhenDynamic(() => IsTag)
.Executes(() =>
{
IReadOnlyCollection<string> packages = GlobFiles(ArtifactsDirectory, "*.nupkg");
var packages = ArtifactsDirectory.GlobFiles("*.nupkg");

Assert.NotEmpty(packages.ToList());
Assert.NotEmpty(packages);

DotNetNuGetPush(s => s
.SetApiKey(ApiKey)
Expand All @@ -181,5 +180,5 @@ class Build : NukeBuild
(v, path) => v.SetTargetPath(path)));
});

bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.InvariantCultureIgnoreCase);
bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.OrdinalIgnoreCase);
}
9 changes: 5 additions & 4 deletions Build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..\</NukeRootDirectory>
<NukeScriptDirectory>..\</NukeScriptDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.0.1" />
<PackageDownload Include="GitVersion.Tool" Version="[5.8.2]" />
<PackageDownload Include="ReportGenerator" Version="[5.0.4]" />
<PackageReference Include="Nuke.Common" Version="8.1.4" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Don't you want to jump to Nuke 9 instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chose nuke 8 to align with main.

<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
<PackageDownload Include="GitVersion.Tool" Version="[5.12.0]" />
<PackageDownload Include="ReportGenerator" Version="[5.1.23]" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Src/FluentAssertions.Json/IJsonAssertionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public interface IJsonAssertionOptions<T>
/// <param name="action">
/// The assertion to execute when the predicate is met.
/// </param>
IJsonAssertionRestriction<T,TProperty> Using<TProperty>(Action<IAssertionContext<TProperty>> action);
IJsonAssertionRestriction<T, TProperty> Using<TProperty>(Action<IAssertionContext<TProperty>> action);
}
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions.Json/IJsonAssertionRestriction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public interface IJsonAssertionRestriction<T, TMember>
/// </summary>
public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>() where TMemberType : TMember;
}
}
}
1 change: 1 addition & 0 deletions Src/FluentAssertions.Json/JTokenDifferentiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ private Difference CompareValues(JValue actual, JValue expected, JPath path)

return null;
}

private static string Describe(JTokenType jTokenType)
{
return jTokenType switch
Expand Down
4 changes: 2 additions & 2 deletions Src/FluentAssertions.Json/JsonAssertionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace FluentAssertions.Json
/// <summary>
/// Represents the run-time type-specific behavior of a JSON structural equivalency assertion. It is the equivalent of <see cref="FluentAssertions.Equivalency.EquivalencyAssertionOptions{T}"/>
/// </summary>
public sealed class JsonAssertionOptions<T> : EquivalencyAssertionOptions<T> , IJsonAssertionOptions<T>
public sealed class JsonAssertionOptions<T> : EquivalencyAssertionOptions<T>, IJsonAssertionOptions<T>
{
public JsonAssertionOptions(EquivalencyAssertionOptions<T> equivalencyAssertionOptions) : base(equivalencyAssertionOptions)
{
Expand All @@ -17,4 +17,4 @@ public JsonAssertionOptions(EquivalencyAssertionOptions<T> equivalencyAssertionO
return new JsonAssertionRestriction<T, TProperty>(base.Using(action));
}
}
}
}
3 changes: 2 additions & 1 deletion Src/FluentAssertions.Json/JsonAssertionRestriction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ internal JsonAssertionRestriction(JsonAssertionOptions<T>.Restriction<TProperty>
this.restriction = restriction;
}

public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>() where TMemberType : TProperty
public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>()
where TMemberType : TProperty
{
return (JsonAssertionOptions<T>)restriction.WhenTypeIs<TMemberType>();
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CA1825: Avoid unnecessary zero-length array allocations. Use Array.Empty<int>() instead
dotnet_diagnostic.CA1825.severity = none
Loading