Skip to content

Commit 41f1df4

Browse files
authored
Merge pull request #73 from jnyrup/jn/nugets
2 parents c543cec + 9120f22 commit 41f1df4

File tree

18 files changed

+432
-374
lines changed

18 files changed

+432
-374
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ jobs:
1717
DOTNET_NOLOGO: true
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
2323

2424
- name: Setup .NET SDKs
25-
uses: actions/setup-dotnet@v1
25+
uses: actions/setup-dotnet@v4
2626
with:
2727
dotnet-version: |
28-
3.1.x
29-
5.0.x
28+
6.0.x
29+
8.0.x
3030
3131
- name: Run NUKE
3232
run: ./build.ps1
@@ -36,12 +36,12 @@ jobs:
3636
ApiKey: ${{ secrets.NUGETAPIKEY }}
3737

3838
- name: coveralls
39-
uses: coverallsapp/github-action@1.1.3
39+
uses: coverallsapp/github-action@v2
4040
with:
4141
github-token: ${{ secrets.GITHUB_TOKEN }}
42-
path-to-lcov: TestResults/reports/lcov.info
42+
file: TestResults/reports/lcov.info
4343

4444
- name: Upload artifacts
45-
uses: actions/upload-artifact@v2
45+
uses: actions/upload-artifact@v4
4646
with:
4747
path: ./Artifacts/*

.nuke/build.schema.json

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"title": "Build Schema",
4-
"$ref": "#/definitions/build",
53
"definitions": {
6-
"build": {
7-
"type": "object",
4+
"Host": {
5+
"type": "string",
6+
"enum": [
7+
"AppVeyor",
8+
"AzurePipelines",
9+
"Bamboo",
10+
"Bitbucket",
11+
"Bitrise",
12+
"GitHubActions",
13+
"GitLab",
14+
"Jenkins",
15+
"Rider",
16+
"SpaceAutomation",
17+
"TeamCity",
18+
"Terminal",
19+
"TravisCI",
20+
"VisualStudio",
21+
"VSCode"
22+
]
23+
},
24+
"ExecutableTarget": {
25+
"type": "string",
26+
"enum": [
27+
"ApiChecks",
28+
"CalculateNugetVersion",
29+
"Clean",
30+
"CodeCoverage",
31+
"Compile",
32+
"Pack",
33+
"Push",
34+
"Restore",
35+
"UnitTests"
36+
]
37+
},
38+
"Verbosity": {
39+
"type": "string",
40+
"description": "",
41+
"enum": [
42+
"Verbose",
43+
"Normal",
44+
"Minimal",
45+
"Quiet"
46+
]
47+
},
48+
"NukeBuild": {
849
"properties": {
9-
"ApiKey": {
10-
"type": "string",
11-
"description": "The key to push to Nuget"
12-
},
13-
"BranchSpec": {
14-
"type": "string",
15-
"description": "A branch specification such as develop or refs/pull/1775/merge"
16-
},
17-
"BuildNumber": {
18-
"type": "string",
19-
"description": "An incrementing build number as provided by the build engine"
20-
},
2150
"Continue": {
2251
"type": "boolean",
2352
"description": "Indicates to continue a previously failed build attempt"
@@ -27,24 +56,8 @@
2756
"description": "Shows the help text for this build assembly"
2857
},
2958
"Host": {
30-
"type": "string",
3159
"description": "Host for execution. Default is 'automatic'",
32-
"enum": [
33-
"AppVeyor",
34-
"AzurePipelines",
35-
"Bamboo",
36-
"Bitrise",
37-
"GitHubActions",
38-
"GitLab",
39-
"Jenkins",
40-
"Rider",
41-
"SpaceAutomation",
42-
"TeamCity",
43-
"Terminal",
44-
"TravisCI",
45-
"VisualStudio",
46-
"VSCode"
47-
]
60+
"$ref": "#/definitions/Host"
4861
},
4962
"NoLogo": {
5063
"type": "boolean",
@@ -73,53 +86,39 @@
7386
"type": "array",
7487
"description": "List of targets to be skipped. Empty list skips all dependencies",
7588
"items": {
76-
"type": "string",
77-
"enum": [
78-
"ApiChecks",
79-
"CalculateNugetVersion",
80-
"Clean",
81-
"CodeCoverage",
82-
"Compile",
83-
"Pack",
84-
"Push",
85-
"Restore",
86-
"UnitTests"
87-
]
89+
"$ref": "#/definitions/ExecutableTarget"
8890
}
8991
},
90-
"Solution": {
91-
"type": "string",
92-
"description": "Path to a solution file that is automatically loaded"
93-
},
9492
"Target": {
9593
"type": "array",
9694
"description": "List of targets to be invoked. Default is '{default_target}'",
9795
"items": {
98-
"type": "string",
99-
"enum": [
100-
"ApiChecks",
101-
"CalculateNugetVersion",
102-
"Clean",
103-
"CodeCoverage",
104-
"Compile",
105-
"Pack",
106-
"Push",
107-
"Restore",
108-
"UnitTests"
109-
]
96+
"$ref": "#/definitions/ExecutableTarget"
11097
}
11198
},
11299
"Verbosity": {
113-
"type": "string",
114100
"description": "Logging verbosity during build execution. Default is 'Normal'",
115-
"enum": [
116-
"Minimal",
117-
"Normal",
118-
"Quiet",
119-
"Verbose"
120-
]
101+
"$ref": "#/definitions/Verbosity"
102+
}
103+
}
104+
}
105+
},
106+
"allOf": [
107+
{
108+
"properties": {
109+
"ApiKey": {
110+
"type": "string",
111+
"description": "The key to push to Nuget",
112+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
113+
},
114+
"Solution": {
115+
"type": "string",
116+
"description": "Path to a solution file that is automatically loaded"
121117
}
122118
}
119+
},
120+
{
121+
"$ref": "#/definitions/NukeBuild"
123122
}
124-
}
125-
}
123+
]
124+
}

Build/Build.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using Nuke.Common;
4+
using Nuke.Common.CI.GitHubActions;
55
using Nuke.Common.Execution;
66
using Nuke.Common.IO;
77
using Nuke.Common.ProjectModel;
@@ -11,13 +11,11 @@
1111
using Nuke.Common.Tools.ReportGenerator;
1212
using Nuke.Common.Tools.Xunit;
1313
using Nuke.Common.Utilities.Collections;
14-
using static Nuke.Common.IO.FileSystemTasks;
15-
using static Nuke.Common.IO.PathConstruction;
1614
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1715
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
1816

19-
[CheckBuildProjectConfigurations]
2017
[UnsetVisualStudioEnvironmentVariables]
18+
[DotNetVerbosityMapping]
2119
class Build : NukeBuild
2220
{
2321
/* Support plugins are available for:
@@ -28,19 +26,20 @@ class Build : NukeBuild
2826
*/
2927
public static int Main() => Execute<Build>(x => x.Push);
3028

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

