Skip to content

Commit 6326aae

Browse files
committed
Smarter CI checks
1 parent 3c9e40d commit 6326aae

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/tooling/docs-assembler/Cli/InboundLinkCommands.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,24 @@ public async Task<int> ValidateLocalLinkReference(string? file = null, string? p
7676
var repository = GitCheckoutInformation.Create(root, new FileSystem(), logger.CreateLogger(nameof(GitCheckoutInformation))).RepositoryName
7777
?? throw new Exception("Unable to determine repository name");
7878

79+
var resolvedFile = fs.FileInfo.New(Path.Combine(root.FullName, file));
80+
7981
var runningOnCi = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"));
82+
if (runningOnCi && !resolvedFile.Exists)
83+
{
84+
_log.LogInformation("Running on CI after a build that produced no {File}, skipping the validation", resolvedFile.FullName);
85+
return 0;
86+
}
8087
if (runningOnCi && !Paths.TryFindDocsFolderFromRoot(fs, root, out _, out _))
8188
{
82-
_log.LogInformation("Running in CI on a folder with no docset.yml file in {Directory}, skipping the validation", root.FullName);
89+
_log.LogInformation("Running on CI, {Directory} has no documentation, skipping the validation", root.FullName);
8390
return 0;
8491
}
8592

86-
var resolvedFile = Path.Combine(root.FullName, file);
8793
_log.LogInformation("Validating {File} in {Directory}", file, root.FullName);
8894

8995
await using var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService).StartAsync(ctx);
90-
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, resolvedFile, ctx);
96+
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, resolvedFile.FullName, ctx);
9197
await collector.StopAsync(ctx);
9298
return collector.Errors;
9399
}

src/tooling/docs-builder/Cli/InboundLinkCommands.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,24 @@ public async Task<int> ValidateLocalLinkReference(string? file = null, string? p
8383
var repository = GitCheckoutInformation.Create(root, new FileSystem(), logger.CreateLogger(nameof(GitCheckoutInformation))).RepositoryName
8484
?? throw new Exception("Unable to determine repository name");
8585

86+
var resolvedFile = fs.FileInfo.New(Path.Combine(root.FullName, file));
87+
8688
var runningOnCi = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"));
89+
if (runningOnCi && !resolvedFile.Exists)
90+
{
91+
_log.LogInformation("Running on CI after a build that produced no {File}, skipping the validation", resolvedFile.FullName);
92+
return 0;
93+
}
8794
if (runningOnCi && !Paths.TryFindDocsFolderFromRoot(fs, root, out _, out _))
8895
{
89-
_log.LogInformation("Running in CI on a folder with no docset.yml file in {Directory}, skipping the validation", root.FullName);
96+
_log.LogInformation("Running on CI, {Directory} has no documentation, skipping the validation", root.FullName);
9097
return 0;
9198
}
9299

93-
var resolvedFile = Path.Combine(root.FullName, file);
94100
_log.LogInformation("Validating {File} in {Directory}", file, root.FullName);
95101

96102
await using var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService).StartAsync(ctx);
97-
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, resolvedFile, ctx);
103+
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, resolvedFile.FullName, ctx);
98104
await collector.StopAsync(ctx);
99105
return collector.Errors;
100106
}

0 commit comments

Comments
 (0)