Skip to content

Commit

Permalink
Merge pull request #24 from nfdi4plants/feature-updateTokenization-#20
Browse files Browse the repository at this point in the history
Library rework
  • Loading branch information
kMutagene authored Jul 27, 2023
2 parents 6ccf979 + c6192db commit 3a0f1a7
Show file tree
Hide file tree
Showing 62 changed files with 3,088 additions and 2,602 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
dotnet-version: '6.0.x'
- name: Build and test
run: dotnet run --project ./build/Build.fsproj runTestsDotNet
run: dotnet run --project ./build/Build.fsproj runTests

build-and-test-windows:

Expand All @@ -31,4 +31,4 @@ jobs:
with:
dotnet-version: '6.0.x'
- name: Build and test
run: dotnet run --project ./build/Build.fsproj runTestsDotNet
run: dotnet run --project ./build/Build.fsproj runTests
74 changes: 38 additions & 36 deletions ArcGraphModel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel", "src\ArcGraphModel\ArcGraphModel.fsproj", "{32B01B13-37E2-4C86-9612-4BD8F33313D3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2EB71559-9BE4-4E02-9763-9092876D1E4A}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel.Tests", "tests\ArcGraphModel.Tests\ArcGraphModel.Tests.fsproj", "{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{CE1B84FD-33DE-48E4-A97A-A4BDC34E08F0}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Expand All @@ -26,53 +22,59 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{CE1B84FD-33D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{67DA0DCC-75F4-4F30-91C3-309A48B13D49}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGraphModel.JsNativeTests", "ArcGraphModel.JsNativeTests", "{5C9428BF-8CBE-41C1-AB54-64493155A6B6}"
ProjectSection(SolutionItems) = preProject
tests\ArcGraphModel.JsNativeTests\Main.js = tests\ArcGraphModel.JsNativeTests\Main.js
EndProjectSection
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary", "src\ControlledVocabulary\ControlledVocabulary.fsproj", "{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel", "src\ArcGraphModel\ArcGraphModel.fsproj", "{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel.Tests", "tests\ArcGraphModel.Tests\ArcGraphModel.Tests.fsproj", "{5A2C8580-8D5E-4A90-A21F-2C45C672A259}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Build", "build\Build.fsproj", "{CAC69396-1A09-4D95-B552-78712A4DA166}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary.Tests", "tests\ControlledVocabulary.Tests\ControlledVocabulary.Tests.fsproj", "{2CBEE59D-07E4-460E-8B97-9267965D3F46}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel.IO", "src\ArcGraphModel.IO\ArcGraphModel.IO.fsproj", "{30A760EF-FCB8-4454-811F-18983A9C076B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
build.sh = build.sh
global.json = global.json
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ArcGraphModel.IO.Tests", "tests\ArcGraphModel.IO.Tests\ArcGraphModel.IO.Tests.fsproj", "{921A1AF1-4FB4-43FC-9B5E-B53D291EE610}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Build", "build\Build.fsproj", "{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32B01B13-37E2-4C86-9612-4BD8F33313D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32B01B13-37E2-4C86-9612-4BD8F33313D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32B01B13-37E2-4C86-9612-4BD8F33313D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32B01B13-37E2-4C86-9612-4BD8F33313D3}.Release|Any CPU.Build.0 = Release|Any CPU
{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95}.Release|Any CPU.Build.0 = Release|Any CPU
{CAC69396-1A09-4D95-B552-78712A4DA166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAC69396-1A09-4D95-B552-78712A4DA166}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAC69396-1A09-4D95-B552-78712A4DA166}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAC69396-1A09-4D95-B552-78712A4DA166}.Release|Any CPU.Build.0 = Release|Any CPU
{30A760EF-FCB8-4454-811F-18983A9C076B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30A760EF-FCB8-4454-811F-18983A9C076B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30A760EF-FCB8-4454-811F-18983A9C076B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30A760EF-FCB8-4454-811F-18983A9C076B}.Release|Any CPU.Build.0 = Release|Any CPU
{921A1AF1-4FB4-43FC-9B5E-B53D291EE610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{921A1AF1-4FB4-43FC-9B5E-B53D291EE610}.Debug|Any CPU.Build.0 = Debug|Any CPU
{921A1AF1-4FB4-43FC-9B5E-B53D291EE610}.Release|Any CPU.ActiveCfg = Release|Any CPU
{921A1AF1-4FB4-43FC-9B5E-B53D291EE610}.Release|Any CPU.Build.0 = Release|Any CPU
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.Build.0 = Release|Any CPU
{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070}.Release|Any CPU.Build.0 = Release|Any CPU
{5A2C8580-8D5E-4A90-A21F-2C45C672A259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A2C8580-8D5E-4A90-A21F-2C45C672A259}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A2C8580-8D5E-4A90-A21F-2C45C672A259}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A2C8580-8D5E-4A90-A21F-2C45C672A259}.Release|Any CPU.Build.0 = Release|Any CPU
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.Build.0 = Release|Any CPU
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{32B01B13-37E2-4C86-9612-4BD8F33313D3} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49}
{81CE2F06-74BE-45F9-B2EB-2BFADD5B9C95} = {2EB71559-9BE4-4E02-9763-9092876D1E4A}
{5C9428BF-8CBE-41C1-AB54-64493155A6B6} = {2EB71559-9BE4-4E02-9763-9092876D1E4A}
{30A760EF-FCB8-4454-811F-18983A9C076B} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49}
{921A1AF1-4FB4-43FC-9B5E-B53D291EE610} = {2EB71559-9BE4-4E02-9763-9092876D1E4A}
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49}
{E80010AC-0AEE-4D7C-A85C-3A20C1FB7070} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49}
{5A2C8580-8D5E-4A90-A21F-2C45C672A259} = {2EB71559-9BE4-4E02-9763-9092876D1E4A}
{2CBEE59D-07E4-460E-8B97-9267965D3F46} = {2EB71559-9BE4-4E02-9763-9092876D1E4A}
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB} = {3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {933E3470-7D09-4F22-A056-2407458B9600}
Expand Down
38 changes: 0 additions & 38 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ let pack = BuildTask.create "Pack" [clean; build; runTests] {
OutputPath = Some pkgDir
}
))
// This is used to create ISADotNet.Fable with the Fable subfolder as explained here:
// https://fable.io/docs/your-fable-project/author-a-fable-library.html
"src/ArcGraphModel/ArcGraphModel.fsproj"
|> Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"PackageId", "ArcGraphModel.Fable"
"Version",stableVersionTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.concat "\r\n")
] @ p.MSBuildParams.Properties)
}
let test = p
{
p with
MSBuildParams = msBuildParams
OutputPath = Some pkgDir
}
)
else failwith "aborted"
}

