Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
66ace18
Remove net462 as a target framework from all projects
APErebus Nov 27, 2025
3b078e7
Tweak build process and clean up Calamari.Testing
APErebus Nov 27, 2025
cca0c16
Fix sbom
APErebus Nov 27, 2025
d99464f
Ignore win7-x86 rids
APErebus Nov 27, 2025
0f4da35
Clean up the buildable projects
APErebus Nov 27, 2025
c5fda4f
Fix compile
APErebus Nov 27, 2025
6a9ffee
Build the test project
APErebus Nov 27, 2025
f6d3bf1
Fix consolidation tests
APErebus Nov 27, 2025
2dad47c
Update LangVersion to default for all projects
APErebus Nov 27, 2025
0e17a0d
Change Calamari.Common to .NET 8.0 (from netstandard)
APErebus Nov 27, 2025
0831b61
Change remaining projects to .NET 8 from netstandard
APErebus Nov 27, 2025
242747c
Remove test attribute
APErebus Nov 27, 2025
5bf9a9c
Try and fix build issue
APErebus Nov 27, 2025
36625cc
Remove unused field
APErebus Nov 27, 2025
71908d1
Add ability to publish individual project
APErebus Nov 28, 2025
e600ddd
Merge branch 'main' into ap/remove-netfx
APErebus Dec 10, 2025
b374e98
Fix bad merge
APErebus Dec 10, 2025
b318e5d
Fix bad merge
APErebus Dec 10, 2025
aa72a73
Merge branch 'main' into ap/remove-netfx
APErebus Dec 10, 2025
0e2b947
Merge branch 'main' into ap/remove-netfx
APErebus Jan 8, 2026
e267a82
Merge branch 'main' into ap/remove-netfx
APErebus Jan 8, 2026
56c5353
Fix consolidated libraries not packing
APErebus Jan 8, 2026
629a213
Fix consolidation
APErebus Jan 8, 2026
b302c20
Execute AzureResourceGroup tests via xUnit, not Nunit
APErebus Jan 8, 2026
29d7dbc
Remove some nunit attributes
APErebus Jan 8, 2026
03fc55e
Fix default test timeout
APErebus Jan 8, 2026
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
587 changes: 160 additions & 427 deletions build/Build.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/Build.sbom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ partial class Build
.Requires(() => DependencyTrackUrl)
.Requires(() => DependencyTrackApiKey)
.Requires(() => InternalDockerRegistry)
.DependsOn(Publish)
.DependsOn(PublishCalamariProjects)
.Executes(async () =>
{
ArgumentNullException.ThrowIfNull(Solution, nameof(Solution));
Expand Down
18 changes: 4 additions & 14 deletions build/CalamariPackageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

namespace Calamari.Build;

public class CalamariPackageMetadata
public class CalamariPackageMetadata(Project project, string framework, string architecture)
{
public CalamariPackageMetadata(Project project, string framework, string? architecture, bool isCrossPlatform)
{
Project = project;
Framework = framework;
Architecture = architecture;
IsCrossPlatform = isCrossPlatform;
}

public Project Project { get; }
public string Framework { get; }
public string? Architecture { get; }
public bool IsCrossPlatform { get; }

public Project Project { get; } = project;
public string Framework { get; } = framework;
public string Architecture { get; } = architecture;
}
2 changes: 1 addition & 1 deletion build/Frameworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Calamari.Build
{
public static class Frameworks
{
public const string Net462 = "net462";
public const string Net80 = "net8.0";
public const string Net80Windows = "net8.0-windows";
}
}
4 changes: 2 additions & 2 deletions source/Calamari.Aws/Calamari.Aws.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0.0</Version>
<OutputType>Exe</OutputType>
<PlatformTarget>anycpu</PlatformTarget>
<AssemblyName>Calamari.Aws</AssemblyName>
<OutputType>Library</OutputType>
Expand All @@ -19,7 +18,8 @@
<ApplicationManifest>Calamari.Aws.exe.manifest</ApplicationManifest>
<ApplicationIcon />
<StartupObject />
<TargetFrameworks>net462;netstandard2.1</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ public class AmazonFileUploadException : Exception
public AmazonFileUploadException(){}
public AmazonFileUploadException(string message) : base(message){}
public AmazonFileUploadException(string message, Exception innerException) : base(message, innerException){}
protected AmazonFileUploadException(SerializationInfo info, StreamingContext context) : base(info, context){}
}
}
4 changes: 2 additions & 2 deletions source/Calamari.Azure/Calamari.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Authors>Octopus Deploy</Authors>
<Copyright>Octopus Deploy Pty Ltd</Copyright>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<AssemblyName>Calamari.AzureAppService.Tests</AssemblyName>
<IsPackable>false</IsPackable>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<IsPackable>true</IsPackable>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<LangVersion>8.0</LangVersion>
<LangVersion>default</LangVersion>
<NoWarn>NU5104</NoWarn>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using Xunit.v3;