34-
[Parameter("An incrementing build number as provided by the build engine")]
35-
readonly string BuildNumber;
31+
string BranchSpec => GitHubActions?.Ref;
32+
33+
string BuildNumber => GitHubActions?.RunNumber.ToString();
3634

3735
[Parameter("The key to push to Nuget")]
36+
[Secret]
3837
readonly string ApiKey;
3938

4039
[Solution(GenerateProjects = true)]
4140
readonly Solution Solution;
4241

43-
[GitVersion(Framework = "net5.0")]
42+
[GitVersion(Framework = "net6.0")]
4443
readonly GitVersion GitVersion;
4544

4645
AbsolutePath SourceDirectory => RootDirectory / "src";
@@ -54,9 +53,9 @@ class Build : NukeBuild
5453
Target Clean => _ => _
5554
.Executes(() =>
5655
{
57-
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
58-
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
59-
EnsureCleanDirectory(ArtifactsDirectory);
56+
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(path => path.DeleteDirectory());
57+
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(path => path.DeleteDirectory());
58+
ArtifactsDirectory.CreateOrCleanDirectory();
6059
});
6160

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

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

8079
Target Restore => _ => _
8180
.DependsOn(Clean)
@@ -122,7 +121,7 @@ class Build : NukeBuild
122121