Expand All @@ -78,25 +59,6 @@ let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean;
MSBuildParams = msBuildParams
}
))
// This is used to create ISADotNet.Fable with the Fable subfolder as explained here:
// https://fable.io/docs/your-fable-project/author-a-fable-library.html
"src/ArcGraphModel/ArcGraphModel.fsproj"
|> Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"PackageId", "ArcGraphModel.Fable"
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines)
] @ p.MSBuildParams.Properties)
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
MSBuildParams = msBuildParams
}
)
else
failwith "aborted"
}
2 changes: 1 addition & 1 deletion build/ProjectInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ let project = "ArcGraphModel"

let testProjects =
[
"tests/ControlledVocabulary.Tests"
"tests/ArcGraphModel.Tests"
"tests/ArcGraphModel.IO.Tests"
]

let solutionFile = $"{project}.sln"
Expand Down
189 changes: 4 additions & 185 deletions build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,196 +6,15 @@ open Fake.DotNet
open ProjectInfo
open BasicTasks

[<Literal>]
let FableTestPath_input = "tests/ArcGraphModel.Tests"
[<Literal>]
let FableTestPath_output = "tests/ArcGraphModel.JsNativeTests/fable"

[<AutoOpen>]
module private Helper =

open Fake
open Fake.Core

let createProcess exe arg dir =
CreateProcess.fromRawCommandLine exe arg
|> CreateProcess.withWorkingDirectory dir
|> CreateProcess.ensureExitCode

module Proc =

module Parallel =

open System

let locker = obj()

let colors = [|
ConsoleColor.DarkYellow
ConsoleColor.DarkCyan
ConsoleColor.Magenta
ConsoleColor.Blue
ConsoleColor.Cyan
ConsoleColor.DarkMagenta
ConsoleColor.DarkBlue
ConsoleColor.Yellow
|]

