Skip to content

Commit

Permalink
setup project
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed May 9, 2024
1 parent 10c900c commit 96dfb22
Show file tree
Hide file tree
Showing 26 changed files with 714 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"fsdocs-tool": {
"version": "20.0.0",
"commands": [
"fsdocs"
]
}
}
}
6 changes: 6 additions & 0 deletions .fsdocs/cache

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and test

on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'tests/**'
- 'build/**'
- '.github/**'
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'tests/**'
- 'build/**'
- '.github/**'


jobs:

build-and-test-linux:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: make script executable
run: chmod u+x build.sh
- name: Build and test
working-directory: ./
run: ./build.sh runtests

build-and-test-windows:

runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Build and test
working-directory: ./
run: ./build.cmd runtests

build-and-test-macos:

runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: make script executable
run: chmod u+x build.sh
- name: Build and test
working-directory: ./
run: ./build.sh runtests
32 changes: 32 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: deploy-gh-pages

on:
push:
branches: [ developer ]
paths:
- 'docs/**'

jobs:
build-and-deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Restore tools
run: dotnet tool restore
- name: make script executable
run: chmod u+x build.sh
- name: Build example docs
run: ./build.sh buildDocs
- name: deploy
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: ./output # The folder the action should deploy.
CLEAN: true # Automatically remove deleted files from the deploy branch
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,6 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/tmp
/output
/pkg
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### 0.0.0 (Released 2024-5-9)
* Additions:
* Initial set up for RELEASE_Notes.md

54 changes: 54 additions & 0 deletions TensorMath.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5317FD43-7D2F-4F4F-8444-B6AA1285C4BD}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TensorMath", "src\TensorMath\TensorMath.fsproj", "{03276E48-6B47-463F-A5BC-59580A623ADB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BAA394CB-3D6F-4CE9-BAE8-56603DBE7793}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TensorMath.Tests", "tests\TensorMath.Tests\TensorMath.Tests.fsproj", "{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7007FA68-0E95-42A0-B25C-A9BBA6071B34}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "build\build.fsproj", "{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{CD408BBB-CFDB-4889-AA66-6F0935B7AD18}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
.github\workflows\deploy-gh-pages.yml = .github\workflows\deploy-gh-pages.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{03276E48-6B47-463F-A5BC-59580A623ADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03276E48-6B47-463F-A5BC-59580A623ADB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03276E48-6B47-463F-A5BC-59580A623ADB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03276E48-6B47-463F-A5BC-59580A623ADB}.Release|Any CPU.Build.0 = Release|Any CPU
{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460}.Release|Any CPU.Build.0 = Release|Any CPU
{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{03276E48-6B47-463F-A5BC-59580A623ADB} = {5317FD43-7D2F-4F4F-8444-B6AA1285C4BD}
{6D6C1F8A-1AFE-4BEE-A073-24515FCC6460} = {BAA394CB-3D6F-4CE9-BAE8-56603DBE7793}
{D305E2AA-681F-47ED-87C8-7A9F6EA2F1A6} = {7007FA68-0E95-42A0-B25C-A9BBA6071B34}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A89F710-DE41-4B47-B450-17CCB1B3A0DC}
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
cls

dotnet run --project ./build/build.fsproj %*
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

dotnet run --project ./build/build.fsproj "$@"
37 changes: 37 additions & 0 deletions build/BasicTasks.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module BasicTasks

open BlackFox.Fake
open Fake.IO
open Fake.DotNet
open Fake.IO.Globbing.Operators

open ProjectInfo

let clean = BuildTask.create "Clean" [] {
!! "src/**/bin"
++ "src/**/obj"
++ "tests/**/bin"
++ "tests/**/obj"
++ "pkg"
|> Shell.cleanDirs
}


let setPrereleaseTag = BuildTask.create "SetPrereleaseTag" [] {
printfn "Please enter pre-release package suffix"
let suffix = System.Console.ReadLine()
prereleaseSuffix <- suffix
prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix)
isPrerelease <- true
}

