From 6322d70086de36fc59c29eb0d164ed199429f7a5 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Tue, 11 Jun 2024 15:58:00 +0200 Subject: [PATCH] Remove CQCHookEndpoint related fields as package metadata now contains it --- src/ARCExpect/ARCExpect.fsproj | 2 +- src/ARCExpect/ARCValidationPackage.fs | 14 ++----- src/ARCExpect/BadgeCreation.fs | 2 +- src/ARCExpect/RELEASE_NOTES.md | 4 ++ src/ARCExpect/TopLevelAPI.fs | 17 +++------ src/ARCExpect/ValidationSummary.fs | 11 +++--- .../ARCValidationPackages.fsproj | 4 +- src/ARCValidationPackages/RELEASE_NOTES.md | 6 ++- src/arc-validate/APIs/ValidateAPI.fs | 10 ++--- src/arc-validate/arc-validate.fsproj | 4 +- tests/ARCExpect.Tests/ReferenceObjects.fs | 9 +++-- tests/ARCExpect.Tests/TopLevelAPITests.fs | 18 +++------ .../ARCExpect.Tests/ValidationSummaryTests.fs | 4 +- .../TopLevelAPITests.fs | 37 +++++++------------ 14 files changed, 60 insertions(+), 82 deletions(-) diff --git a/src/ARCExpect/ARCExpect.fsproj b/src/ARCExpect/ARCExpect.fsproj index 248ca4c..f44e855 100644 --- a/src/ARCExpect/ARCExpect.fsproj +++ b/src/ARCExpect/ARCExpect.fsproj @@ -34,6 +34,6 @@ - + \ No newline at end of file diff --git a/src/ARCExpect/ARCValidationPackage.fs b/src/ARCExpect/ARCValidationPackage.fs index fddf4cc..b06bbd9 100644 --- a/src/ARCExpect/ARCValidationPackage.fs +++ b/src/ARCExpect/ARCValidationPackage.fs @@ -8,19 +8,16 @@ type ARCValidationPackage = Metadata: ValidationPackageMetadata CriticalValidationCases: Test NonCriticalValidationCases: Test - CQCHookEndpoint: string option } with static member create ( metadata: ValidationPackageMetadata, criticalValidationCases: Test, - nonCriticalValidationCases: Test, - ?CQCHookEndpoint: string + nonCriticalValidationCases: Test ) = { Metadata = metadata CriticalValidationCases = criticalValidationCases NonCriticalValidationCases = nonCriticalValidationCases - CQCHookEndpoint = CQCHookEndpoint } static member create ( @@ -35,19 +32,16 @@ type ARCValidationPackage = ARCValidationPackage.create( metadata = metadata, criticalValidationCases = criticalCases, - nonCriticalValidationCases = nonCriticalCases, - ?CQCHookEndpoint = CQCHookEndpoint + nonCriticalValidationCases = nonCriticalCases ) static member create ( metadata: ValidationPackageMetadata, ?CriticalValidationCasesList: Test list, - ?NonCriticalValidationCasesList: Test list, - ?CQCHookEndpoint: string + ?NonCriticalValidationCasesList: Test list ) = ARCValidationPackage.create( metadata = metadata, criticalValidationCasesList = defaultArg CriticalValidationCasesList [], - nonCriticalValidationCasesList = defaultArg NonCriticalValidationCasesList [], - ?CQCHookEndpoint = CQCHookEndpoint + nonCriticalValidationCasesList = defaultArg NonCriticalValidationCasesList [] ) \ No newline at end of file diff --git a/src/ARCExpect/BadgeCreation.fs b/src/ARCExpect/BadgeCreation.fs index eedad9d..5ce2985 100644 --- a/src/ARCExpect/BadgeCreation.fs +++ b/src/ARCExpect/BadgeCreation.fs @@ -34,7 +34,7 @@ type BadgeCreation = defaultColor = (DefaultColor |> Option.defaultValue (Color.fromString Defaults.DEFAULT_COLOR) ), Thresholds = thresholds, value = testResults.passed.Length, - ValueSuffix = $"/{max}" + ValueSuffix = valueSuffix ) diff --git a/src/ARCExpect/RELEASE_NOTES.md b/src/ARCExpect/RELEASE_NOTES.md index e5495cb..993fa0b 100644 --- a/src/ARCExpect/RELEASE_NOTES.md +++ b/src/ARCExpect/RELEASE_NOTES.md @@ -1,3 +1,7 @@ +### 3.0.0 - (Released 2024-04-30) + +Remove separate `CQCHookEndpoint` because it is now directly contained in package metadata. + ### 2.0.0 - (Released 2024-04-30) Major rework and improvements of the **ARCExpect API**. The main changes are: diff --git a/src/ARCExpect/TopLevelAPI.fs b/src/ARCExpect/TopLevelAPI.fs index bc69335..83d71f3 100644 --- a/src/ARCExpect/TopLevelAPI.fs +++ b/src/ARCExpect/TopLevelAPI.fs @@ -15,14 +15,12 @@ type Setup = static member ValidationPackage( metadata: ValidationPackageMetadata, ?CriticalValidationCases: Test list, - ?NonCriticalValidationCases: Test list, - ?CQCHookEndpoint: string + ?NonCriticalValidationCases: Test list ) = ARCValidationPackage.create( metadata = metadata, ?CriticalValidationCasesList = CriticalValidationCases, - ?NonCriticalValidationCasesList = NonCriticalValidationCases, - ?CQCHookEndpoint = CQCHookEndpoint + ?NonCriticalValidationCasesList = NonCriticalValidationCases ) static member ValidationPackage( @@ -51,11 +49,11 @@ type Setup = ?Publish = Publish, ?Authors = Authors, ?Tags = Tags, - ?ReleaseNotes = ReleaseNotes + ?ReleaseNotes = ReleaseNotes, + ?CQCHookEndpoint = CQCHookEndpoint ), ?CriticalValidationCases = CriticalValidationCases, - ?NonCriticalValidationCases = NonCriticalValidationCases, - ?CQCHookEndpoint = CQCHookEndpoint + ?NonCriticalValidationCases = NonCriticalValidationCases ) type Execute = @@ -68,10 +66,7 @@ type Execute = ValidationSummary.ofExpectoTestRunSummaries( criticalSummary = criticalResults, nonCriticalSummary = nonCriticalResults, - package = ValidationPackageSummary.create( - arcValidationPackage.Metadata, - ?HookEndpoint = arcValidationPackage.CQCHookEndpoint - ) + package = ValidationPackageSummary.create(arcValidationPackage.Metadata) ) static member SummaryCreation( diff --git a/src/ARCExpect/ValidationSummary.fs b/src/ARCExpect/ValidationSummary.fs index 6508581..de02068 100644 --- a/src/ARCExpect/ValidationSummary.fs +++ b/src/ARCExpect/ValidationSummary.fs @@ -64,31 +64,30 @@ type ValidationPackageSummary = { Version: string Summary: string Description: string - HookEndpoint: string option + CQCHookEndpoint: string option } with static member create( name: string, version: string, summary: string, description: string, - ?HookEndpoint: string + ?CQCHookEndpoint: string ) = { Name = name Version = version Summary = summary Description = description - HookEndpoint = HookEndpoint + CQCHookEndpoint = CQCHookEndpoint } static member create ( - metadata: ValidationPackageMetadata, - ?HookEndpoint: string + metadata: ValidationPackageMetadata ) = ValidationPackageSummary.create( name = metadata.Name, version = ValidationPackageMetadata.getSemanticVersionString metadata, summary = metadata.Summary, description = metadata.Description, - ?HookEndpoint = HookEndpoint + ?CQCHookEndpoint = if metadata.CQCHookEndpoint = "" then None else Some metadata.CQCHookEndpoint ) /// diff --git a/src/ARCValidationPackages/ARCValidationPackages.fsproj b/src/ARCValidationPackages/ARCValidationPackages.fsproj index 98a78d2..e5e9698 100644 --- a/src/ARCValidationPackages/ARCValidationPackages.fsproj +++ b/src/ARCValidationPackages/ARCValidationPackages.fsproj @@ -22,8 +22,8 @@ - - + + diff --git a/src/ARCValidationPackages/RELEASE_NOTES.md b/src/ARCValidationPackages/RELEASE_NOTES.md index 4ac4927..d981e2b 100644 --- a/src/ARCValidationPackages/RELEASE_NOTES.md +++ b/src/ARCValidationPackages/RELEASE_NOTES.md @@ -1,4 +1,8 @@ -### 3.0.0 - (Released 2024-04-30) +### 4.0.0 - (Released 2024-04-30) + +Update to AVPRIndex v0.1.1 and AVPRClient v0.0.5 + +### 3.0.0 - (Released 2024-04-30) 3.0.0 release of the ArcValidationPackages API. diff --git a/src/arc-validate/APIs/ValidateAPI.fs b/src/arc-validate/APIs/ValidateAPI.fs index 3acbc3d..55ef8d6 100644 --- a/src/arc-validate/APIs/ValidateAPI.fs +++ b/src/arc-validate/APIs/ValidateAPI.fs @@ -37,6 +37,8 @@ module ValidateAPI = let version = args.TryGetResult(Package_Version) + let mutable exitCode = ExitCode.Success + match package with | None -> // Default call means validate schema conformity @@ -52,7 +54,6 @@ module ValidateAPI = let specVersion = defaultArg (args.TryGetResult(Specification_Version)) "latest" let status = AnsiConsole.Status() - let mutable exitCode = ExitCode.Success status.Start($"Performing validation against version '{specVersion}' of the ARC specification", fun ctx -> @@ -79,7 +80,6 @@ module ValidateAPI = | Some packageName -> // Validate against a specific package let status = AnsiConsole.Status() - let mutable exitCode = ExitCode.Success let isRelease = args.TryGetResult(ValidateArgs.Preview).IsSome |> not @@ -132,9 +132,5 @@ module ValidateAPI = AnsiConsole.MarkupLine($"[red]Package {packageName} not installed. You can run run [green]arc-validate package install [/] to install a validation package.[/]") exitCode <- ExitCode.InternalError ) - try - - ExitCode.Success - with e -> - ExitCode.CriticalTestFailure \ No newline at end of file + exitCode \ No newline at end of file diff --git a/src/arc-validate/arc-validate.fsproj b/src/arc-validate/arc-validate.fsproj index aa86eaa..257006b 100644 --- a/src/arc-validate/arc-validate.fsproj +++ b/src/arc-validate/arc-validate.fsproj @@ -26,8 +26,8 @@ - - + + diff --git a/tests/ARCExpect.Tests/ReferenceObjects.fs b/tests/ARCExpect.Tests/ReferenceObjects.fs index f876f88..1d110b2 100644 --- a/tests/ARCExpect.Tests/ReferenceObjects.fs +++ b/tests/ARCExpect.Tests/ReferenceObjects.fs @@ -54,7 +54,7 @@ module ValidationPackageSummary = Version = "1.0.0" Summary = "A package without CQC hook." Description = "A package without CQC hook. More text here." - HookEndpoint = None + CQCHookEndpoint = None } let withHook = { @@ -62,7 +62,7 @@ module ValidationPackageSummary = Version = "1.0.0" Summary = "A package with CQC hook." Description = "A package with CQC hook. More text here." - HookEndpoint = Some "http://test.com" + CQCHookEndpoint = Some "http://test.com" } module ValidationSummary = @@ -83,7 +83,7 @@ module ValidationSummary = ValidationPackage = ValidationPackageSummary.withHook } - let allPassedWithHookJson = """{"Critical":{"HasFailures":false,"Total":1,"Passed":1,"Failed":0,"Errored":0},"NonCritical":{"HasFailures":false,"Total":1,"Passed":1,"Failed":0,"Errored":0},"ValidationPackage":{"Name":"test","Version":"1.0.0","Summary":"A package with CQC hook.","Description":"A package with CQC hook. More text here.","HookEndpoint":"http://test.com"}}""" + let allPassedWithHookJson = """{"Critical":{"HasFailures":false,"Total":1,"Passed":1,"Failed":0,"Errored":0},"NonCritical":{"HasFailures":false,"Total":1,"Passed":1,"Failed":0,"Errored":0},"ValidationPackage":{"Name":"test","Version":"1.0.0","Summary":"A package with CQC hook.","Description":"A package with CQC hook. More text here.","CQCHookEndpoint":"http://test.com"}}""" let allFailedNoHook = { @@ -184,7 +184,8 @@ module ValidationPackageMetadata = MinorVersion = 0, PatchVersion = 0, Summary = "A package with CQC hook.", - Description = "A package with CQC hook. More text here." + Description = "A package with CQC hook. More text here.", + CQCHookEndpoint = "http://test.com" ) module JUnitReport = diff --git a/tests/ARCExpect.Tests/TopLevelAPITests.fs b/tests/ARCExpect.Tests/TopLevelAPITests.fs index 539abf9..9a155e3 100644 --- a/tests/ARCExpect.Tests/TopLevelAPITests.fs +++ b/tests/ARCExpect.Tests/TopLevelAPITests.fs @@ -47,8 +47,7 @@ let ``Toplevel API Setup tests`` = Expect.equal fromMetadata.Metadata.Publish fromValues.Metadata.Publish "metadata publish were not equal" Expect.equal fromMetadata.Metadata.Tags fromValues.Metadata.Tags "metadata tags were not equal" Expect.equal fromMetadata.Metadata.ReleaseNotes fromValues.Metadata.ReleaseNotes "metadata release notes were not equal" - - Expect.equal fromMetadata.CQCHookEndpoint fromValues.CQCHookEndpoint "hook endpoint was not equal" + Expect.equal fromMetadata.Metadata.CQCHookEndpoint fromValues.Metadata.CQCHookEndpoint "hook endpoint was not equal" } ] testList "Execute_Validation" [ @@ -68,8 +67,7 @@ let ``Toplevel API Setup tests`` = Setup.ValidationPackage( metadata = ReferenceObjects.ValidationPackageMetadata.validWithHook, CriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - CQCHookEndpoint = "http://test.com" + NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass] ) |> Execute.Validation Expect.validationSummaryEqualIgnoringOriginal actual ReferenceObjects.ValidationSummary.allPassedWithHook @@ -81,8 +79,7 @@ let ``Toplevel API Setup tests`` = Setup.ValidationPackage( metadata = ReferenceObjects.ValidationPackageMetadata.validWithHook, CriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - CQCHookEndpoint = "http://test.com" + NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass] ) |> Execute.Validation |> Execute.SummaryCreation path @@ -99,8 +96,7 @@ let ``Toplevel API Setup tests`` = Setup.ValidationPackage( metadata = ReferenceObjects.ValidationPackageMetadata.validWithHook, CriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - CQCHookEndpoint = "http://test.com" + NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass] ) |> Execute.Validation |> Execute.JUnitReportCreation path @@ -117,8 +113,7 @@ let ``Toplevel API Setup tests`` = Setup.ValidationPackage( metadata = ReferenceObjects.ValidationPackageMetadata.validWithHook, CriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - CQCHookEndpoint = "http://test.com" + NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass] ) |> Execute.Validation |> Execute.BadgeCreation(path, labelText="allPassedWithHook") @@ -134,8 +129,7 @@ let ``Toplevel API Setup tests`` = Setup.ValidationPackage( metadata = ReferenceObjects.ValidationPackageMetadata.validWithHook, CriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass], - CQCHookEndpoint = "http://test.com" + NonCriticalValidationCases = [ReferenceObjects.TestCase.dummyTestWillPass] ) |> Execute.ValidationPipeline( basePath = path diff --git a/tests/ARCExpect.Tests/ValidationSummaryTests.fs b/tests/ARCExpect.Tests/ValidationSummaryTests.fs index 5c3f706..db63197 100644 --- a/tests/ARCExpect.Tests/ValidationSummaryTests.fs +++ b/tests/ARCExpect.Tests/ValidationSummaryTests.fs @@ -31,7 +31,7 @@ let testPackageWithHook = ValidationPackageSummary.create( version = testPackageVersion, summary = testSummaryWithHook, description = testDescriptionWithHook, - HookEndpoint = testHook + CQCHookEndpoint = testHook ) [] @@ -63,7 +63,7 @@ let ``ValidationResult tests`` = version = testPackageVersion, summary = testSummaryWithHook, description = testDescriptionWithHook, - HookEndpoint = testHook + CQCHookEndpoint = testHook ) Expect.equal actual ReferenceObjects.ValidationPackageSummary.withHook "package summary was not equal" } diff --git a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs index 6a0b374..169c4aa 100644 --- a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs +++ b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs @@ -150,67 +150,58 @@ let ``Toplevel API tests`` = testSequenced (testList "SaveAndCachePackage" [ // here, wee need persistent config and caches across the tests instead of a fixture for each test case resetConfigEnvironment() - let config, avprCache, _ = Result.okValue (API.Common.GetSyncedConfigAndCache(?Token = get_gh_api_token())) - let firstIndexedPackage = config.PackageIndex.[0] - let firstPackageName = firstIndexedPackage.Metadata.Name - let firstPackageVersion = ValidationPackageMetadata.getSemanticVersionString firstIndexedPackage.Metadata + let _, avprCache, _ = Result.okValue (API.Common.GetSyncedConfigAndCache(?Token = get_gh_api_token())) test "SaveAndCachePackage returns OK" { - Expect.isOk (API.AVPR.SaveAndCachePackage(avprCache, firstPackageName, packageVersion = firstPackageVersion )) "SaveAndCachePackage did not return OK" + Expect.isOk (API.AVPR.SaveAndCachePackage(avprCache, "test", packageVersion = "3.0.0" )) "SaveAndCachePackage did not return OK" } test "package is cached after running SaveAndCachePackage" { avprCache - |> Expect.packageCacheContainsPackage firstPackageName firstPackageVersion + |> Expect.packageCacheContainsPackage "test" "3.0.0" } test "package exists after running SaveAndCachePackage" { - Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, $"{firstPackageName}@{firstPackageVersion}.fsx"))) $"{firstPackageName}@{firstPackageVersion}.fsx did not exist at {expected_package_cache_folder_path_release}" + Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, "test@3.0.0.fsx"))) $"test@3.0.0.fsx did not exist at {expected_package_cache_folder_path_release}" } ]) testSequenced (testList "InstallPackage" [ // here, wee need persistent config and caches across the tests instead of a fixture for each test case resetConfigEnvironment() - let config, avprCache, _ = Result.okValue (API.Common.GetSyncedConfigAndCache(?Token = get_gh_api_token())) - let firstIndexedPackage = config.PackageIndex.[0] - let firstPackageName = firstIndexedPackage.Metadata.Name - let firstPackageVersion = ValidationPackageMetadata.getSemanticVersionString firstIndexedPackage.Metadata + let _, avprCache, _ = Result.okValue (API.Common.GetSyncedConfigAndCache(?Token = get_gh_api_token())) test "InstallPackage returns OK" { - Expect.isOk (API.AVPR.InstallPackage(avprCache, firstPackageName, SemVer = firstPackageVersion)) "InstallPackage did not return OK" + Expect.isOk (API.AVPR.InstallPackage(avprCache, "test", SemVer = "3.0.0")) "InstallPackage did not return OK" } test "package is cached after running InstallPackage" { avprCache - |> Expect.packageCacheContainsPackage firstPackageName firstPackageVersion + |> Expect.packageCacheContainsPackage "test" "3.0.0" } test "package exists after running InstallPackage" { - Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, $"{firstPackageName}@{firstPackageVersion}.fsx"))) $"{firstPackageName}@{firstPackageVersion}.fsx did not exist at {expected_package_cache_folder_path_release}" + Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, "test@3.0.0.fsx"))) $"test@3.0.0.fsx did not exist at {expected_package_cache_folder_path_release}" } ]) testSequenced (testList "UnInstallPackage" [ // here, wee need persistent config and caches across the tests instead of a fixture for each test case resetConfigEnvironment() let config, avprCache, _ = Result.okValue (API.Common.GetSyncedConfigAndCache(?Token = get_gh_api_token())) - let firstIndexedPackage = config.PackageIndex.[0] - let firstPackageName = firstIndexedPackage.Metadata.Name - let firstPackageVersion = ValidationPackageMetadata.getSemanticVersionString firstIndexedPackage.Metadata test "InstallPackage returns OK" { - Expect.isOk (API.Preview.InstallPackage(config, avprCache, firstPackageName, SemVer = firstPackageVersion)) "InstallPackage did not return OK" + Expect.isOk (API.Preview.InstallPackage(config, avprCache, "test", SemVer = "3.0.0")) "InstallPackage did not return OK" } test "package is cached after running InstallPackage" { avprCache - |> Expect.packageCacheContainsPackage firstPackageName firstPackageVersion + |> Expect.packageCacheContainsPackage "test" "3.0.0" } test "package exists after running InstallPackage" { - Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, $"{firstPackageName}@{firstPackageVersion}.fsx"))) $"{firstPackageName}@{firstPackageVersion}.fsx did not exist at {expected_package_cache_folder_path_release}" + Expect.isTrue (File.Exists (Path.Combine(expected_package_cache_folder_path_release, "test@3.0.0.fsx"))) $"test@3.0.0.fsx did not exist at {expected_package_cache_folder_path_release}" } test "UninstallPackage with version flag returns OK" { - Expect.isOk (API.Preview.UninstallPackage(avprCache, firstPackageName, SemVer = firstPackageVersion)) "UninstallPackage did not return OK" + Expect.isOk (API.Preview.UninstallPackage(avprCache, "test", SemVer = "3.0.0")) "UninstallPackage did not return OK" } test "package version is not cached anymore after running UninstallPackage" { - Expect.isFalse (avprCache[firstPackageName].ContainsKey(firstPackageVersion)) "version was not removed from the cache" + Expect.isFalse (avprCache["test"].ContainsKey("3.0.0")) "version was not removed from the cache" } test "package does not exist anymore after running UninstallPackage" { - Expect.isFalse (File.Exists (Path.Combine(expected_package_cache_folder_path_preview, $"{firstPackageName}@{firstPackageVersion}.fsx"))) $"{firstPackageName}@{firstPackageVersion}.fsx did not exist at {expected_package_cache_folder_path_release}" + Expect.isFalse (File.Exists (Path.Combine(expected_package_cache_folder_path_preview, "test@3.0.0.fsx"))) $"test@3.0.0.fsx did not exist at {expected_package_cache_folder_path_release}" } ]) ])