namespace Calamari.AzureResourceGroup.Tests.Attributes;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class TestPlatformsAttribute(string platform) : Attribute, ITraitAttribute
{
public string Platform { get; } = platform;

public IReadOnlyCollection<KeyValuePair<string, string>> GetTraits()
=> [new("Category", Platform)];
}
Original file line number Diff line number Diff line change
@@ -1,102 +1,30 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
using Calamari.Azure;
using Calamari.CloudAccounts;
using Calamari.AzureResourceGroup.Tests.Attributes;
using Calamari.AzureResourceGroup.Tests.Support;
using Calamari.Common.Features.Deployment;
using Calamari.Common.Features.Scripts;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing.Variables;
using Calamari.Testing;
using Calamari.Testing.Azure;
using Calamari.Testing.Helpers;
using Calamari.Testing.Requirements;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Xunit.Sdk;

// ReSharper disable MethodHasAsyncOverload - File.ReadAllTextAsync does not exist for .net framework targets

namespace Calamari.AzureResourceGroup.Tests
{
[TestFixture]
class AzureResourceGroupActionHandlerFixture
[Collection(nameof(AzureResourceGroupFixture))]
public class AzureResourceGroupActionHandlerTests(AzureResourceGroupFixture resourceGroupFixture): CalamariTest
{
string clientId;
string clientSecret;
string tenantId;
string subscriptionId;
static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
readonly CancellationToken cancellationToken = CancellationTokenSource.Token;
readonly AzureResourceGroupFixture resourceGroupFixture = resourceGroupFixture;

ArmClient armClient;
SubscriptionResource subscriptionResource;
ResourceGroupResource resourceGroupResource;
string resourceGroupName;

[OneTimeSetUp]
public async Task Setup()
{
var resourceManagementEndpointBaseUri =
Environment.GetEnvironmentVariable(AccountVariables.ResourceManagementEndPoint) ?? DefaultVariables.ResourceManagementEndpoint;
var activeDirectoryEndpointBaseUri =
Environment.GetEnvironmentVariable(AccountVariables.ActiveDirectoryEndPoint) ?? DefaultVariables.ActiveDirectoryEndpoint;

clientId = await ExternalVariables.Get(ExternalVariable.AzureSubscriptionClientId, cancellationToken);
clientSecret = await ExternalVariables.Get(ExternalVariable.AzureSubscriptionPassword, cancellationToken);
tenantId = await ExternalVariables.Get(ExternalVariable.AzureSubscriptionTenantId, cancellationToken);
subscriptionId = await ExternalVariables.Get(ExternalVariable.AzureSubscriptionId, cancellationToken);

var resourceGroupLocation = Environment.GetEnvironmentVariable("AZURE_NEW_RESOURCE_REGION") ?? RandomAzureRegion.GetRandomRegionWithExclusions();

resourceGroupName = AzureTestResourceHelpers.GetResourceGroupName();

var servicePrincipalAccount = new AzureServicePrincipalAccount(subscriptionId,
clientId,
tenantId,
clientSecret,
"AzureGlobalCloud",
resourceManagementEndpointBaseUri,
activeDirectoryEndpointBaseUri);

armClient = servicePrincipalAccount.CreateArmClient(retryOptions =>
{
retryOptions.MaxRetries = 5;
retryOptions.Mode = RetryMode.Exponential;
retryOptions.Delay = TimeSpan.FromSeconds(2);
retryOptions.NetworkTimeout = TimeSpan.FromSeconds(200);
});

//create the resource group
subscriptionResource = armClient.GetSubscriptionResource(SubscriptionResource.CreateResourceIdentifier(subscriptionId));

var response = await subscriptionResource
.GetResourceGroups()
.CreateOrUpdateAsync(WaitUntil.Completed,
resourceGroupName,
new ResourceGroupData(new AzureLocation(resourceGroupLocation))
{
Tags =
{
[AzureTestResourceHelpers.ResourceGroupTags.LifetimeInDaysKey] = AzureTestResourceHelpers.ResourceGroupTags.LifetimeInDaysValue,
[AzureTestResourceHelpers.ResourceGroupTags.SourceKey] = AzureTestResourceHelpers.ResourceGroupTags.SourceValue
}
});

resourceGroupResource = response.Value;
}

[OneTimeTearDown]
public async Task Cleanup()
{
await armClient.GetResourceGroupResource(ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName))
.DeleteAsync(WaitUntil.Started);
}

[Test]
[Fact]
public async Task Deploy_with_template_in_package()
{
var packagePath = TestEnvironment.GetTestPath("Packages", "AzureResourceGroup");
Expand All @@ -113,7 +41,7 @@ await CommandTestBuilder.CreateAsync<DeployAzureResourceGroupCommand, Program>()
.Execute();
}

[Test]
[Fact]
public async Task Deploy_with_template_in_git_repository()
{
// For the purposes of ARM templates in Calamari, a template in a Git Repository
Expand All @@ -134,7 +62,7 @@ await CommandTestBuilder.CreateAsync<DeployAzureResourceGroupCommand, Program>()
.Execute();
}

[Test]
[Fact]
public async Task Deploy_with_template_inline()
{
var packagePath = TestEnvironment.GetTestPath("Packages", "AzureResourceGroup");
Expand All @@ -158,11 +86,15 @@ await CommandTestBuilder.CreateAsync<DeployAzureResourceGroupCommand, Program>()
.Execute();
}

[Test]
[WindowsTest]
[RequiresPowerShell5OrAbove]
[Fact]
[TestPlatforms(TestCategory.CompatibleOS.OnlyWindows)]
public async Task Deploy_Ensure_Tools_Are_Configured()
{
if (ScriptingEnvironment.SafelyGetPowerShellVersion().Major < 5)
{
throw SkipException.ForSkip("This test requires PowerShell 5 or above.");
}

var packagePath = TestEnvironment.GetTestPath("Packages", "AzureResourceGroup");
var templateFileContent = File.ReadAllText(Path.Combine(packagePath, "azure_website_template.json"));
var paramsFileContent = File.ReadAllText(Path.Combine(packagePath, "azure_website_params.json"));
Expand Down Expand Up @@ -192,19 +124,19 @@ await CommandTestBuilder.CreateAsync<DeployAzureResourceGroupCommand, Program>()
.Execute();
}

private void AddDefaults(CommandTestBuilderContext context)
void AddDefaults(CommandTestBuilderContext context)
{
context.Variables.Add("Octopus.Account.AccountType", "AzureServicePrincipal");
context.Variables.Add(AzureAccountVariables.SubscriptionId, subscriptionId);
context.Variables.Add(AzureAccountVariables.TenantId, tenantId);
context.Variables.Add(AzureAccountVariables.ClientId, clientId);
context.Variables.Add(AzureAccountVariables.Password, clientSecret);
context.Variables.Add(SpecialVariables.Action.Azure.ResourceGroupName, resourceGroupName);
context.Variables.Add("ResourceGroup", resourceGroupName);
context.Variables.Add(AzureAccountVariables.SubscriptionId, resourceGroupFixture.SubscriptionId);
context.Variables.Add(AzureAccountVariables.TenantId, resourceGroupFixture.TenantId);
context.Variables.Add(AzureAccountVariables.ClientId, resourceGroupFixture.ClientId);
context.Variables.Add(AzureAccountVariables.Password, resourceGroupFixture.ClientSecret);
context.Variables.Add(SpecialVariables.Action.Azure.ResourceGroupName, resourceGroupFixture.ResourceGroupName);
context.Variables.Add("ResourceGroup", resourceGroupFixture.ResourceGroupName);
context.Variables.Add("SKU", "Shared");
//as we have a single resource group, we need to have unique web app name per test
context.Variables.Add("WebSite", $"Calamari-{Guid.NewGuid():N}");
context.Variables.Add("Location", resourceGroupResource.Data.Location);
context.Variables.Add("Location", resourceGroupFixture.ResourceGroupResource.Data.Location);
//this is a storage account prefix, so just make it as random as possible
//The names of the storage accounts are a max of 7 chars, so we generate a prefix of 17 chars (storage accounts have a max of 24)
context.Variables.Add("AccountPrefix", AzureTestResourceHelpers.RandomName(length: 17));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<AssemblyName>Calamari.AzureResourceGroup.Tests</AssemblyName>
<IsPackable>false</IsPackable>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Octopus.Dependencies.AzureCLI" Version="2.41.0" GeneratePathProperty="true" />
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.41" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" Condition="'$(TargetFramework)' == 'net462'" />
<PackageReference Include="xunit.v3" Version="3.2.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<Target Name="GetPackageFiles" AfterTargets="ResolveReferences" DependsOnTargets="RunResolvePackageDependencies">
<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions source/Calamari.AzureResourceGroup.Tests/CalamariTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Threading;

namespace Calamari.AzureResourceGroup.Tests;

public abstract class CalamariTest
{
readonly CancellationTokenSource cancellationTokenSource;
protected CancellationToken CancellationToken => cancellationTokenSource.Token;

protected virtual TimeSpan TestTimeout => TimeSpan.FromMilliseconds(int.MaxValue);

protected CalamariTest()
{
var ctsTimeout = new CancellationTokenSource(TestTimeout);
cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(ctsTimeout.Token, TestContext.Current.CancellationToken);
}
}
Loading