mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 15:11:10 +00:00
- embeds the append-only historical and deny trust lists in the API and marks matching bundled plugins as Official without blocking loading - builds and records the current plugin manifest only for official release builds - deploys the PDF native libraries for the supported Linux, macOS and Windows runtimes from the plugin dependency manifest - records release hashes by appending only missing entries to master's manifest and rejects any diff that removes a line - documents the release flow, the supported runtimes and the plugin installer limits
191 lines
8.0 KiB
C#
191 lines
8.0 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.IO;
|
|
#endregion
|
|
|
|
namespace Nemera.Presentation.Api.IntegrationTests.Common.Setup;
|
|
|
|
/// <summary>
|
|
/// Locates the files and directories used by the bundled plugin manifest tests.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The tests run from a configuration and target framework folder under bin/tests, so the repository root is found by walking up to the solution instead of hardcoding a machine-specific path.
|
|
/// </remarks>
|
|
[ExcludeFromCodeCoverage]
|
|
public static class BundledPluginManifestTestPaths
|
|
{
|
|
/// <summary>
|
|
/// The name of the directory that holds the build scripts.
|
|
/// </summary>
|
|
public const string BUILD_DIRECTORY_NAME = "build";
|
|
|
|
/// <summary>
|
|
/// The name of the directory that holds the build outputs.
|
|
/// </summary>
|
|
public const string BIN_DIRECTORY_NAME = "bin";
|
|
|
|
/// <summary>
|
|
/// The name of the directory that holds the solution.
|
|
/// </summary>
|
|
public const string SOLUTION_DIRECTORY_NAME = "src";
|
|
|
|
/// <summary>
|
|
/// The file name of the solution.
|
|
/// </summary>
|
|
public const string SOLUTION_FILE_NAME = "Nemera.slnx";
|
|
|
|
/// <summary>
|
|
/// The name of the append-only bundled plugin trust manifest.
|
|
/// </summary>
|
|
public const string BUNDLED_PLUGINS_MANIFEST_FILE_NAME = "BundledPlugins.manifest";
|
|
|
|
/// <summary>
|
|
/// The name of the bundled plugin revocation manifest.
|
|
/// </summary>
|
|
public const string BUNDLED_PLUGINS_DENY_MANIFEST_FILE_NAME = "BundledPlugins.deny.manifest";
|
|
|
|
/// <summary>
|
|
/// The name of the bundled plugin release catalog.
|
|
/// </summary>
|
|
public const string BUNDLED_PLUGINS_PROPS_FILE_NAME = "BundledPlugins.props";
|
|
|
|
/// <summary>
|
|
/// The name of the directory that holds the plugin projects.
|
|
/// </summary>
|
|
public const string PLUGINS_PROJECT_DIRECTORY_NAME = "plugins";
|
|
|
|
/// <summary>
|
|
/// The name of the API output directory under the repository bin directory.
|
|
/// </summary>
|
|
public const string API_OUTPUT_DIRECTORY_NAME = "api";
|
|
|
|
/// <summary>
|
|
/// The name of the directory that holds the deployed plugin assemblies.
|
|
/// </summary>
|
|
public const string PLUGINS_DIRECTORY_NAME = "plugins";
|
|
|
|
/// <summary>
|
|
/// The file name of the published API assembly.
|
|
/// </summary>
|
|
public const string PUBLISHED_API_ASSEMBLY_FILE_NAME = "Nemera.Presentation.Api.dll";
|
|
|
|
/// <summary>
|
|
/// The search pattern of the bundled plugin assemblies.
|
|
/// </summary>
|
|
public const string PLUGIN_ASSEMBLY_SEARCH_PATTERN = "Nemera.Plugins.*.dll";
|
|
|
|
/// <summary>
|
|
/// The search pattern of the plugin project files.
|
|
/// </summary>
|
|
public const string PLUGIN_PROJECT_SEARCH_PATTERN = "*.csproj";
|
|
|
|
/// <summary>
|
|
/// The extension of the bundled plugin assemblies.
|
|
/// </summary>
|
|
public const string PLUGIN_ASSEMBLY_EXTENSION = ".dll";
|
|
|
|
/// <summary>
|
|
/// Locates the repository root from the test output directory.
|
|
/// </summary>
|
|
/// <returns>The absolute path of the repository root.</returns>
|
|
public static string GetRepositoryRoot()
|
|
{
|
|
// Walk up from the test output directory until the solution file is found. This works regardless of how many folders the output is nested under bin.
|
|
DirectoryInfo? directory = new(AppContext.BaseDirectory);
|
|
while (directory is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(directory.FullName, SOLUTION_DIRECTORY_NAME, SOLUTION_FILE_NAME)))
|
|
return directory.FullName;
|
|
directory = directory.Parent;
|
|
}
|
|
throw new InvalidOperationException("The repository root could not be located from the test output directory.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the append-only bundled plugin trust manifest.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the trust manifest.</returns>
|
|
public static string GetBundledPluginsManifestPath(string repositoryRoot)
|
|
{
|
|
return Path.Combine(repositoryRoot, BUILD_DIRECTORY_NAME, BUNDLED_PLUGINS_MANIFEST_FILE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the bundled plugin revocation manifest.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the revocation manifest.</returns>
|
|
public static string GetBundledPluginsDenyManifestPath(string repositoryRoot)
|
|
{
|
|
return Path.Combine(repositoryRoot, BUILD_DIRECTORY_NAME, BUNDLED_PLUGINS_DENY_MANIFEST_FILE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the bundled plugin release catalog.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the release catalog.</returns>
|
|
public static string GetBundledPluginsPropsPath(string repositoryRoot)
|
|
{
|
|
return Path.Combine(repositoryRoot, BUILD_DIRECTORY_NAME, BUNDLED_PLUGINS_PROPS_FILE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the solution file.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the solution file.</returns>
|
|
public static string GetSolutionPath(string repositoryRoot)
|
|
{
|
|
return Path.Combine(repositoryRoot, SOLUTION_DIRECTORY_NAME, SOLUTION_FILE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the directory that holds the plugin projects.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the plugin project directory.</returns>
|
|
public static string GetPluginsProjectDirectory(string repositoryRoot)
|
|
{
|
|
return Path.Combine(repositoryRoot, PLUGINS_PROJECT_DIRECTORY_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the plugins directory of the API build output for the current test configuration.
|
|
/// </summary>
|
|
/// <param name="repositoryRoot">The absolute path of the repository root.</param>
|
|
/// <returns>The absolute path of the deployed plugins directory, whether or not it exists.</returns>
|
|
public static string GetDeployedPluginsDirectory(string repositoryRoot)
|
|
{
|
|
// The test output folder is bin/tests/<project>/<configuration>/<target-framework>, so its parent names the configuration
|
|
// and its own name is the target framework. The API output mirrors that layout under bin/api.
|
|
DirectoryInfo testOutputDirectory = new(AppContext.BaseDirectory);
|
|
string configuration = testOutputDirectory.Parent?.Name
|
|
?? throw new InvalidOperationException("The test configuration could not be determined from the test output directory.");
|
|
string targetFramework = testOutputDirectory.Name;
|
|
return Path.Combine(repositoryRoot, BIN_DIRECTORY_NAME, API_OUTPUT_DIRECTORY_NAME, configuration, targetFramework, PLUGINS_DIRECTORY_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the published API assembly in the publish output directory.
|
|
/// </summary>
|
|
/// <param name="publishDirectory">The absolute path of the publish output directory.</param>
|
|
/// <returns>The absolute path of the published API assembly.</returns>
|
|
public static string GetPublishedApiAssemblyPath(string publishDirectory)
|
|
{
|
|
return Path.Combine(publishDirectory, PUBLISHED_API_ASSEMBLY_FILE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locates the published plugins directory in the publish output directory.
|
|
/// </summary>
|
|
/// <param name="publishDirectory">The absolute path of the publish output directory.</param>
|
|
/// <returns>The absolute path of the published plugins directory.</returns>
|
|
public static string GetPublishedPluginsDirectory(string publishDirectory)
|
|
{
|
|
return Path.Combine(publishDirectory, PLUGINS_DIRECTORY_NAME);
|
|
}
|
|
}
|