123122
DotNetTest(s => s
124123
.SetProjectFile(Solution.FluentAssertions_Json_Specs)
125-
.SetFramework("netcoreapp3.0")
124+
.SetFramework("net8.0")
126125
.SetConfiguration("Debug")
127126
.EnableNoBuild()
128127
.SetDataCollector("XPlat Code Coverage")
@@ -134,7 +133,7 @@ class Build : NukeBuild
134133
.Executes(() =>
135134
{
136135
ReportGenerator(s => s
137-
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net5.0"))
136+
.SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net6.0"))
138137
.SetTargetDirectory(RootDirectory / "TestResults" / "reports")
139138
.AddReports(RootDirectory / "TestResults/**/coverage.cobertura.xml")
140139
.AddReportTypes("HtmlInline_AzurePipelines_Dark", "lcov")
@@ -168,9 +167,9 @@ class Build : NukeBuild
168167
.OnlyWhenDynamic(() => IsTag)
169168
.Executes(() =>
170169
{
171-
IReadOnlyCollection<string> packages = GlobFiles(ArtifactsDirectory, "*.nupkg");
170+
var packages = ArtifactsDirectory.GlobFiles("*.nupkg");
172171

173-
Assert.NotEmpty(packages.ToList());
172+
Assert.NotEmpty(packages);
174173

175174
DotNetNuGetPush(s => s
176175
.SetApiKey(ApiKey)
@@ -181,5 +180,5 @@ class Build : NukeBuild
181180
(v, path) => v.SetTargetPath(path)));
182181
});
183182

184-
bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.InvariantCultureIgnoreCase);
183+
bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.OrdinalIgnoreCase);
185184
}

Build/_build.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<RootNamespace></RootNamespace>
77
<NoWarn>CS0649;CS0169</NoWarn>
88
<NukeRootDirectory>..\</NukeRootDirectory>
99
<NukeScriptDirectory>..\</NukeScriptDirectory>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Nuke.Common" Version="6.0.1" />
14-
<PackageDownload Include="GitVersion.Tool" Version="[5.8.2]" />
15-
<PackageDownload Include="ReportGenerator" Version="[5.0.4]" />
13+
<PackageReference Include="Nuke.Common" Version="8.1.4" />
14+
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
15+
<PackageDownload Include="GitVersion.Tool" Version="[5.12.0]" />
16+
<PackageDownload Include="ReportGenerator" Version="[5.1.23]" />
1617
</ItemGroup>
1718

1819
</Project>

Src/FluentAssertions.Json/IJsonAssertionOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface IJsonAssertionOptions<T>
1515
/// <param name="action">
1616
/// The assertion to execute when the predicate is met.
1717
/// </param>
18-
IJsonAssertionRestriction<T,TProperty> Using<TProperty>(Action<IAssertionContext<TProperty>> action);
18+
IJsonAssertionRestriction<T, TProperty> Using<TProperty>(Action<IAssertionContext<TProperty>> action);
1919
}
2020
}

Src/FluentAssertions.Json/IJsonAssertionRestriction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ public interface IJsonAssertionRestriction<T, TMember>
1111
/// </summary>
1212
public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>() where TMemberType : TMember;
1313
}
14-
}
14+
}

Src/FluentAssertions.Json/JTokenDifferentiator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ private Difference CompareValues(JValue actual, JValue expected, JPath path)
230230

231231
return null;
232232
}
233+
233234
private static string Describe(JTokenType jTokenType)
234235
{
235236
return jTokenType switch

Src/FluentAssertions.Json/JsonAssertionOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace FluentAssertions.Json
66
/// <summary>
77
/// Represents the run-time type-specific behavior of a JSON structural equivalency assertion. It is the equivalent of <see cref="FluentAssertions.Equivalency.EquivalencyAssertionOptions{T}"/>
88
/// </summary>
9-
public sealed class JsonAssertionOptions<T> : EquivalencyAssertionOptions<T> , IJsonAssertionOptions<T>
9+
public sealed class JsonAssertionOptions<T> : EquivalencyAssertionOptions<T>, IJsonAssertionOptions<T>
1010
{
1111
public JsonAssertionOptions(EquivalencyAssertionOptions<T> equivalencyAssertionOptions) : base(equivalencyAssertionOptions)
1212
{
@@ -17,4 +17,4 @@ public JsonAssertionOptions(EquivalencyAssertionOptions<T> equivalencyAssertionO
1717
return new JsonAssertionRestriction<T, TProperty>(base.Using(action));
1818
}
1919
}
20-
}
20+
}

Src/FluentAssertions.Json/JsonAssertionRestriction.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ internal JsonAssertionRestriction(JsonAssertionOptions<T>.Restriction<TProperty>
99
this.restriction = restriction;
1010
}
1111

12-
public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>() where TMemberType : TProperty
12+
public IJsonAssertionOptions<T> WhenTypeIs<TMemberType>()
13+
where TMemberType : TProperty
1314
{
1415
return (JsonAssertionOptions<T>)restriction.WhenTypeIs<TMemberType>();
1516
}

Tests/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# CA1825: Avoid unnecessary zero-length array allocations. Use Array.Empty<int>() instead
4+
dotnet_diagnostic.CA1825.severity = none

0 commit comments

Comments
 (0)