Skip to content

Commit 9d15314

Browse files
committed
(ci) additional information to the setup/teardown
1 parent 2cc34e3 commit 9d15314

File tree

9 files changed

+51
-40
lines changed

9 files changed

+51
-40
lines changed

build/artifacts/BuildLifetime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from arch in archs
3030

3131
LogBuildInformation(context);
3232

33-
context.Information("IsDockerOnLinux: {0}", context.IsDockerOnLinux);
33+
context.Information($"IsDockerOnLinux: {context.IsDockerOnLinux}");
3434
context.Information($"Building for Version: {dotnetVersion}, Distro: {dockerDistro}");
3535
context.EndGroup();
3636
}

build/build/BuildLifetime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public override void Setup(BuildContext context, ISetupContext info)
2222

2323
context.StartGroup("Build Setup");
2424
LogBuildInformation(context);
25-
context.Information("Configuration: {0}", context.MsBuildConfiguration);
25+
context.Information($"Configuration: {context.MsBuildConfiguration}");
2626
context.EndGroup();
2727
}
2828

build/common/Lifetime/BuildLifetimeBase.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public override void Setup(T context, ISetupContext info)
1515

1616
context.IsPullRequest = buildSystem.IsPullRequest;
1717
context.BranchName = context.GetBranchName();
18+
context.RepositoryName = context.GetRepositoryName();
1819
context.IsOriginalRepo = context.IsOriginalRepo();
1920
context.IsMainBranch = context.IsMainBranch();
2021
context.IsSupportBranch = context.IsSupportBranch();
@@ -48,12 +49,7 @@ public override void Teardown(T context, ITeardownContext info)
4849
{
4950
context.Information("Starting Teardown...");
5051

51-
context.Information("Pull Request: {0}", context.IsPullRequest);
52-
context.Information("Original Repo: {0}", context.IsOriginalRepo);
53-
context.Information("Branch Name: {0}", context.BranchName);
54-
context.Information("Main Branch: {0}", context.IsMainBranch);
55-
context.Information("Support Branch: {0}", context.IsSupportBranch);
56-
context.Information("Tagged: {0}", context.IsTagged);
52+
LogBuildInformation(context);
5753

5854
context.Information("Finished running tasks.");
5955
}
@@ -67,16 +63,23 @@ protected void LogBuildInformation(T context)
6763
{
6864
if (context.HasArgument(Arguments.Target))
6965
{
70-
context.Information("Target: {0}", context.Argument<string>(Arguments.Target));
66+
context.Information($"Target: {context.Argument<string>(Arguments.Target)}");
7167
}
72-
context.Information("Version: {0}", context.Version?.SemVersion);
73-
context.Information("Build Agent: {0}", context.GetBuildAgent());
74-
context.Information("OS: {0}", context.GetOS());
75-
context.Information("Pull Request: {0}", context.IsPullRequest);
76-
context.Information("Original Repo: {0}", context.IsOriginalRepo);
77-
context.Information("Branch Name: {0}", context.BranchName);
78-
context.Information("Main Branch: {0}", context.IsMainBranch);
79-
context.Information("Support Branch: {0}", context.IsSupportBranch);
80-
context.Information("Tagged: {0}", context.IsTagged);
68+
if (context.Version is not null)
69+
{
70+
context.Information($"Version: {context.Version.SemVersion}");
71+
}
72+
context.Information($"Build Agent: {context.GetBuildAgent()}");
73+
context.Information($"OS: {context.GetOS()}");
74+
context.Information($"Pull Request: {context.IsPullRequest}");
75+
context.Information($"Repository Name: {context.RepositoryName}");
76+
context.Information($"Original Repository: {context.IsOriginalRepo}");
77+
context.Information($"Branch Name: {context.BranchName}");
78+
context.Information($"Main Branch: {context.IsMainBranch}");
79+
context.Information($"Support Branch: {context.IsSupportBranch}");
80+
context.Information($"Tagged: {context.IsTagged}");
81+
context.Information($"IsStableRelease: {context.IsStableRelease}");
82+
context.Information($"IsTaggedPreRelease: {context.IsTaggedPreRelease}");
83+
context.Information($"IsInternalPreRelease: {context.IsInternalPreRelease}");
8184
}
8285
}

build/common/Utilities/BuildContextBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ protected BuildContextBase(ICakeContext context) : base(context)
99

1010
public bool IsOriginalRepo { get; set; }
1111
public string BranchName { get; set; } = string.Empty;
12+
public string RepositoryName { get; set; } = string.Empty;
1213
public bool IsMainBranch { get; set; }
1314
public bool IsSupportBranch { get; set; }
1415
public bool IsPullRequest { get; set; }

