diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 38aa462..6385975 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -245,7 +245,7 @@ jobs: update-preview-index: needs: staging-area-pre-publish-checks runs-on: ubuntu-latest - if: needs.staging-area-pre-publish-checks.outputs.trigger-update-preview-index == 'true' + if: needs.staging-area-pre-publish-checks.outputs.trigger-update-preview-index == 'true' && github.event_name == 'push' steps: - uses: actions/checkout@v4 - name: Set up .NET diff --git a/StagingArea/invenio/invenio@2.0.0.fsx b/StagingArea/invenio/invenio@2.0.0.fsx new file mode 100644 index 0000000..78aaf52 --- /dev/null +++ b/StagingArea/invenio/invenio@2.0.0.fsx @@ -0,0 +1,116 @@ +let []PACKAGE_METADATA = """(* +--- +Name: invenio +Summary: Validates if the ARC contains the necessary metadata to be publishable via Invenio. +Description: | + Validates if the ARC contains the necessary metadata to be publishable via Invenio. + The following metadata is required: + - Investigation has title and description + - All persons in Investigation Contacts must have a name, last name, affiliation and valid email +MajorVersion: 2 +MinorVersion: 0 +PatchVersion: 0 +Publish: true +Authors: + - FullName: Oliver Maus + Affiliation: DataPLANT + - FullName: Christopher Lux + Email: lux@csbiology.de + Affiliation: RPTU Kaiserslautern + AffiliationLink: http://rptu.de/startseite +Tags: + - Name: ARC + - Name: data publication +ReleaseNotes: | + - Rework the tokenisation and acess to the metadata in Accordance to ARKTokenization 6.0.0/ARCExpect 2.0.0 +--- +*)""" + +#r "nuget: ARCExpect, 2.0.0" + +open ControlledVocabulary +open Expecto +open ARCExpect +open ARCTokenization +open ARCTokenization.StructuralOntology +open System.IO + +// Input: +let arcDir = Directory.GetCurrentDirectory() + +// Values: +let absoluteDirectoryPaths = FileSystem.parseARCFileSystem arcDir + +let investigationMetadata = + absoluteDirectoryPaths + |> Investigation.parseMetadataSheetsFromTokens() arcDir + |> List.concat + + +// Validation Cases: +let cases = + testList INVMSO.``Investigation Metadata``.INVESTIGATION.key.Name [ + // Investigation has title + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` + } + // Investigation has description + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` + } + // Investigation has contacts with name, last name, affiliation and email + // Investigation Person First Name + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Last Name + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Affiliation + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Email + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` + } + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name) { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``) + |> Seq.iter (Validate.Param.ValueMatchesRegex StringValidationPattern.email) + } + ] + +// Execution: + +Setup.ValidationPackage( + metadata = Setup.Metadata(PACKAGE_METADATA), + CriticalValidationCases = [cases] +) +|> Execute.ValidationPipeline( + basePath = arcDir +) \ No newline at end of file diff --git a/StagingArea/pride/pride@1.0.0.fsx b/StagingArea/pride/pride@1.0.0.fsx index a7615f7..6b8b609 100644 --- a/StagingArea/pride/pride@1.0.0.fsx +++ b/StagingArea/pride/pride@1.0.0.fsx @@ -1,4 +1,4 @@ -(* +let []PACKAGE_METADATA = """(* --- Name: pride Summary: Validates if the ARC contains the necessary metadata to be publishable via PRIDE. @@ -19,6 +19,10 @@ Authors: Email: maus@nfdi4plants.org Affiliation: RPTU Kaiserslautern AffiliationLink: http://rptu.de/startseite + - FullName: Christopher Lux + Email: lux@csbiology.de + Affiliation: RPTU Kaiserslautern + AffiliationLink: http://rptu.de/startseite Tags: - Name: validation - Name: pride @@ -32,166 +36,65 @@ ReleaseNotes: | - Study has protocol, tissue & species in correct format - Assay has protocol, technology type, instrument model, and fixed and/or variable modification in correct format --- -*) +*)""" -#r "nuget: ARCExpect" -#r "nuget: Anybadge.NET" -#r "nuget: ARCValidationPackages" -#r "nuget: FSharpAux" +#r "nuget: ARCExpect, 2.0.0" +open ControlledVocabulary +open Expecto open ARCExpect open ARCTokenization open ARCTokenization.StructuralOntology -open ControlledVocabulary -open Expecto -open ARCValidationPackages -open ARCValidationPackages.API open System.IO +open System.Text open FSharpAux - // Input: - let arcDir = Directory.GetCurrentDirectory() -let outDirBadge = Path.Combine(arcDir, "Invenio_badge.svg") -let outDirResXml = Path.Combine(arcDir, "Invenio_results.xml") - // Values: - -let absoluteDirectoryPaths = FileSystem.parseAbsoluteDirectoryPaths arcDir -let absoluteFilePaths = FileSystem.parseAbsoluteFilePaths arcDir - -let invFileTokens = - Investigation.parseMetadataSheetsFromTokens() absoluteFilePaths - |> List.concat - |> ARCGraph.fillTokenList Terms.InvestigationMetadata.ontology - |> Seq.concat - |> Seq.concat - |> Seq.map snd - -Investigation.parseMetadataSheetsFromTokens() absoluteFilePaths |> List.concat |> Seq.iter (Param.getCvName >> printfn "%s") -Investigation.parseMetadataSheetsFromTokens() absoluteFilePaths |> List.concat |> Seq.iter (Param.getTerm >> printfn "%A") - -let invFileTokensNoMdSecKeys = - invFileTokens - |> Seq.filter (Param.getValue >> (<>) Terms.StructuralTerms.metadataSectionKey.Name) - -let contactsFns = - invFileTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``) - -let contactsLns = - invFileTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``) - -let contactsAffs = - invFileTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``) - -let contactsEmails = - invFileTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``) - -let commis = - invFileTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) Terms.StructuralTerms.userComment) - -let stdFileProcTokens = - absoluteFilePaths - |> Seq.choose ( - fun cvp -> - let cvpV = CvParam.getValueAsString cvp - if String.contains "isa.study.xlsx" cvpV then - ARCTokenization.Study.parseProcessGraphColumnsFromFile cvpV - |> Some - else None - ) - -let stdFileMdsTokens = - Study.parseMetadataSheetsFromTokens () absoluteFilePaths - |> List.concat - |> ARCGraph.fillTokenList Terms.StudyMetadata.ontology - |> Seq.concat - |> Seq.concat - |> Seq.map snd - -let stdFileMdsTokensNoMdSecKeys = - stdFileMdsTokens - |> Seq.filter (Param.getValue >> (<>) Terms.StructuralTerms.metadataSectionKey.Name) - -let stdProtocols = - stdFileMdsTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) STDMSO.``Study Metadata``.``STUDY PROTOCOLS``.key) - -let allStdGraphTokens = - stdFileProcTokens - |> Seq.collect Map.values - |> List.concat - |> List.concat - -let organismTokens = - stdFileProcTokens +let absoluteDirectoryPaths = FileSystem.parseARCFileSystem arcDir + +let investigationMetadata = + absoluteDirectoryPaths + |> Investigation.parseMetadataSheetsFromTokens() arcDir + |> List.concat + +let studyMetadata = + absoluteDirectoryPaths + |> Study.parseMetadataSheetsFromTokens() arcDir + +let assayMetadata = + absoluteDirectoryPaths + |> Assay.parseMetadataSheetsFromTokens() arcDir + +let studyFiles = + try + absoluteDirectoryPaths + |> Study.parseProcessGraphColumnsFromTokens arcDir + with + | _ -> seq{Map.empty} + +let organismTokens= + studyFiles |> Seq.collect Map.values |> List.concat |> List.tryFind (fun cvpList -> cvpList.Head |> Param.getValueAsTerm = (CvTerm.create("OBI:0100026","organism","OBI"))) |> Option.defaultValue [] -let tissueTokens = - stdFileProcTokens +let tissueTokens= + studyFiles |> Seq.collect Map.values |> List.concat |> List.tryFind (fun cvpList -> cvpList.Head |> Param.getValueAsTerm = (CvTerm.create("NCIT:12801","Tissue","NCIT"))) |> Option.defaultValue [] -let assFileProcTokens = - absoluteFilePaths - |> Seq.choose ( - fun cvp -> - let cvpV = CvParam.getValueAsString cvp - if String.contains "isa.assay.xlsx" cvpV then - ARCTokenization.Assay.parseProcessGraphColumnsFromFile cvpV - |> Some - else None - ) - -let assFileMdsTokens = - Assay.parseMetadataSheetsFromTokens () absoluteFilePaths - |> List.concat - |> ARCGraph.fillTokenList Terms.AssayMetadata.ontology - |> Seq.concat - |> Seq.concat - |> Seq.map snd let techTypeName = CvTerm.create("ASSMSO:00000011", "Assay Technology Type", "ASSMSO") let techTypeTAN = CvTerm.create("ASSMSO:00000013", "Assay Technology Type Term Accession Number", "ASSMSO") let techTypeTSR = CvTerm.create("ASSMSO:00000015", "Assay Technology Type Term Source REF", "ASSMSO") -let assFileMdsTokensNoMdSecKeys = - assFileMdsTokens - |> Seq.filter (Param.getValue >> (<>) Terms.StructuralTerms.metadataSectionKey.Name) - -let assTechTypeTAN = - stdFileMdsTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) techTypeTAN) - -let assTechTypeTSR = - stdFileMdsTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) techTypeTSR) - -let assTechTypeName = - stdFileMdsTokensNoMdSecKeys - |> Seq.filter (Param.getTerm >> (=) techTypeName) - -let allAssGraphTokens = - assFileProcTokens - |> Seq.collect Map.values - |> List.concat - |> List.concat - - // Helper functions (to deposit in ARCExpect later): - let characterLimit (lowerLimit : int option) (upperLimit : int option) = match lowerLimit, upperLimit with | None, None -> System.Text.RegularExpressions.Regex(@"^.{0,}$") @@ -199,9 +102,6 @@ let characterLimit (lowerLimit : int option) (upperLimit : int option) = | None, Some ul -> System.Text.RegularExpressions.Regex($"^.{{0,{ul}}}$") | Some ll, Some ul -> System.Text.RegularExpressions.Regex($"^.{{{ll},{ul}}}$") - -open System.Text - type ErrorMessage with static member ofIParamCollection error iParamCollection = @@ -253,37 +153,54 @@ type Validate.ParamCollection with // Validation Cases: - let cases = testList "cases" [ // naming is difficult here ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) { - invFileTokensNoMdSecKeys + investigationMetadata |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` } ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { - invFileTokensNoMdSecKeys + investigationMetadata |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` + }//recheck + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name`` } - ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name) { - contactsFns + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``) |> Seq.iter Validate.Param.ValueIsNotEmpty } - ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name) { - contactsLns - |> Seq.iter Validate.Param.ValueIsNotEmpty + //recheck + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name`` } - ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name) { - contactsAffs + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``) |> Seq.iter Validate.Param.ValueIsNotEmpty + } + //recheck + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation`` } - ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name) { - contactsEmails - |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` } ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name) { - contactsEmails + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``) |> Seq.iter (Validate.Param.ValueMatchesRegex StringValidationPattern.email) } // missing: how to get specific comment? (here: Keywords Comment) @@ -292,51 +209,77 @@ let cases = // |> Seq.iter (Validate.Param.ValueMatchesRegex StringValidationPattern.email) // needs special Regex //} ARCExpect.validationCase (TestID.Name STDMSO.``Study Metadata``.``STUDY PROTOCOLS``.key.Name) { - stdProtocols - |> Validate.ParamCollection.ContainsParamWithTerm STDMSO.``Study Metadata``.``STUDY PROTOCOLS``.key + studyMetadata + |> List.iter(fun study -> + study + |> Validate.ParamCollection.ContainsParamWithTerm STDMSO.``Study Metadata``.``STUDY PROTOCOLS``.key + ) } ARCExpect.validationCase (TestID.Name STDMSO.``Study Metadata``.``STUDY PROTOCOLS``.key.Name) { - stdProtocols - |> Seq.iter (Validate.Param.ValueMatchesRegex (characterLimit (Some 50) (Some 500))) + studyMetadata + |> List.iter(fun study -> + study + |> Seq.iter (Validate.Param.ValueMatchesRegex (characterLimit (Some 50) (Some 500))) + ) } ARCExpect.validationCase (TestID.Name "organism") { - allStdGraphTokens + studyMetadata + |> List.concat |> Validate.ParamCollection.ContainsParamWithTerm (CvTerm.create("OBI:0100026","organism","OBI")) + + } + ARCExpect.validationCase (TestID.Name "organism terms exist") { + studyMetadata + |> List.concat + |> Validate.ParamCollection.forAll (fun ip -> match ip.Value with CvValue _ -> true | _ -> false) } ARCExpect.validationCase (TestID.Name "organism terms") { organismTokens |> Validate.ParamCollection.forAll (fun ip -> match ip.Value with CvValue _ -> true | _ -> false) } ARCExpect.validationCase (TestID.Name "Tissue") { - allStdGraphTokens + studyMetadata + |> List.concat |> Validate.ParamCollection.ContainsParamWithTerm (CvTerm.create("NCIT:12801","Tissue","NCIT")) - } + }//recheck ARCExpect.validationCase (TestID.Name "Tissue terms") { tissueTokens |> Validate.ParamCollection.forAll (fun ip -> match ip.Value with CvValue _ -> true | _ -> false) } ARCExpect.validationCase (TestID.Name techTypeName.Name) { - assTechTypeName - |> Validate.ParamCollection.ContainsParamWithTerm techTypeName + assayMetadata + |> List.iter(fun assay -> + assay + |> Validate.ParamCollection.ContainsParamWithTerm techTypeName + ) } ARCExpect.validationCase (TestID.Name techTypeTAN.Name) { - assTechTypeTAN - |> Validate.ParamCollection.ContainsParamWithTerm techTypeTAN + assayMetadata + |> List.iter(fun assay -> + assay + |> Validate.ParamCollection.ContainsParamWithTerm techTypeTAN + ) } ARCExpect.validationCase (TestID.Name techTypeTSR.Name) { - assTechTypeTSR - |> Validate.ParamCollection.ContainsParamWithTerm techTypeTSR + assayMetadata + |> List.iter(fun assay -> + assay + |> Validate.ParamCollection.ContainsParamWithTerm techTypeTSR + ) } ARCExpect.validationCase (TestID.Name "Instrument Model") { - allStdGraphTokens + studyMetadata + |> List.concat |> Validate.ParamCollection.ContainsParamWithTerm (CvTerm.create("MS:1000031","instrument model","MS")) } ARCExpect.validationCase (TestID.Name "Modification") { ARCExpect.either (fun _ -> - allStdGraphTokens + studyMetadata + |> List.concat |> Validate.ParamCollection.ContainsParamWithTerm (CvTerm.create("MS:1003021","Fixed modification","MS")) ) (fun _ -> - allStdGraphTokens + studyMetadata + |> List.concat |> Validate.ParamCollection.ContainsParamWithTerm (CvTerm.create("MS:1003022","Variable modification","MS")) ) } @@ -344,5 +287,10 @@ let cases = // Execution: - -Execute.ValidationPipeline(jUnitPath = outDirResXml, badgePath = outDirBadge, labelText = "PRIDE") cases +Setup.ValidationPackage( + metadata = Setup.Metadata(PACKAGE_METADATA), + CriticalValidationCases = [cases] +) +|> Execute.ValidationPipeline( + basePath = arcDir +) \ No newline at end of file diff --git a/StagingAreaTests/PackageSanityChecks.fs b/StagingAreaTests/PackageSanityChecks.fs index 17e7004..633cad3 100644 --- a/StagingAreaTests/PackageSanityChecks.fs +++ b/StagingAreaTests/PackageSanityChecks.fs @@ -23,8 +23,8 @@ module Metadata = module ValidationScripts = [] - let ``All packages compile`` () = + let ``All packages run`` () = Assert.All( ReferenceObjects.all_staged_packages_paths, - Assert.ScriptCompiles + Assert.ScriptRuns [||] ) \ No newline at end of file diff --git a/StagingAreaTests/StagingAreaTests.fsproj b/StagingAreaTests/StagingAreaTests.fsproj index 4bc587c..2a1f015 100644 --- a/StagingAreaTests/StagingAreaTests.fsproj +++ b/StagingAreaTests/StagingAreaTests.fsproj @@ -30,7 +30,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/StagingAreaTests/Utils.fs b/StagingAreaTests/Utils.fs index 2bd950b..eda7511 100644 --- a/StagingAreaTests/Utils.fs +++ b/StagingAreaTests/Utils.fs @@ -5,19 +5,32 @@ open AVPRIndex.Domain open Xunit open System open System.IO -open FSharp.Compiler.CodeAnalysis +open Fake.DotNet type Assert with - static member ScriptCompiles (script: string) = - let t = Path.GetTempFileName() - let tempPath = Path.ChangeExtension(t, ".dll") - let checker = FSharpChecker.Create() - let errors, exitCode = - checker.Compile([| "fsc.exe"; "-o"; tempPath; "-a"; script |]) - |> Async.RunSynchronously - Assert.Empty(errors) - Assert.Equal(0, exitCode) + static member ScriptRuns (args: string []) (scriptPath: string)= + let args = Array.concat [|[|scriptPath|]; args|] + //let outPath = Path.GetDirectoryName scriptPath + let result = + DotNet.exec + (fun p -> + { + p with + RedirectOutput = true + PrintRedirectedOutput = true + } + ) + "fsi" + (args |> String.concat " ") + //let packageName = Path.GetFileNameWithoutExtension(scriptPath) + //let outputFolder = Path.Combine([|outPath; ".arc-validate-results"; packageName|]) + //Assert.True(Directory.Exists(outputFolder)) + //Assert.True(File.Exists(Path.Combine(outputFolder,"badge.svg"))) + //Assert.True(File.Exists(Path.Combine(outputFolder,"validation_report.xml"))) + //Assert.True(File.Exists(Path.Combine(outputFolder,"validation_summary.json"))) + Assert.Equal(result.ExitCode, 0) + Assert.Empty(result.Errors) static member ContainsFrontmatter (script: string) = let containsCommentFrontmatter = script.StartsWith(Frontmatter.frontMatterCommentStart, StringComparison.Ordinal) && script.Contains(Frontmatter.frontMatterCommentEnd)