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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<Authors>finos</Authors>
<Authors>FINOS</Authors>
<RepositoryUrl>https://github.com/finos/morphir-dotnet</RepositoryUrl>
<!-- owners is not supported in MSBuild -->

Expand Down
4 changes: 3 additions & 1 deletion build/Build.Packaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ partial class Build
.SetProperty("PackAsTool", "true")
.SetProperty("ToolCommandName", "dotnet-morphir")
.SetProperty("IsPackable", "true")
.SetProperty("Version", versionString));
.SetProperty("Version", versionString)
.SetProperty("DebugType", "none") // Don't include PDB files in tool package
.SetProperty("IncludeSymbols", "false"));
});

/// <summary>
Expand Down
30 changes: 19 additions & 11 deletions tests/Morphir.Build.Tests/LocalInstallationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Morphir.Build.Tests;
public class LocalInstallationTests
{
[Test]
[Skip("Requires packages to be built first and is a potentially destructive test")]
public async Task ToolPackage_InstallsFromLocalFolder()
{
// Arrange
Expand All @@ -29,15 +28,18 @@ public async Task ToolPackage_InstallsFromLocalFolder()
var packageName = Path.GetFileName(toolPackage!);
File.Copy(toolPackage, Path.Combine(localSource, packageName));

// Act - Install tool from local source
// Extract version from package filename
var version = TestFixture.GetPackageVersion(toolPackage);

// Act - Install tool from local source (version is required for local feeds)
var installResult = await RunDotnetCommand(
$"tool install Morphir.Tool --tool-path {tempDir} --add-source {localSource}");
$"tool install Morphir.Tool --version {version} --tool-path {tempDir} --add-source {localSource}");

// Assert
installResult.ExitCode.Should().Be(0,
$"Tool installation should succeed. Output: {installResult.Output}");

var toolPath = Path.Combine(tempDir, "morphir");
var toolPath = Path.Combine(tempDir, "dotnet-morphir");
if (OperatingSystem.IsWindows())
{
toolPath += ".exe";
Expand All @@ -56,7 +58,6 @@ public async Task ToolPackage_InstallsFromLocalFolder()
}

[Test]
[Skip("Requires packages to be built first and is a potentially destructive test")]
public async Task ToolCommand_AvailableAfterInstall()
{
// Arrange
Expand All @@ -75,12 +76,15 @@ public async Task ToolCommand_AvailableAfterInstall()
var packageName = Path.GetFileName(toolPackage!);
File.Copy(toolPackage, Path.Combine(localSource, packageName));

// Install tool
// Extract version from package filename
var version = TestFixture.GetPackageVersion(toolPackage);

// Install tool (version is required for local feeds)
await RunDotnetCommand(
$"tool install Morphir.Tool --tool-path {tempDir} --add-source {localSource}");
$"tool install Morphir.Tool --version {version} --tool-path {tempDir} --add-source {localSource}");

// Act - Run the tool command
var toolPath = Path.Combine(tempDir, "morphir");
var toolPath = Path.Combine(tempDir, "dotnet-morphir");
if (OperatingSystem.IsWindows())
{
toolPath += ".exe";
Expand All @@ -105,7 +109,6 @@ await RunDotnetCommand(
}

[Test]
[Skip("Requires packages to be built first and is a potentially destructive test")]
public async Task ToolPackage_UninstallsSuccessfully()
{
// Arrange
Expand All @@ -123,8 +126,13 @@ public async Task ToolPackage_UninstallsSuccessfully()
// Copy package and install
var packageName = Path.GetFileName(toolPackage!);
File.Copy(toolPackage, Path.Combine(localSource, packageName));

// Extract version from package filename
var version = TestFixture.GetPackageVersion(toolPackage);

// Install tool (version is required for local feeds)
await RunDotnetCommand(
$"tool install Morphir.Tool --tool-path {tempDir} --add-source {localSource}");
$"tool install Morphir.Tool --version {version} --tool-path {tempDir} --add-source {localSource}");

// Act - Uninstall tool
var uninstallResult = await RunDotnetCommand(
Expand All @@ -134,7 +142,7 @@ await RunDotnetCommand(
uninstallResult.ExitCode.Should().Be(0,
$"Tool uninstallation should succeed. Output: {uninstallResult.Output}");

var toolPath = Path.Combine(tempDir, "morphir");
var toolPath = Path.Combine(tempDir, "dotnet-morphir");
if (OperatingSystem.IsWindows())
{
toolPath += ".exe";
Expand Down
4 changes: 0 additions & 4 deletions tests/Morphir.Build.Tests/PackageMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Morphir.Build.Tests;
public class PackageMetadataTests
{
[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task AllPackages_HaveSameVersion()
{
// Arrange
Expand All @@ -37,7 +36,6 @@ public async Task AllPackages_HaveSameVersion()
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task PackageVersions_MatchChangelogVersion()
{
// Arrange
Expand All @@ -56,7 +54,6 @@ public async Task PackageVersions_MatchChangelogVersion()
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task ToolPackage_HasCorrectMetadata()
{
// Arrange
Expand All @@ -75,7 +72,6 @@ public async Task ToolPackage_HasCorrectMetadata()
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task AllPackages_HaveReleaseNotes()
{
// Arrange
Expand Down
16 changes: 6 additions & 10 deletions tests/Morphir.Build.Tests/PackageStructureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Morphir.Build.Tests;
public class PackageStructureTests
{
[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task ToolPackage_HasCorrectStructure()
{
// Arrange
Expand All @@ -24,8 +23,8 @@ public async Task ToolPackage_HasCorrectStructure()
"Tool package must have tools/net10.0/any/ directory");

// Check for required tool files
entries.Should().Contain("tools/net10.0/any/morphir.dll",
"Tool package must contain morphir.dll in tools directory");
entries.Should().Contain("tools/net10.0/any/dotnet-morphir.dll",
"Tool package must contain dotnet-morphir.dll in tools directory");
entries.Should().Contain("tools/net10.0/any/DotnetToolSettings.xml",
"Tool package must contain DotnetToolSettings.xml");

Expand All @@ -39,7 +38,6 @@ public async Task ToolPackage_HasCorrectStructure()
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task ToolPackage_HasCorrectToolSettings()
{
// Arrange
Expand All @@ -50,14 +48,13 @@ public async Task ToolPackage_HasCorrectToolSettings()
var toolSettings = await TestFixture.ReadPackageEntry(package!, "tools/net10.0/any/DotnetToolSettings.xml");

// Assert
toolSettings.Should().Contain("<Command Name=\"morphir\"",
"Tool command should be named 'morphir'");
toolSettings.Should().Contain("EntryPoint=\"morphir.dll\"",
"Tool entry point should be morphir.dll");
toolSettings.Should().Contain("<Command Name=\"dotnet-morphir\"",
"Tool command should be named 'dotnet-morphir'");
toolSettings.Should().Contain("EntryPoint=\"dotnet-morphir.dll\"",
"Tool entry point should be dotnet-morphir.dll");
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task LibraryPackages_HaveCorrectStructure()
{
// Arrange - Check Morphir.Core package
Expand All @@ -81,7 +78,6 @@ public async Task LibraryPackages_HaveCorrectStructure()
}

[Test]
[Skip("Requires packages to be built first - run after PackAll target")]
public async Task Packages_DoNotContainUnnecessaryFiles()
{
// Arrange - Find specific packages to avoid ambiguity
Expand Down
24 changes: 24 additions & 0 deletions tests/Morphir.Build.Tests/TestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,28 @@ public static bool HasPackages()
return Directory.Exists(packagesDir) &&
Directory.GetFiles(packagesDir, "*.nupkg").Any();
}

/// <summary>
/// Extract version from package filename
/// </summary>
/// <param name="packagePath">Full path to .nupkg file like "/path/Morphir.Tool.0.3.0-rc.2.nupkg"</param>
/// <returns>Version string like "0.3.0-rc.2"</returns>
public static string GetPackageVersion(string packagePath)
{
var filename = Path.GetFileNameWithoutExtension(packagePath);
// Format: PackageName.Version.nupkg
// Example: Morphir.Tool.0.3.0-rc.2.nupkg -> extract "0.3.0-rc.2"

// Use regex to match semantic version pattern: starts with digit.digit.digit
// This handles: major.minor.patch[-prerelease][+build]
var versionPattern = @"\.(\d+\.\d+\.\d+(?:-[\w\d\.-]+)?(?:\+[\w\d\.-]+)?)$";
var match = System.Text.RegularExpressions.Regex.Match(filename, versionPattern);

if (match.Success)
{
return match.Groups[1].Value;
}

throw new ArgumentException($"Could not extract semantic version from package filename: {filename}");
}
}
Loading