/// builds the solution file (dotnet build solution.sln)
let buildSolution =
BuildTask.create "BuildSolution" [ clean ] {
solutionFile
|> DotNet.build (fun p ->
{ p with MSBuildParams = { p.MSBuildParams with DisableInternalBinLog = true }}
|> DotNet.Options.withCustomParams (Some "-tl")
)
}

46 changes: 46 additions & 0 deletions build/Build.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
open BlackFox.Fake
open System.IO
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Tools

open Helpers

initializeContext()

open BasicTasks
open TestTasks
open PackageTasks
open DocumentationTasks
open ReleaseTasks

/// Full release of nuget package, git tag, and documentation for the stable version.
let _release =
BuildTask.createEmpty
"Release"
[clean; buildSolution; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs]

/// Full release of nuget package, git tag, and documentation for the prerelease version.
let _preRelease =
BuildTask.createEmpty
"PreRelease"
[setPrereleaseTag; clean; buildSolution; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs]

/// Full release of nuget package for the prerelease version.
let _releaseNoDocs =
BuildTask.createEmpty
"ReleaseNoDocs"
[clean; buildSolution; runTests; pack; createTag; publishNuget;]

/// Full release of nuget package for the prerelease version.
let _preReleaseNoDocs =
BuildTask.createEmpty
"PreReleaseNoDocs"
[setPrereleaseTag; clean; buildSolution; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]

[<EntryPoint>]
let main args =
runOrDefault buildSolution args
36 changes: 36 additions & 0 deletions build/DocumentationTasks.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module DocumentationTasks

open Helpers
open ProjectInfo
open BasicTasks

open BlackFox.Fake


let buildDocs = BuildTask.create "BuildDocs" [buildSolution] {
printfn "building docs with stable version %s" stableVersionTag
runDotNet
(sprintf "fsdocs build --clean --properties Configuration=%s --parameters fsdocs-package-version %s" configuration stableVersionTag)
"./"
}

let buildDocsPrerelease = BuildTask.create "BuildDocsPrerelease" [setPrereleaseTag; buildSolution] {
printfn "building docs with prerelease version %s" prereleaseTag
runDotNet
(sprintf "fsdocs build --clean --properties Configuration=%s --parameters fsdocs-package-version %s" configuration prereleaseTag)
"./"
}

let watchDocs = BuildTask.create "WatchDocs" [buildSolution] {
printfn "watching docs with stable version %s" stableVersionTag
runDotNet
(sprintf "fsdocs watch --clean --properties Configuration=%s --parameters fsdocs-package-version %s" configuration stableVersionTag)
"./"
}

let watchDocsPrerelease = BuildTask.create "WatchDocsPrerelease" [setPrereleaseTag; buildSolution] {
printfn "watching docs with prerelease version %s" prereleaseTag
runDotNet
(sprintf "fsdocs watch --clean --properties Configuration=%s --parameters fsdocs-package-version %s" configuration prereleaseTag)
"./"
}
28 changes: 28 additions & 0 deletions build/Helpers.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Helpers

open BlackFox.Fake
open Fake.Core
open Fake.DotNet

let initializeContext () =
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)

/// Executes a dotnet command in the given working directory
let runDotNet cmd workingDir =
let result =
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir

let runOrDefault defaultTarget args =
Trace.trace (sprintf "%A" args)
try
match args with
| [| target |] -> Target.runOrDefault target
| arr when args.Length > 1 ->
Target.run 0 (Array.head arr) ( Array.tail arr |> List.ofArray )
| _ -> BuildTask.runOrDefault defaultTarget
0
with e ->
printfn "%A" e
1
18 changes: 18 additions & 0 deletions build/MessagePrompts.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module MessagePrompts

let prompt (msg:string) =
System.Console.Write(msg)
System.Console.ReadLine().Trim()
|> function | "" -> None | s -> Some s
|> Option.map (fun s -> s.Replace ("\"","\\\""))

let rec promptYesNo msg =
match prompt (sprintf "%s [Yn]: " msg) with
| Some "Y" | Some "y" -> true
| Some "N" | Some "n" -> false
| _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg

let releaseMsg = """This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file.
Do you want to continue?"""

let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?"""
Loading

0 comments on commit 96dfb22

Please sign in to comment.