let print color (colored: string) (line: string) =
lock locker
(fun () ->
let currentColor = Console.ForegroundColor
Console.ForegroundColor <- color
Console.Write colored
Console.ForegroundColor <- currentColor
Console.WriteLine line)

let onStdout index name (line: string) =
let color = colors.[index % colors.Length]
if isNull line then
print color $"{name}: --- END ---" ""
else if String.isNotNullOrEmpty line then
print color $"{name}: " line

let onStderr name (line: string) =
let color = ConsoleColor.Red
if isNull line |> not then
print color $"{name}: " line

let redirect (index, (name, createProcess)) =
createProcess
|> CreateProcess.redirectOutputIfNotRedirected
|> CreateProcess.withOutputEvents (onStdout index name) (onStderr name)

let printStarting indexed =
for (index, (name, c: CreateProcess<_>)) in indexed do
let color = colors.[index % colors.Length]
let wd =
c.WorkingDirectory
|> Option.defaultValue ""
let exe = c.Command.Executable
let args = c.Command.Arguments.ToStartInfo
print color $"{name}: {wd}> {exe} {args}" ""

let run cs =
cs
|> Seq.toArray
|> Array.indexed
|> fun x -> printStarting x; x
|> Array.map redirect
|> Array.Parallel.map Proc.run

let dotnet = createProcess "dotnet"

let npm =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith

createProcess npmPath

let run proc arg dir =
proc arg dir
|> Proc.run
|> ignore

let runParallel processes =
processes
|> Proc.Parallel.run
|> ignore

let cleanFable = BuildTask.create "cleanFable" [clean; build] {
System.IO.Directory.CreateDirectory FableTestPath_output |> ignore
run dotnet "fable clean --yes" FableTestPath_output
}

module RunTests =

/// runs `npm test` in root.
/// npm test consists of `test` and `pretest`
/// check package.json in root for behavior
let runTestsJs = BuildTask.create "runTestsJS" [clean; cleanFable; build] {
run npm "test" ""
}

let runTestsDotnet = BuildTask.create "runTestsDotnet" [clean; build] {
testProjects
|> Seq.iter (fun testProject ->
Fake.DotNet.DotNet.test(fun testParams ->
{
testParams with
Logger = Some "console;verbosity=detailed"
Configuration = DotNet.BuildConfiguration.fromString configuration
NoBuild = true
}
) testProject
)
}

let runTests = BuildTask.create "RunTests" [clean; build; RunTests.runTestsJs; RunTests.runTestsDotnet] {
()
}

module WatchTests =

let private watchProjTests (projPath:string) =
let pName =
let n = System.IO.Path.GetFileNameWithoutExtension(projPath)
$"[{n}]"
pName, dotnet "watch run" projPath

let private dotnetTestsProcesses =
[
for testProj in testProjects do
yield watchProjTests testProj
]

let private fableTestsProcesses =
[
"[Fable Core]", dotnet $"fable watch {FableTestPath_input} -o {FableTestPath_output} --run npm run test:live" "."
"[Mocha JsNative]", npm $"run testnative:live" "."
]

let allTest = dotnetTestsProcesses@fableTestsProcesses

let watchTestsDotnet = BuildTask.create "watchTestsDotnet" [clean; build] {
dotnetTestsProcesses
|> runParallel
}

let watchJS = BuildTask.create "watchTestsJS" [clean; build] {
fableTestsProcesses
|> runParallel
}

let watchTests = BuildTask.create "watchTests" [clean; build] {
WatchTests.allTest
|> runParallel
}

// to do: use this once we have actual tests ~ Kevin Schneider
// Not sure how this interacts with the changes for fable compatibility, i will..
// ..leave it in for now ~ Kevin Frey
let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build] {
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
let runTests = BuildTask.create "RunTests" [clean; build] {
testProjects
|> Seq.iter(fun testProject ->
|> Seq.iter (fun testProject ->
Fake.DotNet.DotNet.test(fun testParams ->
{
testParams with
MSBuildParams = {
standardParams with
Properties = [
"AltCover","true"
"AltCoverCobertura","../../codeCov.xml"
"AltCoverForce","true"
]
};
Logger = Some "console;verbosity=detailed"
Configuration = DotNet.BuildConfiguration.fromString configuration
NoBuild = true
}
) testProject
)
Expand Down
Loading

0 comments on commit 3a0f1a7

Please sign in to comment.