Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Telemetry.Abstractions" Version="10.0.0" />
<PackageVersion Include="Nullean.ScopedFileSystem" Version="0.4.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
<PackageVersion Include="Generator.Equals" Version="3.3.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageVersion Include="KubernetesClient" Version="18.0.5" />
Expand Down
11 changes: 5 additions & 6 deletions src/Elastic.Codex/Building/CodexBuildService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using Elastic.Markdown.Exporters;
using Elastic.Markdown.IO;
using Microsoft.Extensions.Logging;
using Nullean.ScopedFileSystem;

namespace Elastic.Codex.Building;

Expand All @@ -47,7 +46,7 @@ public class CodexBuildService(
public async Task<CodexBuildResult> BuildAll(
CodexContext context,
CodexCloneResult cloneResult,
ScopedFileSystem fileSystem,
IFileSystem fileSystem,
Cancel ctx,
IReadOnlySet<Exporter>? exporters = null)
{
Expand All @@ -67,7 +66,7 @@ public async Task<CodexBuildResult> BuildAll(
var buildContexts = new List<CodexDocumentationSetBuildContext>();

var environment = context.Configuration.Environment ?? "internal";
using var codexLinkIndexReader = new GitLinkIndexReader(environment, FileSystemFactory.AppData, skipFetch: true);
using var codexLinkIndexReader = new GitLinkIndexReader(environment, context.ReadFileSystem, skipFetch: true);

// Phase 1: Load and parse all documentation sets
foreach (var checkout in cloneResult.Checkouts)
Expand Down Expand Up @@ -137,7 +136,7 @@ public async Task<CodexBuildResult> BuildAll(
private async Task<CodexDocumentationSetBuildContext?> LoadDocumentationSet(
CodexContext context,
CodexCheckout checkout,
ScopedFileSystem fileSystem,
IFileSystem fileSystem,
ILinkIndexReader codexLinkIndexReader,
Cancel ctx)
{
Expand Down Expand Up @@ -402,10 +401,10 @@ internal sealed class CodexDocumentationContext(CodexContext codexContext) : ICo
public IDiagnosticsCollector Collector => codexContext.Collector;

/// <inheritdoc />
public ScopedFileSystem ReadFileSystem => codexContext.ReadFileSystem;
public IFileSystem ReadFileSystem => codexContext.ReadFileSystem;

/// <inheritdoc />
public ScopedFileSystem WriteFileSystem => codexContext.WriteFileSystem;
public IFileSystem WriteFileSystem => codexContext.WriteFileSystem;

/// <inheritdoc />
public IDirectoryInfo OutputDirectory => codexContext.OutputDirectory;
Expand Down
13 changes: 6 additions & 7 deletions src/Elastic.Codex/CodexContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Elastic.Documentation.Configuration;
using Elastic.Documentation.Configuration.Codex;
using Elastic.Documentation.Diagnostics;
using Nullean.ScopedFileSystem;

namespace Elastic.Codex;

Expand All @@ -15,8 +14,8 @@ namespace Elastic.Codex;
/// </summary>
public class CodexContext
{
public ScopedFileSystem ReadFileSystem { get; }
public ScopedFileSystem WriteFileSystem { get; }
public IFileSystem ReadFileSystem { get; }
public IFileSystem WriteFileSystem { get; }
public IDiagnosticsCollector Collector { get; }
public CodexConfiguration Configuration { get; }
public IFileInfo ConfigurationPath { get; }
Expand All @@ -35,8 +34,8 @@ public CodexContext(
CodexConfiguration configuration,
IFileInfo configurationPath,
IDiagnosticsCollector collector,
ScopedFileSystem readFileSystem,
ScopedFileSystem writeFileSystem,
IFileSystem readFileSystem,
IFileSystem writeFileSystem,
string? checkoutDirectory,
string? outputDirectory)
{
Expand All @@ -46,10 +45,10 @@ public CodexContext(
ReadFileSystem = readFileSystem;
WriteFileSystem = writeFileSystem;

var defaultCheckoutDirectory = Path.Join(Paths.ApplicationData.FullName, "codex", "clone");
var defaultCheckoutDirectory = Path.Join(Paths.GitCommonRoot.FullName, ".artifacts", "codex", "clone");
CheckoutDirectory = ReadFileSystem.DirectoryInfo.New(checkoutDirectory ?? defaultCheckoutDirectory);

var defaultOutputDirectory = Path.Join(Paths.WorkingDirectoryRoot.FullName, ".artifacts", "codex", "docs");
OutputDirectory = WriteFileSystem.DirectoryInfo.New(outputDirectory ?? defaultOutputDirectory);
OutputDirectory = ReadFileSystem.DirectoryInfo.New(outputDirectory ?? defaultOutputDirectory);
}
}
3 changes: 1 addition & 2 deletions src/Elastic.Codex/Indexing/CodexIndexService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Elastic.Documentation.Isolated;
using Elastic.Documentation.Services;
using Microsoft.Extensions.Logging;
using Nullean.ScopedFileSystem;

namespace Elastic.Codex.Indexing;

Expand All @@ -31,7 +30,7 @@ IsolatedBuildService isolatedBuildService
public async Task<bool> Index(
CodexContext codexContext,
CodexCloneResult cloneResult,
ScopedFileSystem fileSystem,
FileSystem fileSystem,
ElasticsearchIndexOptions esOptions,
Cancel ctx = default)
{
Expand Down
13 changes: 6 additions & 7 deletions src/Elastic.Documentation.Configuration/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Elastic.Documentation.Configuration.Toc;
using Elastic.Documentation.Configuration.Versions;
using Elastic.Documentation.Diagnostics;
using Nullean.ScopedFileSystem;

namespace Elastic.Documentation.Configuration;

Expand All @@ -22,8 +21,8 @@ public record BuildContext : IDocumentationSetContext, IDocumentationConfigurati
public static string Version { get; } = Assembly.GetExecutingAssembly().GetCustomAttributes<AssemblyInformationalVersionAttribute>()
.FirstOrDefault()?.InformationalVersion ?? "0.0.0";

public ScopedFileSystem ReadFileSystem { get; }
public ScopedFileSystem WriteFileSystem { get; }
public IFileSystem ReadFileSystem { get; }
public IFileSystem WriteFileSystem { get; }
public IReadOnlySet<Exporter> AvailableExporters { get; }

public IDirectoryInfo? DocumentationCheckoutDirectory { get; }
Expand Down Expand Up @@ -73,7 +72,7 @@ public string? UrlPathPrefix

public BuildContext(
IDiagnosticsCollector collector,
ScopedFileSystem fileSystem,
IFileSystem fileSystem,
IConfigurationContext configurationContext
)
: this(collector, fileSystem, fileSystem, configurationContext, ExportOptions.Default, null, null)
Expand All @@ -82,8 +81,8 @@ IConfigurationContext configurationContext

public BuildContext(
IDiagnosticsCollector collector,
ScopedFileSystem readFileSystem,
ScopedFileSystem writeFileSystem,
IFileSystem readFileSystem,
IFileSystem writeFileSystem,
IConfigurationContext configurationContext,
IReadOnlySet<Exporter> availableExporters,
string? source = null,
Expand All @@ -108,7 +107,7 @@ public BuildContext(

(DocumentationSourceDirectory, ConfigurationPath) = Paths.FindDocsFolderFromRoot(ReadFileSystem, rootFolder);

DocumentationCheckoutDirectory = Paths.FindGitRoot(DocumentationSourceDirectory);
DocumentationCheckoutDirectory = Paths.DetermineSourceDirectoryRoot(DocumentationSourceDirectory);

OutputDirectory = !string.IsNullOrWhiteSpace(output)
? WriteFileSystem.DirectoryInfo.New(output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ public ConfigurationFileProvider(
_fileSystem = fileSystem;
_assemblyName = typeof(ConfigurationFileProvider).Assembly.GetName().Name!;
SkipPrivateRepositories = skipPrivateRepositories;
// Use a unique subdirectory per instance to avoid file-locking collisions when
// multiple processes or parallel tests share the same ApplicationData path.
var configRuntimeDir = Path.Join(Paths.ApplicationData.FullName, "config-runtime", Guid.NewGuid().ToString("N"));
TemporaryDirectory = fileSystem.DirectoryInfo.New(configRuntimeDir);
TemporaryDirectory.Create();
TemporaryDirectory = fileSystem.Directory.CreateTempSubdirectory("docs-builder-config");

// TODO: This doesn't work as expected if a github actions consumer repo has a `config` directory.
// ConfigurationSource = configurationSource ?? (
Expand Down Expand Up @@ -271,7 +267,7 @@ public static IServiceCollection AddConfigurationFileProvider(this IServiceColle
{
using var sp = services.BuildServiceProvider();
var logFactory = sp.GetRequiredService<ILoggerFactory>();
var provider = new ConfigurationFileProvider(logFactory, FileSystemFactory.RealRead, skipPrivateRepositories, configurationSource);
var provider = new ConfigurationFileProvider(logFactory, new FileSystem(), skipPrivateRepositories, configurationSource);
_ = services.AddSingleton(provider);
configure(services, provider);
return services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Elastic.Documentation\Elastic.Documentation.csproj" />
<ProjectReference Include="..\Elastic.Documentation\Elastic.Documentation.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNet.Glob" />
<PackageReference Include="NetEscapades.EnumGenerators" />
<PackageReference Include="Nullean.ScopedFileSystem" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
<PackageReference Include="Samboy063.Tomlet" />
<PackageReference Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Vecc.YamlDotNet.Analyzers.StaticGenerator"/>
<PackageReference Include="YamlDotNet"/>
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading