Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New documentation and associated src changes #23

Merged
merged 12 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 89 additions & 64 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ open Fake.DotNet

let projectName = "Bristlecone"
let projectSummary = "Time-series modelling in F#"
let projectDescription = """

let projectDescription =
"""
An F# library for model-fitting model-selection (MFMS) of ecological
models to observational data. The library was developed for
individual-based plant modelling using tree ring time-series,
but can be used for any ecological models."""

let authors = "Andrew Martin"
let companyName = ""
let companyName = "University of Oxford; University of Cambridge"
let tags = "modelling time-series F# fsharp R data-science ecology model-fitting"
let license = "MIT"
let iconUrl = ""
Expand All @@ -55,92 +58,116 @@ let repositoryContentUrl = "https://raw.githubusercontent.com/AndrewIOM/bristlec
// Read release notes & version info from RELEASE_NOTES.md
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let binDir = __SOURCE_DIRECTORY__ @@ "bin"
let release = System.IO.File.ReadLines "RELEASE_NOTES.MD" |> Fake.Core.ReleaseNotes.parse

let release =
System.IO.File.ReadLines "RELEASE_NOTES.MD" |> Fake.Core.ReleaseNotes.parse

// Generate assembly info files with the right version & up-to-date information
Target.create "AssemblyInfo" (fun _ ->
let fileName = "src/Bristlecone/AssemblyInfo.fs"
AssemblyInfoFile.createFSharpWithConfig fileName
[ Fake.DotNet.AssemblyInfo.Title projectName
Fake.DotNet.AssemblyInfo.Company companyName
Fake.DotNet.AssemblyInfo.Product projectName
Fake.DotNet.AssemblyInfo.Description projectSummary
Fake.DotNet.AssemblyInfo.Version release.AssemblyVersion
Fake.DotNet.AssemblyInfo.FileVersion release.AssemblyVersion ]
(AssemblyInfoFileConfig(false))
)
let fileName = "src/Bristlecone/AssemblyInfo.fs"

AssemblyInfoFile.createFSharpWithConfig
fileName
[ Fake.DotNet.AssemblyInfo.Title projectName
Fake.DotNet.AssemblyInfo.Company companyName
Fake.DotNet.AssemblyInfo.Product projectName
Fake.DotNet.AssemblyInfo.Description projectSummary
Fake.DotNet.AssemblyInfo.Version release.AssemblyVersion
Fake.DotNet.AssemblyInfo.FileVersion release.AssemblyVersion ]
(AssemblyInfoFileConfig(false)))

// --------------------------------------------------------------------------------------
// Clean build results & restore NuGet packages

Target.create "Clean" (fun _ ->
Fake.IO.Shell.cleanDirs ["bin"; "output" ]
Fake.IO.Shell.cleanDirs ["tests/Bristlecone.Tests/bin"; "tests/Bristlecone.Tests/obj" ]
)
Fake.IO.Shell.cleanDirs [ "bin"; "output" ]
Fake.IO.Shell.cleanDirs [ "tests/Bristlecone.Tests/bin"; "tests/Bristlecone.Tests/obj" ])

Target.create "CleanDocs" (fun _ -> Fake.IO.Shell.cleanDirs [ ".fsdocs" ])

// --------------------------------------------------------------------------------------
// Check formatting with Fantomas

Target.create "CheckFormat" (fun _ ->
let result = DotNet.exec id "fantomas" "./src --check"
let resultDocs = DotNet.exec id "fantomas" "./docs --check"

Target.create "CleanDocs" (fun _ ->
Fake.IO.Shell.cleanDirs [".fsdocs"]
)
if result.ExitCode = 0 && resultDocs.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, run \"dotnet fantomas ./src\" to resolve this."
elif result.ExitCode = 99 then
failwith "Some files need formatting, run \"dotnet fantomas ./docs\" to resolve this."
else
Trace.logf "Errors while formatting: %A" result.Errors)

// --------------------------------------------------------------------------------------
// Build library & test project

Target.create "Build" (fun _ ->
Trace.log " --- Building the app --- "
Fake.DotNet.DotNet.build id ("bristlecone.sln")
)
Fake.DotNet.DotNet.build id ("bristlecone.sln"))

// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete

Target.create "RunTests" (fun _ ->
let rHome = Environment.environVarOrFail "R_HOME"
Trace.logf "R_HOME is set as %s" rHome
let result = Fake.DotNet.DotNet.exec (fun args ->
{ args with Verbosity = Some Fake.DotNet.DotNet.Verbosity.Normal}) "run" ("--project tests/Bristlecone.Tests")
if result.ExitCode <> 0 then failwith "Tests failed"
)

let result =
Fake.DotNet.DotNet.exec
(fun args ->
{ args with
Verbosity = Some Fake.DotNet.DotNet.Verbosity.Normal })
"run"
("--project tests/Bristlecone.Tests")

if result.ExitCode <> 0 then
failwith "Tests failed")

// --------------------------------------------------------------------------------------
// Build a NuGet package

Target.create "NuGet" (fun _ ->
// Format the description to fit on a single line (remove \r\n and double-spaces)
let projectDescription = projectDescription.Replace("\r", "").Replace("\n", "").Replace(" ", " ")

let projectDescription =
projectDescription.Replace("\r", "").Replace("\n", "").Replace(" ", " ")

// Format the release notes
let releaseNotes = release.Notes |> String.concat "\n"

let properties = [
("Version", release.NugetVersion)
("Authors", authors)
("PackageProjectUrl", packageProjectUrl)
("PackageTags", tags)
("RepositoryType", repositoryType)
("RepositoryUrl", repositoryUrl)
("PackageLicenseExpression", license)
("PackageRequireLicenseAcceptance", "false")
("PackageReleaseNotes", releaseNotes)
("Summary", projectSummary)
("PackageDescription", projectDescription)
("PackageIcon", "logo.png")
("PackageIconUrl", iconUrl)
("EnableSourceLink", "true")
("PublishRepositoryUrl", "true")
("EmbedUntrackedSources", "true")
("IncludeSymbols", "true")
("IncludeSymbols", "false")
("SymbolPackageFormat", "snupkg")
("Copyright", copyright)
]

DotNet.pack (fun p ->
{ p with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "bin"
MSBuildParams = { p.MSBuildParams with Properties = properties}
}
) ("bristlecone.sln"))
let properties =
[ ("Version", release.NugetVersion)
("Authors", authors)
("PackageProjectUrl", packageProjectUrl)
("PackageTags", tags)
("RepositoryType", repositoryType)
("RepositoryUrl", repositoryUrl)
("PackageLicenseExpression", license)
("PackageRequireLicenseAcceptance", "false")
("PackageReleaseNotes", releaseNotes)
("Summary", projectSummary)
("PackageDescription", projectDescription)
("PackageIcon", "logo.png")
("PackageIconUrl", iconUrl)
("EnableSourceLink", "true")
("PublishRepositoryUrl", "true")
("EmbedUntrackedSources", "true")
("IncludeSymbols", "true")
("IncludeSymbols", "false")
("SymbolPackageFormat", "snupkg")
("Copyright", copyright) ]

DotNet.pack
(fun p ->
{ p with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "bin"
MSBuildParams =
{ p.MSBuildParams with
Properties = properties } })
("bristlecone.sln"))

//--------------------------------------------------------------------------------------
//Generate the documentation
Expand All @@ -163,21 +190,19 @@ Target.create "DocsMeta" (fun _ ->
"<FsDocsWarnOnMissingDocs>true</FsDocsWarnOnMissingDocs>"
"<FsDocsTheme>default</FsDocsTheme>"
"</PropertyGroup>"
"</Project>"]
|> Fake.IO.File.write false "Directory.Build.props"
)
"</Project>" ]
|> Fake.IO.File.write false "Directory.Build.props")

Target.create "GenerateDocs" (fun _ ->
Fake.IO.Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" "build --clean --eval --strict" |> ignore
)
Fake.IO.Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" "build --clean --eval --strict" |> ignore)

// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override

Target.create "All" ignore

"Clean" ==> "AssemblyInfo" ==> "Build"
"Clean" ==> "CheckFormat" ==> "AssemblyInfo" ==> "Build"
"Build" ==> "CleanDocs" ==> "DocsMeta" ==> "GenerateDocs" ==> "All"
"Build" ==> "NuGet" ==> "All"
"Build" ==> "RunTests" ==> "All"
Expand Down
125 changes: 0 additions & 125 deletions components/allometric.fsx

This file was deleted.

Loading
Loading