Skip to content

Commit 5d18f16

Browse files
committed
Update to support TestCentricRunner
1 parent 16a4b96 commit 5d18f16

File tree

8 files changed

+91
-25
lines changed

8 files changed

+91
-25
lines changed

.config/dotnet-tools.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
"dotnet-cake"
99
],
1010
"rollForward": false
11+
},
12+
"gitversion.tool": {
13+
"version": "6.4.0",
14+
"commands": [
15+
"dotnet-gitversion"
16+
],
17+
"rollForward": false
18+
},
19+
"gitreleasemanager.tool": {
20+
"version": "0.20.0",
21+
"commands": [
22+
"dotnet-gitreleasemanager"
23+
],
24+
"rollForward": false
1125
}
1226
}
1327
}

GitVersion.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# This copy of GitVersion.yml is used in building the recipe package itself.
22
next-version: 1.5.0
33
mode: ContinuousDelivery
4-
legacy-semver-padding: 5
5-
build-metadata-padding: 5
6-
commits-since-version-source-padding: 5
74
branches:
8-
master:
9-
regex: ^main$
10-
tag: alpha
5+
main:
6+
label: alpha
117
release:
12-
tag: pre
8+
label: pre
139
pull-request:
14-
tag: pr
10+
label: pr

recipe/build-settings.cake

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,50 @@ public static class BuildSettings
176176
public static string AssemblyInformationalVersion => BuildVersion.AssemblyInformationalVersion;
177177
public static bool IsDevelopmentRelease => PackageVersion.Contains("-dev");
178178

179-
// Standard Directory Structure - not changeable by user
180-
public static string ProjectDirectory => Context.Environment.WorkingDirectory.FullPath + "/";
179+
// Chocolatey.org does not yet support semver 2.0, so we have to use a legacy format
180+
private static string _chocolateyPackageVersion;
181+
public static string ChocolateyPackageVersion
182+
{
183+
get
184+
{
185+
if (!IsPreRelease)
186+
return PackageVersion;
187+
188+
if (_chocolateyPackageVersion == null)
189+
{
190+
// Use PackageVersion as default
191+
_chocolateyPackageVersion = PackageVersion;
192+
193+
var semver = BuildVersion.SemVer;
194+
var label = BuildVersion.PreReleaseLabel;
195+
var suffix = BuildVersion.PreReleaseSuffix;
196+
int num1, num2;
197+
198+
// Our standard pre-releases are in the form <label> "." <num1> ["." <num2>]
199+
// If anything else comes up, we just use the default PackageVersion
200+
if (!suffix.StartsWith(label + "."))
201+
return _chocolateyPackageVersion;
202+
203+
suffix = suffix.Substring(label.Length + 1);
204+
int dot2 = suffix.IndexOf('.');
205+
if (dot2 > 0) // another dot?
206+
{
207+
if (int.TryParse(suffix.Substring(0, dot2), out num1) && int.TryParse(suffix.Substring(dot2 + 1), out num2))
208+
_chocolateyPackageVersion = $"{semver}-{label}{num1:000}-{num2:000}";
209+
}
210+
else // just one dot
211+
{
212+
if (int.TryParse(suffix, out num1))
213+
_chocolateyPackageVersion = $"{semver}-{label}{num1:000}";
214+
}
215+
}
216+
217+
return _chocolateyPackageVersion;
218+
}
219+
}
220+
221+
// Standard Directory Structure - not changeable by user
222+
public static string ProjectDirectory => Context.Environment.WorkingDirectory.FullPath + "/";
181223
public static string SourceDirectory => ProjectDirectory + SRC_DIR;
182224
public static string OutputDirectory => ProjectDirectory + BIN_DIR + Configuration + "/";
183225
public static string NuGetDirectory => ProjectDirectory + NUGET_DIR;

recipe/package-definition.cake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public abstract class PackageDefinition
4040

4141
PackageType = packageType;
4242
PackageId = id;
43-
PackageVersion = BuildSettings.PackageVersion;
43+
// HACK
44+
PackageVersion = packageType == PackageType.Chocolatey ? BuildSettings.ChocolateyPackageVersion : BuildSettings.PackageVersion;
4445
PackageSource = source;
4546
BasePath = basePath ?? BuildSettings.OutputDirectory;
4647
TestRunner = testRunner;

recipe/test-results.cake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ public class ExpectedResult : TestResultSummary
3333

3434
public class ExpectedAssemblyResult
3535
{
36-
public ExpectedAssemblyResult(string name, string expectedRuntime = null)
37-
{
38-
AssemblyName = name;
39-
Runtime = expectedRuntime;
40-
}
41-
42-
public string AssemblyName { get; }
43-
public string Runtime { get; }
36+
public ExpectedAssemblyResult(string name, string expectedRuntime = null, string expectedAgent = null)
37+
{
38+
AssemblyName = name;
39+
Runtime = expectedRuntime;
40+
AgentName = expectedAgent;
41+
}
42+
43+
public string AssemblyName { get; }
44+
public string Runtime { get; }
45+
public string AgentName { get; }
4446
}
4547

4648
public class ActualResult : TestResultSummary

recipe/tools.cake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
// Load all tools used by the recipe
22
#tool NuGet.CommandLine&version=6.9.1
3-
#tool dotnet:?package=GitVersion.Tool&version=5.12.0
4-
#tool dotnet:?package=GitReleaseManager.Tool&version=0.18.0
3+
#tool dotnet:?package=GitVersion.Tool&version=6.4.0
4+
#tool dotnet:?package=GitReleaseManager.Tool&version=0.20.0
55
#addin nuget:?package=Cake.Git&version=5.0.1
66

7+
// Using statements needed in the scripts
8+
using Cake.Git;
9+
using System.Text.RegularExpressions;
10+
using System.Xml;
11+
using SIO = System.IO;
12+
713
public static class Tools
814
{
915
public static DirectoryPath FindInstalledTool(string packageId)

recipe/versioning.cake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,23 @@ public class BuildVersion
4949
PreReleaseLabel = label;
5050
PreReleaseSuffix = suffix;
5151

52-
PackageVersion = packageVersion;
52+
PackageVersion = LegacyPackageVersion = packageVersion;
5353
AssemblyVersion = SemVer + ".0";
5454
AssemblyFileVersion = SemVer;
5555
AssemblyInformationalVersion = packageVersion;
56+
57+
// We use a legacy SemVer 1.0 format for alpha, beta and rc releases on chocolatey
58+
var labelWithDot = label + ".";
59+
int num;
60+
if (suffix.StartsWith(labelWithDot) && int.TryParse(suffix.Substring(labelWithDot.Length), out num))
61+
LegacyPackageVersion = $"{SemVer}-{label}{num:000}";
5662
}
5763

5864
public string BranchName { get; }
5965
public bool IsReleaseBranch { get; }
6066

6167
public string PackageVersion { get; }
68+
public string LegacyPackageVersion { get; }
6269
public string AssemblyVersion { get; }
6370
public string AssemblyFileVersion { get; }
6471
public string AssemblyInformationalVersion { get; }
@@ -97,13 +104,11 @@ public class BuildVersion
97104
case "dev":
98105
case "pre":
99106
case "pr":
100-
suffix += "." + _gitVersion.PreReleaseNumber;
101-
break;
102107
case "rc":
103108
case "alpha":
104109
case "beta":
105110
default:
106-
suffix += "." + _gitVersion.CommitsSinceVersionSource;
111+
suffix += "." + _gitVersion.PreReleaseNumber;
107112
break;
108113
}
109114

0 commit comments

Comments
 (0)