Skip to content

Commit

Permalink
Merge pull request #27 from CSBiology/fable
Browse files Browse the repository at this point in the history
Fable readiness
  • Loading branch information
HLWeil committed May 11, 2023
2 parents 9fa9537 + f3f301e commit a0c11d0
Show file tree
Hide file tree
Showing 49 changed files with 1,556 additions and 2,780 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"fsdocs"
]
},
"fable": {
"version": "4.1.3",
"commands": [
"fable"
]
}
}
}
21 changes: 18 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
pull_request:
branches: [ main ]


jobs:
build-and-test-linux:

Expand All @@ -18,9 +17,17 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: Restore fable
run: dotnet tool restore
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
- name: install node modules
run: npm install
- name: make script executable
run: chmod u+x build.sh
- name: Build and test
- name: Build and test dotnet
working-directory: ./
run: ./build.sh runtests

Expand All @@ -34,6 +41,14 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: Build and test
- name: Restore fable
run: dotnet tool restore
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
- name: install node modules
run: npm install
- name: Build and test dotnet
working-directory: ./
run: ./build.cmd runtests
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,5 @@ MigrationBackup/
pkg/

tmp/
.fsdocs/
.fsdocs/
/tests/FsSpreadsheet.JsNativeTests/fable/**/*.js
7 changes: 7 additions & 0 deletions FsSpreadsheet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{276B
build.sh = build.sh
.config\dotnet-tools.json = .config\dotnet-tools.json
global.json = global.json
package.json = package.json
playground.fsx = playground.fsx
.github\workflows\publish-github-pages.yml = .github\workflows\publish-github-pages.yml
README.md = README.md
Expand All @@ -37,6 +38,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F77AD108
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FsSpreadsheet.Interactive.Tests", "tests\FsSpreadsheet.Interactive.Tests\FsSpreadsheet.Interactive.Tests.fsproj", "{7AC6357C-BDA0-40AE-955E-953C4BFF5BB0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FsSpreadsheet.JsNativeTests", "FsSpreadsheet.JsNativeTests", "{CA144336-9B18-429F-A11B-81EC3CB06CE5}"
ProjectSection(SolutionItems) = preProject
tests\FsSpreadsheet.JsNativeTests\Main.js = tests\FsSpreadsheet.JsNativeTests\Main.js
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -156,6 +162,7 @@ Global
{C7DF552E-DDE1-4D6D-B0A3-B9D273FC0E32} = {F77AD108-C6B4-46BB-B7BC-13573F45F876}
{5F8EBA76-7B6B-4BAF-9426-F17B14FA5C4C} = {1CF1274C-DE28-4446-9B4E-5884E797B87B}
{7AC6357C-BDA0-40AE-955E-953C4BFF5BB0} = {F77AD108-C6B4-46BB-B7BC-13573F45F876}
{CA144336-9B18-429F-A11B-81EC3CB06CE5} = {F77AD108-C6B4-46BB-B7BC-13573F45F876}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0EDE6697-0F13-4DB1-AC56-12C15A72D395}
Expand Down
21 changes: 21 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
### 2.0.1+bd195cc (Released 2023-5-11)
* Additions:
* [[#e8e7a88](https://github.com/CSBiology/FsSpreadsheet/commit/e8e7a88064dd85ec4d2ed6037237626fd46b7ec6)] update CI to include Fable
* Deletions:
* [[#bd195cc](https://github.com/CSBiology/FsSpreadsheet/commit/bd195cc0920f9e723c4aa163b6935a229c7d730d)] remove deprecated functions and fill incomplete matches

### 2.0.0+2b67a3f (Released 2023-5-11)
* Additions:
* [[#2b67a3f](https://github.com/CSBiology/FsSpreadsheet/commit/2b67a3f18a1c0cbcce92747e64e39ef4959abba7)] start adding DSL test
* [[#eab82ec](https://github.com/CSBiology/FsSpreadsheet/commit/eab82ec6fd136cba6e60d20a9cbb8346e296faba)] Merge pull request #24 from CSBiology/FsColumn
* [[#9fa9537](https://github.com/CSBiology/FsSpreadsheet/commit/9fa9537ba2e9b049679ea491bc52a1e6c8707bb3)] Update ReleaseNotes
* [[#ff35f3d](https://github.com/CSBiology/FsSpreadsheet/commit/ff35f3d060f311e6bb54ad70f80a890a49f60a49)] Add Fable logic
* [[#d89c88b](https://github.com/CSBiology/FsSpreadsheet/commit/d89c88b126125dafc552328ec04f1c1e77036f0f)] Init fable compatibility :sparkles::tada:
* [[#5f60c82](https://github.com/CSBiology/FsSpreadsheet/commit/5f60c8264b9655ac8c7ebb6c766458cb6506d9ec)] Add dsl logic back to fable version :sparkles:
* [[#9b51c85](https://github.com/CSBiology/FsSpreadsheet/commit/9b51c85de78c85f2181d94e8b5be8edaa930198d)] Init fable test suit :sparkles:
* [[#58dc08c](https://github.com/CSBiology/FsSpreadsheet/commit/58dc08c0cbbd412305e15bb1ea412e57ffae6e45)] Make tests pass :heavy_check_mark:
* Deletions:
* [[#d158414](https://github.com/CSBiology/FsSpreadsheet/commit/d15841424793c84cd94311da7bfb59afe65c9b82)] remove argument exception mapping
* Bugfixes:
* [[#1c72afb](https://github.com/CSBiology/FsSpreadsheet/commit/1c72afbd410bf6093ad3cc664305228fd057908e)] Fix cell getValueAs<_> for fable :sparkles:

### 1.3.0-preview+549125f (Released 2023-4-24)
* Additions:
* [[#549125f](https://github.com/CSBiology/FsSpreadsheet/commit/549125f54d5aa1b7b41f8e52962bf506bc5eb9f4)] add Columns field to FsTable
Expand Down
26 changes: 13 additions & 13 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean;
!! "src/**/*.*proj"
-- "src/bin/*"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines )
] @ p.MSBuildParams.Properties)
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
MSBuildParams = msBuildParams
}
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"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"
Expand Down
6 changes: 3 additions & 3 deletions build/ProjectInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ let project = "FsSpreadsheet"

let testProjects =
[
"tests/FsSpreadsheet.Tests/FsSpreadsheet.Tests.fsproj"
"tests/FsSpreadsheet.ExcelIO.Tests/FsSpreadsheet.ExcelIO.Tests.fsproj"
"tests/FsSpreadsheet.Interactive.Tests/FsSpreadsheet.Interactive.Tests.fsproj"
"tests/FsSpreadsheet.Tests"
"tests/FsSpreadsheet.ExcelIO.Tests"
"tests/FsSpreadsheet.Interactive.Tests"
]

let solutionFile = $"{project}.sln"
Expand Down
199 changes: 167 additions & 32 deletions build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,173 @@ open Fake.DotNet
open ProjectInfo
open BasicTasks

let runTests = BuildTask.create "RunTests" [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
)
[<Literal>]
let FableTestPath_input = "tests/FsSpreadsheet.Tests"
[<Literal>]
let FableTestPath_output = "tests/FsSpreadsheet.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] {
()
}

// to do: use this once we have actual tests
let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build] {
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
testProjects
|> 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"
}
) testProject
)
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]", dotnet $"fable watch {FableTestPath_input} -o {FableTestPath_output} -s --run npm run test:live" "."
"[Mocha]", 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
}
Loading

0 comments on commit a0c11d0

Please sign in to comment.