diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64e4acf638..45884b6157 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Run Nuke Build 🏗 id: nuke-build env: diff --git a/build/Build.cs b/build/Build.cs index 58fcdbfb15..eff73d817b 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -45,7 +45,7 @@ class Build : NukeBuild [PackageExecutable( packageId: "OctoVersion.Tool", packageExecutable: "OctoVersion.Tool.dll", - Framework = "net6.0")] + Framework = "net8.0")] readonly Tool OctoVersion; [PackageExecutable( @@ -167,7 +167,7 @@ class Build : NukeBuild var portablePublishDir = OctoPublishDirectory / "portable"; DotNetPublish(_ => _ .SetProject(Solution.Octo) - .SetFramework("netcoreapp3.1") + .SetFramework("net8.0") .SetConfiguration(Configuration) .SetOutput(portablePublishDir) .SetVersion(fullSemVer)); @@ -188,7 +188,7 @@ class Build : NukeBuild DotNetPublish(_ => _ .SetProject(Solution.Octo) .SetConfiguration(Configuration) - .SetFramework("net6.0") + .SetFramework("net8.0") .SetRuntime(rid) .EnableSelfContained() .EnablePublishSingleFile() diff --git a/build/_build.csproj b/build/_build.csproj index 4d3d99bcfe..64cd0a6dfa 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -12,7 +12,7 @@ - + diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index 7bc28484c4..0306022356 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -16,6 +16,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -24,4 +26,5 @@ True True True - True + True + True diff --git a/global.json b/global.json index c077e9fc34..027e02265d 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.101", + "version": "8.0.407", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/source/Octo.Tests/Commands/AllowReleaseProgressionCommandFixture.cs b/source/Octo.Tests/Commands/AllowReleaseProgressionCommandFixture.cs index 17455caa28..fc3e9ad87b 100644 --- a/source/Octo.Tests/Commands/AllowReleaseProgressionCommandFixture.cs +++ b/source/Octo.Tests/Commands/AllowReleaseProgressionCommandFixture.cs @@ -74,38 +74,38 @@ public void ShouldBeAttachedWithCorrectAttribute() [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void ShouldValidateProjectIdOrNameParameterForMissing(string projectIdOrName) + public async Task ShouldValidateProjectIdOrNameParameterForMissing(string projectIdOrName) { CommandLineArgs.Add($"--project={projectIdOrName}"); CommandLineArgs.Add($"--version={releaseResource.Version}"); Func exec = () => allowReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a project name or ID using the parameter: --project=XYZ"); } [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void ShouldValidateReleaseVersionNumberParameterForMissing(string releaseVersionNumber) + public async Task ShouldValidateReleaseVersionNumberParameterForMissing(string releaseVersionNumber) { CommandLineArgs.Add($"--project={projectResource.Name}"); CommandLineArgs.Add($"--version={releaseVersionNumber}"); Func exec = () => allowReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a release version number using the version parameter: --version=1.0.5"); } [TestCase("9999999999999999999999999999999999999")] [Description("Version number larger than an int")] - public void ShouldValidateReleaseVersionNumberParameterForFormat(string releaseVersionNumber) + public async Task ShouldValidateReleaseVersionNumberParameterForFormat(string releaseVersionNumber) { CommandLineArgs.Add($"--project={projectResource.Name}"); CommandLineArgs.Add($"--version={releaseVersionNumber}"); Func exec = () => allowReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please provide a valid release version format: --version=1.0.5"); } @@ -123,7 +123,7 @@ public async Task ShouldSupportBothReleaseNumberAndVersionArgForReleaseVersionNu } [Test] - public void ShouldThrowCorrectException_WhenReleaseNotFound() + public async Task ShouldThrowCorrectException_WhenReleaseNotFound() { Repository.Projects.GetReleaseByVersion(projectResource, releaseResource.Version).Returns((ReleaseResource)null); @@ -132,7 +132,7 @@ public void ShouldThrowCorrectException_WhenReleaseNotFound() Func exec = () => allowReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] diff --git a/source/Octo.Tests/Commands/ApiCommandFixture.cs b/source/Octo.Tests/Commands/ApiCommandFixture.cs index a777c49b38..cf8d091ea8 100644 --- a/source/Octo.Tests/Commands/ApiCommandFixture.cs +++ b/source/Octo.Tests/Commands/ApiCommandFixture.cs @@ -52,11 +52,11 @@ public void ShouldNotThrowIfServerSetInEnvVar() } [Test] - public void ShouldThrowIfInvalidCommandLineParametersArePassed() + public async Task ShouldThrowIfInvalidCommandLineParametersArePassed() { CommandLineArgs.Add("--fail=epic"); Func exec = () => apiCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] @@ -134,11 +134,11 @@ public async Task ShouldRunWithinASpaceWhenSpaceNameSpecified() })); await apiCommand.Execute(argsWithSpaceName.ToArray()).ConfigureAwait(false); - Assert.IsTrue(isInRightSpaceContext); + Assert.That(isInRightSpaceContext, Is.True); } [Test] - public void ShouldThrowWhenThereIsNoSpaceMatchTheProvidedName() + public async Task ShouldThrowWhenThereIsNoSpaceMatchTheProvidedName() { var client = Substitute.For(); ClientFactory.CreateAsyncClient(null).ReturnsForAnyArgs(client); @@ -150,7 +150,7 @@ public void ShouldThrowWhenThereIsNoSpaceMatchTheProvidedName() var argsWithSpaceName = CommandLineArgs.Concat(new[] { "--space=nonExistent" }); Func action = async () => await apiCommand.Execute(argsWithSpaceName.ToArray()).ConfigureAwait(false); - action.ShouldThrow().WithMessage("Cannot find the space with name or id 'nonExistent'. Please check the spelling and that you have permissions to view it. Please use Configuration > Test Permissions to confirm."); + await action.Should().ThrowAsync().WithMessage("Cannot find the space with name or id 'nonExistent'. Please check the spelling and that you have permissions to view it. Please use Configuration > Test Permissions to confirm."); } } } diff --git a/source/Octo.Tests/Commands/CleanEnvironmentCommandFixture.cs b/source/Octo.Tests/Commands/CleanEnvironmentCommandFixture.cs index b00856430d..3edabd9a84 100644 --- a/source/Octo.Tests/Commands/CleanEnvironmentCommandFixture.cs +++ b/source/Octo.Tests/Commands/CleanEnvironmentCommandFixture.cs @@ -113,30 +113,30 @@ public void ShouldRemoveMachinesBelongingToMultipleEnvironmentsInsteadOfDeleting } [Test] - public void ShouldNotCleanEnvironmentWithMissingEnvironmentArgs() + public async Task ShouldNotCleanEnvironmentWithMissingEnvironmentArgs() { Func exec = () => listMachinesCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify an environment name using the parameter: --environment=XYZ"); } [Test] - public void ShouldNotCleanEnvironmentWithMissingStatusArgs() + public async Task ShouldNotCleanEnvironmentWithMissingStatusArgs() { CommandLineArgs.Add("-environment=Development"); Func exec = () => listMachinesCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a status using the parameter: --status or --health-status"); } [Test] - public void ShouldNotCleanTheEnvironmentIfEnvironmentNotFound() + public async Task ShouldNotCleanTheEnvironmentIfEnvironmentNotFound() { CommandLineArgs.Add("-environment=Development"); CommandLineArgs.Add("-status=Offline"); Func exec = () => listMachinesCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Could not find the specified environment; either it does not exist or you lack permissions to view it."); } diff --git a/source/Octo.Tests/Commands/CleanWorkerPoolCommandFixture.cs b/source/Octo.Tests/Commands/CleanWorkerPoolCommandFixture.cs index 121f2437ca..4a5120ed54 100644 --- a/source/Octo.Tests/Commands/CleanWorkerPoolCommandFixture.cs +++ b/source/Octo.Tests/Commands/CleanWorkerPoolCommandFixture.cs @@ -90,30 +90,30 @@ public void ShouldRemoveMachinesBelongingToMultiplePoolsInsteadOfDeleting() } [Test] - public void ShouldNotCleanPoolWithMissingPoolArgs() + public async Task ShouldNotCleanPoolWithMissingPoolArgs() { Func exec = () => cleanPoolCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a worker pool name using the parameter: --workerpool=XYZ"); } [Test] - public void ShouldNotCleanPoolWithMissingStatusArgs() + public async Task ShouldNotCleanPoolWithMissingStatusArgs() { CommandLineArgs.Add("-workerpool=SomePool"); Func exec = () => cleanPoolCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a status using the parameter: --health-status"); } [Test] - public void ShouldNotCleanIfPoolNotFound() + public async Task ShouldNotCleanIfPoolNotFound() { CommandLineArgs.Add("-workerpool=SomePool"); CommandLineArgs.Add("-health-status=Unhealthy"); Func exec = () => cleanPoolCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Could not find the specified worker pool; either it does not exist or you lack permissions to view it."); } diff --git a/source/Octo.Tests/Commands/CreateChannelCommandFixture.cs b/source/Octo.Tests/Commands/CreateChannelCommandFixture.cs index a6fb493bb2..6d4e680053 100644 --- a/source/Octo.Tests/Commands/CreateChannelCommandFixture.cs +++ b/source/Octo.Tests/Commands/CreateChannelCommandFixture.cs @@ -22,14 +22,14 @@ public void SetUp() } [Test] - public void ShouldThrowBecauseOfMissingParameters() + public async Task ShouldThrowBecauseOfMissingParameters() { Func exec = () => createChannelCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] - public void ShouldThrowForOlderOctopusServers() + public async Task ShouldThrowForOlderOctopusServers() { Repository.LoadRootDocument() .Returns(new RootResource @@ -42,7 +42,7 @@ public void ShouldThrowForOlderOctopusServers() CommandLineArgs.Add($"--lifecycle={$"Lifecycle-{Guid.NewGuid()}"}"); Func exec = () => createChannelCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] diff --git a/source/Octo.Tests/Commands/CreateReleaseCommandFixture.cs b/source/Octo.Tests/Commands/CreateReleaseCommandFixture.cs index 0b491d4b43..7f50fe79d6 100644 --- a/source/Octo.Tests/Commands/CreateReleaseCommandFixture.cs +++ b/source/Octo.Tests/Commands/CreateReleaseCommandFixture.cs @@ -39,9 +39,9 @@ public void ShouldLoadOptionsFromFile() createReleaseCommand.Execute("--configfile=Commands/Resources/CreateRelease.config.txt"); }); - Assert.AreEqual("Test Project", createReleaseCommand.ProjectNameOrId); - Assert.AreEqual("1.0.0", createReleaseCommand.VersionNumberParameterValue); - Assert.AreEqual("Test config file.", createReleaseCommand.ReleaseNotes); + Assert.That("Test Project", Is.EqualTo( createReleaseCommand.ProjectNameOrId)); + Assert.That("1.0.0", Is.EqualTo( createReleaseCommand.VersionNumberParameterValue)); + Assert.That("Test config file.", Is.EqualTo(createReleaseCommand.ReleaseNotes)); } [Test] diff --git a/source/Octo.Tests/Commands/DeleteAutoDeployOverrideCommandFixture.cs b/source/Octo.Tests/Commands/DeleteAutoDeployOverrideCommandFixture.cs index 54b34dfe5f..b133f7dd1e 100644 --- a/source/Octo.Tests/Commands/DeleteAutoDeployOverrideCommandFixture.cs +++ b/source/Octo.Tests/Commands/DeleteAutoDeployOverrideCommandFixture.cs @@ -84,7 +84,7 @@ public async Task ShouldDeleteOverrideForEnvironment() LogLines.Should().Contain("Deleted auto deploy release override for the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); - Assert.True(!savedProject.AutoDeployReleaseOverrides.Any()); + Assert.That(!savedProject.AutoDeployReleaseOverrides.Any(), Is.True); } [Test] @@ -100,7 +100,7 @@ public async Task ShouldDeleteOverrideForTenantByName() LogLines.Should().Contain("Deleted auto deploy release override for the project OctoFx to the environment Production and tenant Octopus"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); - Assert.True(!savedProject.AutoDeployReleaseOverrides.Any()); + Assert.That(!savedProject.AutoDeployReleaseOverrides.Any(), Is.True); } [Test] @@ -116,7 +116,7 @@ public async Task ShouldDeleteOverrideForTenantByTag() LogLines.Should().Contain("Deleted auto deploy release override for the project OctoFx to the environment Production and tenant Octopus"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); - Assert.True(!savedProject.AutoDeployReleaseOverrides.Any()); + Assert.That(!savedProject.AutoDeployReleaseOverrides.Any(), Is.True); } [Test] diff --git a/source/Octo.Tests/Commands/DeletePackageCommandFixture.cs b/source/Octo.Tests/Commands/DeletePackageCommandFixture.cs index 0607e1e097..93f9b4b7fd 100644 --- a/source/Octo.Tests/Commands/DeletePackageCommandFixture.cs +++ b/source/Octo.Tests/Commands/DeletePackageCommandFixture.cs @@ -42,25 +42,25 @@ public async Task DefaultOutput_ShouldDeleteTheGivenPackage() deletePackageCommand.PrintJsonOutput(); var logOutput = LogOutput.ToString(); - Assert.True(logOutput.Contains("\"Status\": \"Success\"")); - Assert.True(logOutput.Contains($"\"PackageId\": \"{packageId}\"")); - Assert.True(logOutput.Contains($"\"Version\": \"{packageVersion}\"")); + logOutput.Should().Contain("\"Status\": \"Success\""); + logOutput.Should().Contain($"\"PackageId\": \"{packageId}\""); + logOutput.Should().Contain($"\"Version\": \"{packageVersion}\""); } [Test] - public void CommandException_ShouldNotSearchForPackageWhenThereIsNoPackageId() + public async Task CommandException_ShouldNotSearchForPackageWhenThereIsNoPackageId() { Func exec = () => deletePackageCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a package id using the parameter: --packageId=XYZ"); } [Test] - public void CommandException_ShouldNotSearchForPackageWhenThereIsNoPackageVersion() + public async Task CommandException_ShouldNotSearchForPackageWhenThereIsNoPackageVersion() { deletePackageCommand.PackageId = "TestPackage"; Func exec = () => deletePackageCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a package version using the parameter: --version=1.0.0"); } } diff --git a/source/Octo.Tests/Commands/DeployReleaseCommandTestFixture.cs b/source/Octo.Tests/Commands/DeployReleaseCommandTestFixture.cs index d748a87f49..80b9b0dec2 100644 --- a/source/Octo.Tests/Commands/DeployReleaseCommandTestFixture.cs +++ b/source/Octo.Tests/Commands/DeployReleaseCommandTestFixture.cs @@ -59,7 +59,7 @@ public void SetUp() } [Test] - public void ShouldCancelDeploymentOnTimeoutIfRequested() + public async Task ShouldCancelDeploymentOnTimeoutIfRequested() { Repository.Tasks .When(x => x.WaitForCompletion(Arg.Any(), Arg.Any(), TimeSpan.FromSeconds(1), Arg.Any>())) @@ -73,13 +73,13 @@ public void ShouldCancelDeploymentOnTimeoutIfRequested() CommandLineArgs.Add("--cancelontimeout"); Func exec = () => deployReleaseCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); Repository.Tasks.Received().Cancel(taskResource).GetAwaiter().GetResult(); } [Test] - public void ShouldNotCancelDeploymentOnTimeoutIfNotRequested() + public async Task ShouldNotCancelDeploymentOnTimeoutIfNotRequested() { Repository.Tasks .When(x => x.WaitForCompletion(Arg.Any(), Arg.Any(), TimeSpan.FromSeconds(1), Arg.Any>())) @@ -92,14 +92,14 @@ public void ShouldNotCancelDeploymentOnTimeoutIfNotRequested() CommandLineArgs.Add("--progress"); Func exec = () => deployReleaseCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); - Repository.Tasks.DidNotReceive().Cancel(Arg.Any()); + await Repository.Tasks.DidNotReceive().Cancel(Arg.Any()); } [TestCase("1.0.0")] [TestCase("somedockertag")] - public void ShouldRejectIfMultipleEnvironmentsAndTenanted(string version) + public async Task ShouldRejectIfMultipleEnvironmentsAndTenanted(string version) { CommandLineArgs.Add("--project=" + ProjectName); CommandLineArgs.Add("--deploymenttimeout=00:00:01"); @@ -111,10 +111,10 @@ public void ShouldRejectIfMultipleEnvironmentsAndTenanted(string version) CommandLineArgs.Add("--cancelontimeout"); Func exec = () => deployReleaseCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify only one environment at a time when deploying to tenants."); - Repository.Deployments.DidNotReceive().Create(Arg.Any()); + await Repository.Deployments.DidNotReceive().Create(Arg.Any()); } [TestCase("1.0.0")] diff --git a/source/Octo.Tests/Commands/ListMachinesCommandFixture.cs b/source/Octo.Tests/Commands/ListMachinesCommandFixture.cs index 27026e39e5..843d56166f 100644 --- a/source/Octo.Tests/Commands/ListMachinesCommandFixture.cs +++ b/source/Octo.Tests/Commands/ListMachinesCommandFixture.cs @@ -418,7 +418,7 @@ public async Task ShouldThrowIfUsingHealthStatusPre34() (await Repository.LoadRootDocument()).Version = "3.1.0"; Func exec = () => listMachinesCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("The `--health-status` parameter is only available on Octopus Server instances from 3.4.0 onwards."); } diff --git a/source/Octo.Tests/Commands/OverrideAutoDeployCommandFixture.cs b/source/Octo.Tests/Commands/OverrideAutoDeployCommandFixture.cs index 839d51ca19..72011f0a4a 100644 --- a/source/Octo.Tests/Commands/OverrideAutoDeployCommandFixture.cs +++ b/source/Octo.Tests/Commands/OverrideAutoDeployCommandFixture.cs @@ -91,10 +91,10 @@ public async Task ShouldAddOverrideForEnvironmentAndRelease() LogLines.Should().Contain("Auto deploy will deploy version 1.2.0 of the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); var autoDeployOverride = savedProject.AutoDeployReleaseOverrides.Single(); - Assert.AreEqual(project.Id, savedProject.Id); - Assert.AreEqual(release.Id, autoDeployOverride.ReleaseId); - Assert.AreEqual(null, autoDeployOverride.TenantId); - Assert.AreEqual(environment.Id, autoDeployOverride.EnvironmentId); + Assert.That(project.Id, Is.EqualTo(savedProject.Id)); + Assert.That(release.Id, Is.EqualTo(autoDeployOverride.ReleaseId)); + Assert.That(null, Is.EqualTo(autoDeployOverride.TenantId)); + Assert.That(environment.Id, Is.EqualTo(autoDeployOverride.EnvironmentId)); } [Test] @@ -109,10 +109,10 @@ public async Task ShouldAddOverrideForEnvironmentAndDockerTagVersionedRelease() LogLines.Should().Contain("Auto deploy will deploy version somedockertag of the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); var autoDeployOverride = savedProject.AutoDeployReleaseOverrides.Single(); - Assert.AreEqual(project.Id, savedProject.Id); - Assert.AreEqual(release2.Id, autoDeployOverride.ReleaseId); - Assert.AreEqual(null, autoDeployOverride.TenantId); - Assert.AreEqual(environment.Id, autoDeployOverride.EnvironmentId); + Assert.That(project.Id, Is.EqualTo(savedProject.Id)); + Assert.That(release2.Id, Is.EqualTo(autoDeployOverride.ReleaseId)); + Assert.That(null, Is.EqualTo(autoDeployOverride.TenantId)); + Assert.That(environment.Id, Is.EqualTo(autoDeployOverride.EnvironmentId)); } [Test] @@ -128,10 +128,10 @@ public async Task ShouldAddOverrideForTenantsByName() LogLines.Should().Contain("Auto deploy will deploy version 1.2.0 of the project OctoFx to the environment Production for the tenant Octopus"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); var autoDeployOverride = savedProject.AutoDeployReleaseOverrides.Single(); - Assert.AreEqual(project.Id, savedProject.Id); - Assert.AreEqual(release.Id, autoDeployOverride.ReleaseId); - Assert.AreEqual(octopusTenant.Id, autoDeployOverride.TenantId); - Assert.AreEqual(environment.Id, autoDeployOverride.EnvironmentId); + Assert.That(project.Id, Is.EqualTo(savedProject.Id)); + Assert.That(release.Id, Is.EqualTo(autoDeployOverride.ReleaseId)); + Assert.That(octopusTenant.Id, Is.EqualTo(autoDeployOverride.TenantId)); + Assert.That(environment.Id, Is.EqualTo(autoDeployOverride.EnvironmentId)); } [Test] @@ -147,10 +147,10 @@ public async Task ShouldAddOverrideForTenantsByTag() LogLines.Should().Contain("Auto deploy will deploy version 1.2.0 of the project OctoFx to the environment Production for the tenant Octopus"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); var autoDeployOverride = savedProject.AutoDeployReleaseOverrides.Single(); - Assert.AreEqual(project.Id, savedProject.Id); - Assert.AreEqual(release.Id, autoDeployOverride.ReleaseId); - Assert.AreEqual(octopusTenant.Id, autoDeployOverride.TenantId); - Assert.AreEqual(environment.Id, autoDeployOverride.EnvironmentId); + Assert.That(project.Id, Is.EqualTo(savedProject.Id)); + Assert.That(release.Id, Is.EqualTo(autoDeployOverride.ReleaseId)); + Assert.That(octopusTenant.Id, Is.EqualTo(autoDeployOverride.TenantId)); + Assert.That(environment.Id, Is.EqualTo(autoDeployOverride.EnvironmentId)); } [Test] diff --git a/source/Octo.Tests/Commands/PreventReleaseProgressionCommandFixture.cs b/source/Octo.Tests/Commands/PreventReleaseProgressionCommandFixture.cs index 99ebc65277..60731d79fe 100644 --- a/source/Octo.Tests/Commands/PreventReleaseProgressionCommandFixture.cs +++ b/source/Octo.Tests/Commands/PreventReleaseProgressionCommandFixture.cs @@ -88,55 +88,55 @@ public void ShouldBeAttachedWithCorrectAttribute() [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void ShouldValidateProjectIdOrNameParameterForMissing(string projectIdOrName) + public async Task ShouldValidateProjectIdOrNameParameterForMissing(string projectIdOrName) { CommandLineArgs.Add($"--project={projectIdOrName}"); CommandLineArgs.Add($"--version={releaseResource.Version}"); CommandLineArgs.Add($"--reason={ReasonToPrevent}"); Func exec = () => preventReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a project name or ID using the parameter: --project=XYZ"); } [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void ShouldValidateReasonToPreventParameterForMissing(string reasonToPrevent) + public async Task ShouldValidateReasonToPreventParameterForMissing(string reasonToPrevent) { CommandLineArgs.Add($"--project={projectResource.Name}"); CommandLineArgs.Add($"--version={releaseResource.Version}"); CommandLineArgs.Add($"--reason={reasonToPrevent}"); Func exec = () => preventReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a reason why you would like to prevent this release from progressing to next phase using the reason parameter: --reason=Contract Tests Failed"); } [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void ShouldValidateReleaseVersionNumberParameterForMissing(string releaseVersionNumber) + public async Task ShouldValidateReleaseVersionNumberParameterForMissing(string releaseVersionNumber) { CommandLineArgs.Add($"--project={projectResource.Name}"); CommandLineArgs.Add($"--reason={ReasonToPrevent}"); CommandLineArgs.Add($"--version={releaseVersionNumber}"); Func exec = () => preventReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please specify a release version number using the version parameter: --version=1.0.5"); } [TestCase("999999999999999999999999999999999999999999999999999999")] [Description("Number larger than an int")] - public void ShouldValidateReleaseVersionNumberParameterForFormat(string releaseVersionNumber) + public async Task ShouldValidateReleaseVersionNumberParameterForFormat(string releaseVersionNumber) { CommandLineArgs.Add($"--project={projectResource.Name}"); CommandLineArgs.Add($"--reason={ReasonToPrevent}"); CommandLineArgs.Add($"--version={releaseVersionNumber}"); Func exec = () => preventReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow() + await exec.Should().ThrowAsync() .WithMessage("Please provide a valid release version format: --version=1.0.5"); } @@ -168,7 +168,7 @@ public async Task ShouldSupportDockerVersionForRelease() } [Test] - public void ShouldThrowCorrectException_WhenReleaseNotFound() + public async Task ShouldThrowCorrectException_WhenReleaseNotFound() { Repository.Projects.GetReleaseByVersion(projectResource, releaseResource.Version).Returns((ReleaseResource)null); @@ -178,7 +178,7 @@ public void ShouldThrowCorrectException_WhenReleaseNotFound() Func exec = () => preventReleaseProgressionCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] diff --git a/source/Octo.Tests/Commands/RunRunbookCommandTestFixture.cs b/source/Octo.Tests/Commands/RunRunbookCommandTestFixture.cs index 2c24e3a7c3..bb58c68c5a 100644 --- a/source/Octo.Tests/Commands/RunRunbookCommandTestFixture.cs +++ b/source/Octo.Tests/Commands/RunRunbookCommandTestFixture.cs @@ -54,7 +54,7 @@ void AddRequiredArgs() } [Test] - public void ShouldCancelDeploymentOnTimeoutIfRequested() + public async Task ShouldCancelDeploymentOnTimeoutIfRequested() { AddRequiredArgs(); CommandLineArgs.Add("--runTimeout=00:00:01"); @@ -62,77 +62,77 @@ public void ShouldCancelDeploymentOnTimeoutIfRequested() CommandLineArgs.Add("--cancelontimeout"); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); Repository.Tasks.Received().Cancel(taskResource).GetAwaiter().GetResult(); } [Test] - public void ShouldNotCancelDeploymentOnTimeoutIfNotRequested() + public async Task ShouldNotCancelDeploymentOnTimeoutIfNotRequested() { AddRequiredArgs(); CommandLineArgs.Add("--runTimeout=00:00:01"); CommandLineArgs.Add("--progress"); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); - Repository.Tasks.DidNotReceive().Cancel(Arg.Any()); + await Repository.Tasks.DidNotReceive().Cancel(Arg.Any()); } [Test] [TestCase("--project=" + ProjectName, "--environment=" + ValidEnvironment)] [TestCase("--runbook=" + RunbookName, "--environment=" + ValidEnvironment)] [TestCase("--project=" + ProjectName, "--runbook=" + RunbookName)] - public void WhenARequiredParameterIsNotSupplied_ShouldThrowException(params string[] arguments) + public async Task WhenARequiredParameterIsNotSupplied_ShouldThrowException(params string[] arguments) { foreach (var arg in arguments) CommandLineArgs.Add(arg); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] - public void WhenAllRequiredParametersAreSupplied_ShouldNotThrowException() + public async Task WhenAllRequiredParametersAreSupplied_ShouldNotThrowException() { AddRequiredArgs(); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldNotThrow(); + await exec.Should().NotThrowAsync(); } [Test] - public void WhenRunAtSuppliedIsAfterNotRunAfter_ShouldThrowException() + public async Task WhenRunAtSuppliedIsAfterNotRunAfter_ShouldThrowException() { AddRequiredArgs(); CommandLineArgs.Add("--runAt=" + "2020-07-16T03:00:00Z"); CommandLineArgs.Add("--notRunAfter=" + "2020-07-15T03:00:00Z"); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] - public void WhenIncludedMachinesIntersectsWithExcludedMachines_ShouldThrowException() + public async Task WhenIncludedMachinesIntersectsWithExcludedMachines_ShouldThrowException() { AddRequiredArgs(); CommandLineArgs.Add("--specificMachines=" + "one,two"); CommandLineArgs.Add("--excludeMachines=" + "two,three"); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } [Test] - public void WhenATentantWildcardIsSupplied_NoOtherTenantIdsOrTagsCanBeSupplied() + public async Task WhenATentantWildcardIsSupplied_NoOtherTenantIdsOrTagsCanBeSupplied() { AddRequiredArgs(); CommandLineArgs.Add("--tenant=" + "*"); CommandLineArgs.Add("--tenantTag=" + "beta,stable"); Func exec = () => runRunbookCommand.Execute(CommandLineArgs.ToArray()); - exec.ShouldThrow(); + await exec.Should().ThrowAsync(); } } } diff --git a/source/Octo.Tests/Commands/SupportFormattedOutputFixture.cs b/source/Octo.Tests/Commands/SupportFormattedOutputFixture.cs index 16653f4354..59cea74f74 100644 --- a/source/Octo.Tests/Commands/SupportFormattedOutputFixture.cs +++ b/source/Octo.Tests/Commands/SupportFormattedOutputFixture.cs @@ -32,7 +32,7 @@ public async Task FormattedOutput_FormatSetToJson() await command.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); - command.PrintJsonOutputCalled.ShouldBeEquivalentTo(true); + Assert.That(command.PrintJsonOutputCalled, Is.True); } [Test] diff --git a/source/Octo.Tests/Diagnostics/LogUtilitiesFixture.cs b/source/Octo.Tests/Diagnostics/LogUtilitiesFixture.cs index 8067fac501..148cf50d0d 100644 --- a/source/Octo.Tests/Diagnostics/LogUtilitiesFixture.cs +++ b/source/Octo.Tests/Diagnostics/LogUtilitiesFixture.cs @@ -14,8 +14,8 @@ public sealed class LogUtilitiesFixture public void ShouldThrowIfUnknownLogLevelIsProvided() { var result = Assert.Throws(() => LogUtilities.ParseLogLevel("z")); - result.Message.ShouldBeEquivalentTo("Unrecognized loglevel 'z'. Valid options are verbose, debug, information, warning, error and fatal. " + - "Defaults to 'debug'."); + Assert.That(result.Message, Is.EquivalentTo("Unrecognized loglevel 'z'. Valid options are verbose, debug, information, warning, error and fatal. " + + "Defaults to 'debug'.")); } [TestCase("fatal", LogEventLevel.Fatal)] @@ -27,7 +27,7 @@ public void ShouldThrowIfUnknownLogLevelIsProvided() public void ShouldParseLogLevelCorrectly(string value, LogEventLevel level) { var result = LogUtilities.ParseLogLevel(value); - result.ShouldBeEquivalentTo(level); + Assert.That(result, Is.EqualTo(level)); } } } diff --git a/source/Octo.Tests/Octo.Tests.csproj b/source/Octo.Tests/Octo.Tests.csproj index d59ca56c1b..87d33937eb 100644 --- a/source/Octo.Tests/Octo.Tests.csproj +++ b/source/Octo.Tests/Octo.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 Octo.Tests true false @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers @@ -21,11 +21,11 @@ - - - - - + + + + + diff --git a/source/Octo.Tests/Util/CommandSuggesterFixture.cs b/source/Octo.Tests/Util/CommandSuggesterFixture.cs index 7d23eaf126..1be827fc1a 100644 --- a/source/Octo.Tests/Util/CommandSuggesterFixture.cs +++ b/source/Octo.Tests/Util/CommandSuggesterFixture.cs @@ -20,7 +20,7 @@ public class CompleteCommandFixture [TestCaseSource(nameof(GetTestCases))] public void ShouldGetCorrectCompletions(string[] words, string[] expectedItems) { - CommandSuggester.SuggestCommandsFor(words, testCompletionItems).ShouldBeEquivalentTo(expectedItems); + Assert.That(CommandSuggester.SuggestCommandsFor(words, testCompletionItems), Is.EquivalentTo(expectedItems)); } static IEnumerable GetTestCases() diff --git a/source/Octo.Tests/Util/UriExtensionsFixture.cs b/source/Octo.Tests/Util/UriExtensionsFixture.cs index 1e319c31e1..10cd35d6ee 100644 --- a/source/Octo.Tests/Util/UriExtensionsFixture.cs +++ b/source/Octo.Tests/Util/UriExtensionsFixture.cs @@ -12,7 +12,7 @@ public void ShouldAppendSuffixIfThereIsNoOverlap() { var result = new Uri("http://www.mysite.com").EnsureEndsWith("suffix"); - Assert.AreEqual(result.ToString(), "http://www.mysite.com/suffix"); + Assert.That(result.ToString(), Is.EqualTo("http://www.mysite.com/suffix")); } [Test] @@ -20,7 +20,7 @@ public void ShouldRemoveAnyOverlapBetweenBaseAddresAndSuffix() { var result = new Uri("http://www.mysite.com/virtual").EnsureEndsWith("/virtual/suffix"); - Assert.AreEqual(result.ToString(), "http://www.mysite.com/virtual/suffix"); + Assert.That(result.ToString(), Is.EqualTo("http://www.mysite.com/virtual/suffix")); } } } diff --git a/source/Octo/Octo.csproj b/source/Octo/Octo.csproj index bb91d700a0..e82394751d 100644 --- a/source/Octo/Octo.csproj +++ b/source/Octo/Octo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1;net6.0 + net8.0 true portable octo diff --git a/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs b/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs deleted file mode 100644 index 468a7845aa..0000000000 --- a/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Octopus.Cli.Repositories; -using Octopus.Cli.Util; -using Octopus.Client; -using Octopus.Client.Model; -using Octopus.Client.Model.PackageMetadata; -using Octopus.CommandLine; -using Octopus.CommandLine.Commands; - -namespace Octopus.Cli.Commands.Package -{ - [Command("push-metadata", Description = "Pushes package metadata to Octopus Server. Deprecated. Please use the build-information command for Octopus Server 2019.10.0 and above.")] - public class PushMetadataCommand : ApiCommand, ISupportFormattedOutput - { - static readonly OverwriteMode DefaultOverwriteMode = OverwriteMode.FailIfExists; - - OctopusPackageMetadataMappedResource resultResource; - - public PushMetadataCommand(IOctopusAsyncRepositoryFactory repositoryFactory, IOctopusFileSystem fileSystem, IOctopusClientFactory clientFactory, ICommandOutputProvider commandOutputProvider) - : base(clientFactory, repositoryFactory, fileSystem, commandOutputProvider) - { - var options = Options.For("Package metadata pushing"); - options.Add("package-id=", "The ID of the package, e.g., 'MyCompany.MyApp'.", v => PackageId = v); - options.Add("version=", "The version of the package; defaults to a timestamp-based version.", v => Version = v); - options.Add("metadata-file=", "Octopus Package metadata Json file.", file => MetadataFile = file); - options.Add("overwrite-mode=", $"Determines behavior if the package already exists in the repository. Valid values are {Enum.GetNames(typeof(OverwriteMode)).ReadableJoin()}. Default is {DefaultOverwriteMode}.", mode => OverwriteMode = mode); - options.Add("replace-existing", "If the package metadata already exists in the repository, the default behavior is to reject the new package metadata being pushed. You can pass this flag to overwrite the existing package metadata. This flag may be deprecated in a future version; passing it is the same as using the OverwriteExisting overwrite-mode.", replace => OverwriteMode = OverwriteMode.OverwriteExisting); - } - - public string PackageId { get; set; } - public string Version { get; set; } - public string MetadataFile { get; set; } - public OverwriteMode OverwriteMode { get; set; } = DefaultOverwriteMode; - - public async Task Request() - { - if (string.IsNullOrEmpty(MetadataFile)) - throw new CommandException("Please specify the metadata file."); - if (string.IsNullOrEmpty(PackageId)) - throw new CommandException("Please specify the package id."); - if (string.IsNullOrEmpty(Version)) - throw new CommandException("Please specify the package version."); - - if (!FileSystem.FileExists(MetadataFile)) - throw new CommandException($"Metadata file '{MetadataFile}' does not exist"); - - var rootDocument = await Repository.LoadRootDocument(); - if (rootDocument.HasLink("BuildInformation")) - commandOutputProvider.Warning("This Octopus server supports the BuildInformation API, we recommend using the `build-information` command as `package-metadata` has been deprecated."); - - commandOutputProvider.Debug("Pushing package metadata: {PackageId}...", PackageId); - - var fileContent = FileSystem.ReadAllText(MetadataFile); - var octopusPackageMetadata = JsonConvert.DeserializeObject(fileContent); - - resultResource = await Repository.PackageMetadataRepository.Push(PackageId, Version, octopusPackageMetadata, OverwriteMode); - } - - public void PrintDefaultOutput() - { - commandOutputProvider.Debug("Push successful"); - } - - public void PrintJsonOutput() - { - commandOutputProvider.Json(resultResource); - } - } -} diff --git a/source/Octopus.Cli/Octopus.Cli.csproj b/source/Octopus.Cli/Octopus.Cli.csproj index 84ff594397..984cf3adff 100644 --- a/source/Octopus.Cli/Octopus.Cli.csproj +++ b/source/Octopus.Cli/Octopus.Cli.csproj @@ -1,7 +1,7 @@  - netstandard2.1;net6.0 + net8.0 Octopus Deploy Octopus Deploy Pty Ltd Apache-2.0 @@ -23,23 +23,23 @@ all runtime; build; native; contentfiles; analyzers - + - + - + - - + + - + diff --git a/source/Octopus.DotNet.Cli/Octopus.DotNet.Cli.csproj b/source/Octopus.DotNet.Cli/Octopus.DotNet.Cli.csproj index 0a86a7ee6f..5b3918bde6 100644 --- a/source/Octopus.DotNet.Cli/Octopus.DotNet.Cli.csproj +++ b/source/Octopus.DotNet.Cli/Octopus.DotNet.Cli.csproj @@ -6,7 +6,7 @@ We include all possible targets here so that no matter what framework version the user has installed, there is an appropriate build in the tools package --> - netcoreapp3.1;net6.0 + net8.0 True dotnet-octo Octopus.DotNet.Cli diff --git a/source/OctopusCli.sln.DotSettings b/source/OctopusCli.sln.DotSettings index f05dab78fe..843b49c73d 100644 --- a/source/OctopusCli.sln.DotSettings +++ b/source/OctopusCli.sln.DotSettings @@ -199,6 +199,8 @@ <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb" /></Policy> True F:\OctopusGit\OctopusDeploy\source\Octopus.sln.DotSettings @@ -211,11 +213,13 @@ True True True + True True True True True True + True True False False diff --git a/source/global.json b/source/global.json new file mode 100644 index 0000000000..b5b37b60d7 --- /dev/null +++ b/source/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "8.0.0", + "rollForward": "latestMajor", + "allowPrerelease": false + } +} \ No newline at end of file