build/common/Utilities/ContextExtensions.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,7 @@ public static void GitPushBranch(this ICakeContext context, DirectoryPath reposi
3030

3131
public static bool IsOriginalRepo(this ICakeContext context)
3232
{
33-
var buildSystem = context.BuildSystem();
34-
string repositoryName = string.Empty;
35-
if (buildSystem.IsRunningOnAppVeyor)
36-
{
37-
repositoryName = buildSystem.AppVeyor.Environment.Repository.Name;
38-
}
39-
else if (buildSystem.IsRunningOnAzurePipelines)
40-
{
41-
repositoryName = buildSystem.AzurePipelines.Environment.Repository.RepoName;
42-
}
43-
else if (buildSystem.IsRunningOnGitHubActions)
44-
{
45-
repositoryName = buildSystem.GitHubActions.Environment.Workflow.Repository;
46-
}
47-
context.Information("Repository Name: {0}", repositoryName);
48-
33+
var repositoryName = context.GetRepositoryName();
4934
return !string.IsNullOrWhiteSpace(repositoryName) && StringComparer.OrdinalIgnoreCase.Equals("gittools/GitVersion", repositoryName);
5035
}
5136

@@ -160,6 +145,25 @@ public static string GetBranchName(this ICakeContext context)
160145
return repositoryBranch;
161146
}
162147

148+
public static string GetRepositoryName(this ICakeContext context)
149+
{
150+
var buildSystem = context.BuildSystem();
151+
string repositoryName = string.Empty;
152+
if (buildSystem.IsRunningOnAppVeyor)
153+
{
154+
repositoryName = buildSystem.AppVeyor.Environment.Repository.Name;
155+
}
156+
else if (buildSystem.IsRunningOnAzurePipelines)
157+
{
158+
repositoryName = buildSystem.AzurePipelines.Environment.Repository.RepoName;
159+
}
160+
else if (buildSystem.IsRunningOnGitHubActions)
161+
{
162+
repositoryName = buildSystem.GitHubActions.Environment.Workflow.Repository;
163+
}
164+
return repositoryName;
165+
}
166+
163167
private static void StartGroup(this IAzurePipelinesCommands _, ICakeContext context, string title) => context.Information("##[group]{0}", title);
164168

165169
private static void EndGroup(this IAzurePipelinesCommands _, ICakeContext context) => context.Information("##[endgroup]");

build/docker/BuildLifetime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ from arch in archs
3131

3232
LogBuildInformation(context);
3333

34-
context.Information("IsDockerOnLinux: {0}", context.IsDockerOnLinux);
34+
context.Information($"IsDockerOnLinux: {context.IsDockerOnLinux}");
3535
context.Information($"Building for Version: {dotnetVersion}, Distro: {dockerDistro}");
3636
context.EndGroup();
3737
}

build/docs/Tasks/GenerateSchemas.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public override void Run(BuildContext context)
1313
var version = $"{gitVersion.Major}.{gitVersion.Minor}";
1414
var schemaTargetDir = context.MakeAbsolute(Paths.Root.Combine("schemas"));
1515
context.EnsureDirectoryExists(schemaTargetDir);
16-
context.Information("Schema tool: {0}", schemaTool);
17-
context.Information("Schema target dir: {0}", schemaTargetDir);
18-
context.Information("Schema version: {0}", version);
16+
context.Information($"Schema tool: {schemaTool}");
17+
context.Information($"Schema target dir: {schemaTargetDir}");
18+
context.Information($"Schema version: {version}");
1919
context.DotNetExecute(schemaTool, $"--Version {version} --OutputDirectory {schemaTargetDir}");
2020
}
2121
}

build/docs/Tasks/PublishDocs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static void PublishDocumentation(BuildContext context)
6868
var sourceCommit = context.GitLogTip("./");
6969

7070
var publishFolder = context.MakeAbsolute(Paths.ArtifactsDocs.Combine("_published").Combine(DateTime.Now.ToString("yyyyMMdd_HHmmss")));
71-
context.Information("Publishing Folder: {0}", publishFolder);
71+
context.Information($"Publishing Folder: {publishFolder}");
7272
context.Information("Getting publish branch...");
7373
context.GitClone($"https://github.com/{Constants.RepoOwner}/{Constants.Repository}", publishFolder, new GitCloneSettings
7474
{

build/publish/Tasks/PublishNuget.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,26 @@ public override void Run(BuildContext context)
2828
// publish to github packages for commits on main and on original repo
2929
if (context.IsInternalPreRelease)
3030
{
31+
context.StartGroup("Publishing to GitHub Packages");
3132
var apiKey = context.Credentials?.GitHub?.Token;
3233
if (string.IsNullOrEmpty(apiKey))
3334
{
3435
throw new InvalidOperationException("Could not resolve NuGet GitHub Packages API key.");
3536
}
3637
PublishToNugetRepo(context, apiKey, Constants.GithubPackagesUrl);
38+
context.EndGroup();
3739
}
3840
// publish to nuget.org for tagged releases
3941
if (context.IsStableRelease || context.IsTaggedPreRelease)
4042
{
43+
context.StartGroup("Publishing to Nuget.org");
4144
var apiKey = context.Credentials?.Nuget?.ApiKey;
4245
if (string.IsNullOrEmpty(apiKey))
4346
{
4447
throw new InvalidOperationException("Could not resolve NuGet org API key.");
4548
}
46-
4749
PublishToNugetRepo(context, apiKey, Constants.NugetOrgUrl);
50+
context.EndGroup();
4851
}
4952
}
5053
private static void PublishToNugetRepo(BuildContext context, string apiKey, string apiUrl)

0 commit comments

Comments
 (0)