Skip to content

Commit 7f83a80

Browse files
committed
Move cake test to a new project dedicated to cake
And some other touch-ups
1 parent 66ae53b commit 7f83a80

File tree

11 files changed

+69
-26
lines changed

11 files changed

+69
-26
lines changed

azure-pipelines.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ stages:
122122
--no-build $(testModifier)
123123
-c $(BuildConfiguration)
124124
--filter "TestCategory!=FailsOnAzurePipelines"
125-
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.trx"
125+
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.x64.trx"
126126
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
127127
--collect:"XPlat Code Coverage"
128128
--
@@ -135,7 +135,7 @@ stages:
135135
--no-build $(testModifier)
136136
-c $(BuildConfiguration)
137137
--filter "TestCategory!=FailsOnAzurePipelines"
138-
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.trx"
138+
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.x86.trx"
139139
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
140140
--collect:"XPlat Code Coverage"
141141
--
@@ -144,6 +144,19 @@ stages:
144144
workingDirectory: src
145145
condition: ne(variables['dotnet32'], '')
146146
147+
- script: >
148+
dotnet test Cake.GitVersioning.Tests
149+
--no-build $(testModifier)
150+
-c $(BuildConfiguration)
151+
--filter "TestCategory!=FailsOnAzurePipelines"
152+
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.cake.trx"
153+
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
154+
--collect:"XPlat Code Coverage"
155+
--
156+
RunConfiguration.DisableAppDomain=true
157+
displayName: Run cake tests
158+
workingDirectory: src
159+
147160
- task: PublishCodeCoverageResults@1
148161
displayName: Publish code coverage results
149162
inputs:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net5.0;net461</TargetFrameworks>
5+
<SignAssembly>false</SignAssembly>
6+
<IsTestProject>true</IsTestProject>
7+
<IsPackable>false</IsPackable>
8+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
9+
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
10+
<DebugType>full</DebugType>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\Cake.GitVersioning\Cake.GitVersioning.csproj" />
15+
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
16+
</ItemGroup>
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
19+
<PackageReference Include="xunit" Version="2.4.1" />
20+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
<PrivateAssets>all</PrivateAssets>
23+
</PackageReference>
24+
<PackageReference Include="coverlet.collector" Version="1.3.0" />
25+
</ItemGroup>
26+
27+
</Project>

src/NerdBank.GitVersioning.Tests/GitVersioningCloudProviderTests.cs renamed to src/Cake.GitVersioning.Tests/GitVersioningCloudProviderTests.cs

File renamed without changes.

src/Cake.GitVersioning/Cake.GitVersioning.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
65
<GenerateDocumentationFile>true</GenerateDocumentationFile>
76
<Authors>Chris Crutchfield, Andrew Arnott</Authors>
87
<Company>andarno</Company>

src/Cake.GitVersioning/GitVersioningAliases.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Cake.Core;
77
using Cake.Core.Annotations;
88
using Nerdbank.GitVersioning;
9+
using Nerdbank.GitVersioning.Commands;
910

1011
/// <summary>
1112
/// Contains functionality for using Nerdbank.GitVersioning.
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
namespace Cake.GitVersioning
1+
#nullable enable
2+
3+
namespace Cake.GitVersioning
24
{
5+
using System;
36
using System.Collections.Generic;
47

58
/// <summary>
@@ -8,35 +11,35 @@
811
public class GitVersioningCloudSettings
912
{
1013
/// <summary>
11-
/// The string to use for the cloud build number.
12-
/// If not value os specified, the computed version will be used.
14+
/// The string to use for the cloud build number.
15+
/// If no value is specified, the computed version will be used.
1316
/// </summary>
14-
public string Version { get; set; } = null;
17+
public string? Version { get; set; }
1518

1619
/// <summary>
1720
/// Adds an identifier to the build metadata part of a semantic version.
1821
/// </summary>
19-
public IList<string> Metadata { get; set; } = new List<string>();
22+
public List<string> Metadata { get; } = new();
2023

2124
/// <summary>
2225
/// Force activation for a particular CI system. If not specified,
2326
/// auto-detection will be used.
2427
/// </summary>
25-
public GitVersioningCloudProvider? CISystem { get; set; } = null;
28+
public GitVersioningCloudProvider? CISystem { get; set; }
2629

2730
/// <summary>
2831
/// Defines ALL version variables as cloud build variables, with a "NBGV_" prefix.
2932
/// </summary>
30-
public bool AllVariables { get; set; } = false;
33+
public bool AllVariables { get; set; }
3134

3235
/// <summary>
3336
/// Defines a few common version variables as cloud build variables, with a "Git" prefix.
3437
/// </summary>
35-
public bool CommonVariables { get; set; } = false;
38+
public bool CommonVariables { get; set; }
3639

3740
/// <summary>
3841
/// Additional cloud build variables to define.
3942
/// </summary>
40-
public IDictionary<string, string> AdditionalVariables { get; set; } = new Dictionary<string, string>();
43+
public Dictionary<string, string> AdditionalVariables { get; } = new(StringComparer.OrdinalIgnoreCase);
4144
}
4245
}

