feat(release): add reproducible signed artifacts (#19)
This commit is contained in:
@@ -1,30 +1,69 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FinalFactory.Rendezvous.Tests.Contracts;
|
||||
|
||||
internal static class ContractTestFiles
|
||||
{
|
||||
public static string Read(string fileName) => File
|
||||
.ReadAllText(Path.Combine(Directory, fileName))
|
||||
.ReadAllText(Path.Combine(DirectoryFor(fileName), fileName))
|
||||
.TrimEnd('\r', '\n');
|
||||
|
||||
public static string Directory
|
||||
{
|
||||
get
|
||||
{
|
||||
return VersionedDirectory(Property("RendezvousMajorVersion"));
|
||||
}
|
||||
}
|
||||
|
||||
public static string OpenApiDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
string httpVersion = Property("HttpContractVersion");
|
||||
return Path.Combine(RepositoryRoot, $"docs/api/rendezvous-v{httpVersion}.json");
|
||||
}
|
||||
}
|
||||
|
||||
private static string DirectoryFor(string fileName)
|
||||
{
|
||||
string property = fileName switch
|
||||
{
|
||||
"client-public-api.txt" or "contracts-public-api.txt" => "RendezvousMajorVersion",
|
||||
"connection-ticket.json" => "ConnectionTicketFormatVersion",
|
||||
_ when fileName.EndsWith(".hex", StringComparison.Ordinal) => "UdpContractVersion",
|
||||
_ when fileName.EndsWith(".json", StringComparison.Ordinal) => "HttpContractVersion",
|
||||
_ => throw new InvalidOperationException($"No contract version dimension maps {fileName}."),
|
||||
};
|
||||
return VersionedDirectory(Property(property));
|
||||
}
|
||||
|
||||
private static string VersionedDirectory(string version) => Path.Combine(
|
||||
RepositoryRoot,
|
||||
$"tests/FinalFactory.Rendezvous.Tests/TestData/Contracts/v{version}");
|
||||
|
||||
private static string Property(string name)
|
||||
{
|
||||
XDocument versions = XDocument.Load(Path.Combine(RepositoryRoot, "eng/Versions.props"));
|
||||
return versions.Descendants(name).Single().Value;
|
||||
}
|
||||
|
||||
private static string RepositoryRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
DirectoryInfo? directory = new(AppContext.BaseDirectory);
|
||||
while (directory is not null)
|
||||
{
|
||||
string solution = Path.Combine(directory.FullName, "Rendezvous.slnx");
|
||||
if (File.Exists(solution))
|
||||
if (File.Exists(Path.Combine(directory.FullName, "Rendezvous.slnx")))
|
||||
{
|
||||
return Path.Combine(
|
||||
directory.FullName,
|
||||
"tests/FinalFactory.Rendezvous.Tests/TestData/Contracts/v1");
|
||||
return directory.FullName;
|
||||
}
|
||||
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Could not locate contract test data.");
|
||||
throw new DirectoryNotFoundException("Could not locate repository root.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user