mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds per-platform release artifacts and release image validation
This commit is contained in:
1 parent
92ab62011e
commit
68143dff25
19 files changed
+603
-115
No files matched your search
+22
-35
@@ -7,8 +7,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Xml.Linq;
|
||||
#endregion
|
||||
|
||||
@@ -217,41 +215,30 @@ public class BundledPluginManifestReaderTests
|
||||
?? throw new InvalidOperationException($"The environment variable '{PUBLISH_DIRECTORY_ENVIRONMENT_VARIABLE}' is not set.");
|
||||
string publishedApiAssemblyPath = BundledPluginManifestTestPaths.GetPublishedApiAssemblyPath(publishDirectory);
|
||||
string publishedPluginsDirectory = BundledPluginManifestTestPaths.GetPublishedPluginsDirectory(publishDirectory);
|
||||
// Load the published API assembly in its own context, so the test reads the exact shipped binary without loading it into the test process.
|
||||
AssemblyLoadContext loadContext = new("PublishedBundledPluginManifestVerification", isCollectible: true);
|
||||
try
|
||||
// Read the resource directly from the file. Loading the assembly would fail for a runtime whose architecture differs from the test process.
|
||||
byte[] publishedManifestBytes = PublishedAssemblyResourceReader.ReadEmbeddedResource(publishedApiAssemblyPath, CURRENT_MANIFEST_RESOURCE_NAME);
|
||||
using (MemoryStream manifestStream = new(publishedManifestBytes))
|
||||
{
|
||||
Assembly publishedApiAssembly = loadContext.LoadFromAssemblyPath(publishedApiAssemblyPath);
|
||||
// The published assembly must embed the current manifest. A missing resource means the official publish step did not run.
|
||||
using (Stream manifestStream = publishedApiAssembly.GetManifestResourceStream(CURRENT_MANIFEST_RESOURCE_NAME)
|
||||
?? throw new InvalidOperationException("The published API assembly does not embed the current bundled plugin manifest."))
|
||||
{
|
||||
// Act
|
||||
IReadOnlyDictionary<string, IReadOnlySet<string>> publishedManifestEntries = BundledPluginManifestReader.ReadExpectedChecksums(manifestStream);
|
||||
// Act
|
||||
IReadOnlyDictionary<string, IReadOnlySet<string>> publishedManifestEntries = BundledPluginManifestReader.ReadExpectedChecksums(manifestStream);
|
||||
|
||||
// Assert
|
||||
Assert.NotEmpty(publishedManifestEntries);
|
||||
// The manifest and the published plugin folder must agree exactly: every entry has a file, and the counts match.
|
||||
string[] publishedPluginAssemblyFileNames = [.. Directory.EnumerateFiles(publishedPluginsDirectory, BundledPluginManifestTestPaths.PLUGIN_ASSEMBLY_SEARCH_PATTERN)
|
||||
.Select(Path.GetFileName)
|
||||
.OfType<string>()];
|
||||
Assert.Equal(publishedManifestEntries.Count, publishedPluginAssemblyFileNames.Length);
|
||||
foreach (KeyValuePair<string, IReadOnlySet<string>> entry in publishedManifestEntries)
|
||||
{
|
||||
Assert.Contains(entry.Key, publishedPluginAssemblyFileNames, StringComparer.OrdinalIgnoreCase);
|
||||
string publishedAssemblyPath = Path.Combine(publishedPluginsDirectory, entry.Key);
|
||||
Assert.True(File.Exists(publishedAssemblyPath), $"The published plugin assembly '{entry.Key}' is missing from '{publishedPluginsDirectory}'.");
|
||||
string actualSha256 = _bundledPluginFileHashFixture.Create(publishedAssemblyPath);
|
||||
string expectedSha256 = Assert.Single(entry.Value);
|
||||
Assert.Equal(expectedSha256, actualSha256, ignoreCase: true);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotEmpty(publishedManifestEntries);
|
||||
// The manifest and the published plugin folder must agree exactly: every entry has a file, and the counts match.
|
||||
string[] publishedPluginAssemblyFileNames = [.. Directory.EnumerateFiles(publishedPluginsDirectory, BundledPluginManifestTestPaths.PLUGIN_ASSEMBLY_SEARCH_PATTERN)
|
||||
.Select(Path.GetFileName)
|
||||
.OfType<string>()];
|
||||
Assert.Equal(publishedManifestEntries.Count, publishedPluginAssemblyFileNames.Length);
|
||||
foreach (KeyValuePair<string, IReadOnlySet<string>> entry in publishedManifestEntries)
|
||||
{
|
||||
Assert.Contains(entry.Key, publishedPluginAssemblyFileNames, StringComparer.OrdinalIgnoreCase);
|
||||
string publishedAssemblyPath = Path.Combine(publishedPluginsDirectory, entry.Key);
|
||||
Assert.True(File.Exists(publishedAssemblyPath), $"The published plugin assembly '{entry.Key}' is missing from '{publishedPluginsDirectory}'.");
|
||||
string actualSha256 = _bundledPluginFileHashFixture.Create(publishedAssemblyPath);
|
||||
string expectedSha256 = Assert.Single(entry.Value);
|
||||
Assert.Equal(expectedSha256, actualSha256, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Unload the collectible context so the published assembly does not stay locked for later test runs.
|
||||
loadContext.Unload();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -285,8 +272,8 @@ public class BundledPluginManifestReaderTests
|
||||
{
|
||||
using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream(resourceName)
|
||||
?? throw new InvalidOperationException($"The embedded manifest resource '{resourceName}' is missing."))
|
||||
using (StreamReader reader = new(stream))
|
||||
return reader.ReadToEnd();
|
||||
using (StreamReader reader = new(stream))
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user