Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
content-source-match: ${{ steps.event-check.outputs.content-source-match != '' && steps.event-check.outputs.content-source-match || steps.match.outputs.content-source-match }}
content-source-next: ${{ steps.event-check.outputs.content-source-next != '' && steps.event-check.outputs.content-source-next || steps.match.outputs.content-source-next }}
content-source-current: ${{ steps.event-check.outputs.content-source-current != '' && steps.event-check.outputs.content-source-current || steps.match.outputs.content-source-current }}
content-source-edge: ${{ steps.event-check.outputs.content-source-edge != '' && steps.event-check.outputs.content-source-edge || steps.match.outputs.content-source-edge }}
content-source-speculative: ${{ steps.event-check.outputs.content-source-speculative != '' && steps.event-check.outputs.content-source-speculative || steps.match.outputs.content-source-speculative }}
steps:
- name: Not a push event
Expand All @@ -92,6 +93,7 @@ jobs:
echo "content-source-match=true" >> $GITHUB_OUTPUT
echo "content-source-next=false" >> $GITHUB_OUTPUT
echo "content-source-current=false" >> $GITHUB_OUTPUT
echo "content-source-edge=false" >> $GITHUB_OUTPUT
echo "content-source-speculative=false" >> $GITHUB_OUTPUT
- name: Match for push events
id: match
Expand All @@ -106,6 +108,7 @@ jobs:
echo "content-source-match=${{ steps.event-check.outputs.content-source-match != '' && steps.event-check.outputs.content-source-match || steps.match.outputs.content-source-match }}"
echo "content-source-next=${{ steps.event-check.outputs.content-source-next != '' && steps.event-check.outputs.content-source-next || steps.match.outputs.content-source-next }}"
echo "content-source-current=${{ steps.event-check.outputs.content-source-current != '' && steps.event-check.outputs.content-source-current || steps.match.outputs.content-source-current }}"
echo "content-source-current=${{ steps.event-check.outputs.content-source-edge != '' && steps.event-check.outputs.content-source-edge || steps.match.outputs.content-source-edge }}"
echo "content-source-speculative=${{ steps.event-check.outputs.content-source-speculative != '' && steps.event-check.outputs.content-source-speculative || steps.match.outputs.content-source-speculative }}"
echo "ref=${{ github.ref_name }}"
echo "repo=${{ github.repository }}"
Expand Down Expand Up @@ -460,11 +463,6 @@ jobs:
env.MATCH == 'true'
&& (
contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
&& (
needs.match.outputs.content-source-current == 'true'
|| needs.match.outputs.content-source-next == 'true'
|| needs.match.outputs.content-source-speculative == 'true'
)
&& steps.s3-upload.outcome == 'success'
)
uses: elastic/docs-builder/actions/update-link-index@main
Expand Down
2 changes: 2 additions & 0 deletions actions/assembler-match/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ outputs:
description: "true/false indicating the branch acts as the next content source"
content-source-current:
description: "true/false indicating the branch acts as the current content source"
content-source-edge:
description: "true/false indicating the branch acts as the edge content source"
content-source-speculative:
description: "true/false speculative match, used to build version branches before they are marked as current/next"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
/// <paramref name="repository"/>.
public ContentSourceMatch Match(string repository, string branchOrTag)
{
var match = new ContentSourceMatch(null, null, false);
var match = new ContentSourceMatch(null, null, null, false);
var tokens = repository.Split('/');
var repositoryName = tokens.Last();
var owner = tokens.First();
Expand All @@ -141,34 +141,29 @@
{
var current = r.GetBranch(ContentSource.Current);
var next = r.GetBranch(ContentSource.Next);
var edge = r.GetBranch(ContentSource.Edge);
var isVersionBranch = ContentSourceRegex.MatchVersionBranch().IsMatch(branchOrTag);
if (current == branchOrTag)
match = match with { Current = ContentSource.Current };

if (next == branchOrTag)
match = match with
{
Next = ContentSource.Next
};
match = match with { Next = ContentSource.Next };

if (edge == branchOrTag)
match = match with { Edge = ContentSource.Edge };

if (isVersionBranch && SemVersion.TryParse(branchOrTag + ".0", out var v))
{
// if the current branch is a version, only speculatively match if branch is actually a new version
if (SemVersion.TryParse(current + ".0", out var currentVersion))
{
if (v >= currentVersion)
match = match with
{
Speculative = true
};
match = match with { Speculative = true };
}
// assume we are newly onboarding the repository to current/next
else
match = match with
{
Speculative = true
};
match = match with { Speculative = true };
}

return match;
}

Expand All @@ -177,27 +172,27 @@
// this is an unknown new elastic repository
var isVersionBranch = ContentSourceRegex.MatchVersionBranch().IsMatch(branchOrTag);
if (isVersionBranch || branchOrTag == "main" || branchOrTag == "master")
return match with
{
Speculative = true
};
return match with { Speculative = true };
}

if (Narrative.GetBranch(ContentSource.Current) == branchOrTag)
match = match with
{
Current = ContentSource.Current
};
match = match with { Current = ContentSource.Current };

if (Narrative.GetBranch(ContentSource.Next) == branchOrTag)
match = match with
{
Next = ContentSource.Next
};
match = match with { Next = ContentSource.Next };

if (Narrative.GetBranch(ContentSource.Edge) == branchOrTag)
match = match with { Edge = ContentSource.Edge };

// if we haven't matched anything yet, and the branch is 'main' or 'master' always build
if (match is { Current: null, Next: null, Edge: null, Speculative: false}

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build (elastic/oblt-actions)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build (elastic/opentelemetry)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build (elastic/elasticsearch)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build (elastic/docs-content)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / validate-assembler

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / integration

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / integration

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / synthetics

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 188 in src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

View workflow job for this annotation

GitHub Actions / build

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
&& branchOrTag is "main" or "master")
return match with { Speculative = true };

return match;
}

public record ContentSourceMatch(ContentSource? Current, ContentSource? Next, bool Speculative);
public record ContentSourceMatch(ContentSource? Current, ContentSource? Next, ContentSource? Edge, bool Speculative);
}

internal static partial class ContentSourceRegex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public async Task<bool> ShouldBuild(IDiagnosticsCollector collector, string? rep
// environment does not matter to check the configuration, defaulting to dev
var assembleContext = new AssembleContext(configuration, configurationContext, "dev", collector, fileSystem, fileSystem, null, null);
var matches = assembleContext.Configuration.Match(repo, refName);
if (matches is { Current: null, Next: null, Speculative: false })
if (matches is { Current: null, Next: null, Edge: null, Speculative: false })
{
_logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repo, refName);
await githubActionsService.SetOutputAsync("content-source-match", "false");
await githubActionsService.SetOutputAsync("content-source-next", "false");
await githubActionsService.SetOutputAsync("content-source-edge", "false");
await githubActionsService.SetOutputAsync("content-source-current", "false");
await githubActionsService.SetOutputAsync("content-source-speculative", "false");
return false;
Expand All @@ -60,6 +61,7 @@ public async Task<bool> ShouldBuild(IDiagnosticsCollector collector, string? rep
await githubActionsService.SetOutputAsync("content-source-match", "true");
await githubActionsService.SetOutputAsync("content-source-next", matches.Next is not null ? "true" : "false");
await githubActionsService.SetOutputAsync("content-source-current", matches.Current is not null ? "true" : "false");
await githubActionsService.SetOutputAsync("content-source-edge", matches.Edge is not null ? "true" : "false");
await githubActionsService.SetOutputAsync("content-source-speculative", matches.Speculative ? "true" : "false");
return true;
}
Expand Down
Loading