src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<EmbeddedResource Include="repos\*" />
2929
</ItemGroup>
3030
<ItemGroup>
31-
<ProjectReference Include="..\Cake.GitVersioning\Cake.GitVersioning.csproj" />
3231
<ProjectReference Include="..\Nerdbank.GitVersioning.Tasks\Nerdbank.GitVersioning.Tasks.csproj" />
3332
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
3433
</ItemGroup>

src/NerdBank.GitVersioning/CloudCommand.cs renamed to src/NerdBank.GitVersioning/Commands/CloudCommand.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Nerdbank.GitVersioning
1+
namespace Nerdbank.GitVersioning.Commands
22
{
33
using System;
44
using System.Collections.Generic;
@@ -7,7 +7,7 @@
77
using Validation;
88

99
/// <summary>
10-
/// Implementation of the "nbgv cloud" command that updates the build environments variables with version variables
10+
/// Implementation of the "nbgv cloud" command that updates the build environments variables with version variables.
1111
/// </summary>
1212
public class CloudCommand
1313
{
@@ -17,23 +17,23 @@ public class CloudCommand
1717
public enum CloudCommandError
1818
{
1919
/// <summary>
20-
/// Teh specified CI system was not found
20+
/// The specified CI system was not found.
2121
/// </summary>
2222
NoCloudBuildProviderMatch,
2323

2424
/// <summary>
25-
/// A cloud variable was defined multiple times
25+
/// A cloud variable was defined multiple times.
2626
/// </summary>
2727
DuplicateCloudVariable,
2828

2929
/// <summary>
30-
/// No supported cloud build environment could be detected
30+
/// No supported cloud build environment could be detected.
3131
/// </summary>
32-
NoCloudBuildEnvDetected
32+
NoCloudBuildEnvDetected,
3333
}
3434

3535
/// <summary>
36-
/// Exception indicating an error while setting build variables
36+
/// Exception indicating an error while setting build variables.
3737
/// </summary>
3838
public class CloudCommandException : Exception
3939
{
@@ -43,7 +43,7 @@ public class CloudCommandException : Exception
4343
public CloudCommandError Error { get; }
4444

4545
/// <summary>
46-
/// Initializes a new instance of <see cref="CloudCommandException"/>
46+
/// Initializes a new instance of <see cref="CloudCommandException"/> class.
4747
/// </summary>
4848
/// <param name="message">The message that describes the error.</param>
4949
/// <param name="error">The error that occurred.</param>
@@ -79,7 +79,7 @@ public CloudCommand(TextWriter outputWriter = null, TextWriter errorWriter = nul
7979
/// The string to use for the cloud build number. If not specified, the computed version will be used.
8080
/// </param>
8181
/// <param name="ciSystem">
82-
/// The CI system to activate. If not specified, auto-detection will be used.
82+
/// The CI system to activate. If not specified, auto-detection will be used.
8383
/// </param>
8484
/// <param name="allVars">
8585
/// Controls whether to define all version variables as cloud build variables.

src/NerdBank.GitVersioning/LibGit2/LibGit2Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public override bool TrySelectCommit(string committish)
7777
}
7878

7979
/// <inheritdoc />
80-
public override void Stage(string path) => Commands.Stage(this.Repository, path);
80+
public override void Stage(string path) => global::LibGit2Sharp.Commands.Stage(this.Repository, path);
8181

8282
/// <inheritdoc/>
8383
public override string GetShortUniqueCommitId(int minLength) => this.Repository.ObjectDatabase.ShortenObjectId(this.Commit, minLength);

src/NerdBank.GitVersioning/ReleaseManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public void PrepareRelease(string projectDirectory, string releaseUnstableTag =
295295

296296
// create release branch and update version
297297
var releaseBranch = repository.CreateBranch(releaseBranchName);
298-
Commands.Checkout(repository, releaseBranch);
298+
global::LibGit2Sharp.Commands.Checkout(repository, releaseBranch);
299299
this.UpdateVersion(context, versionOptions.Version, releaseVersion);
300300

301301
if (outputMode == ReleaseManagerOutputMode.Text)
@@ -304,7 +304,7 @@ public void PrepareRelease(string projectDirectory, string releaseUnstableTag =
304304
}
305305

306306
// update version on main branch
307-
Commands.Checkout(repository, originalBranchName);
307+
global::LibGit2Sharp.Commands.Checkout(repository, originalBranchName);
308308
this.UpdateVersion(context, versionOptions.Version, nextDevVersion);
309309

310310
if (outputMode == ReleaseManagerOutputMode.Text)
@@ -371,7 +371,7 @@ private void UpdateVersion(LibGit2Context context, SemanticVersion oldVersion, S
371371
versionOptions.Version = newVersion;
372372
var filePath = context.VersionFile.SetVersion(context.AbsoluteProjectDirectory, versionOptions, includeSchemaProperty: true);
373373

374-
Commands.Stage(context.Repository, filePath);
374+
global::LibGit2Sharp.Commands.Stage(context.Repository, filePath);
375375

376376
// Author a commit only if we effectively changed something.
377377
if (!context.Repository.Head.Tip.Tree.Equals(context.Repository.Index.WriteToTree()))

0 commit comments

Comments
 (0)