Skip to content

Commit

Permalink
Merge pull request #7 from TypedUseCase/feature/udpate-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
MortalFlesh authored Aug 12, 2021
2 parents ee98907 + 063df70 commit 0639247
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 149 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"commands": [
"paket"
]
},
"dotnet-fsharplint": {
"version": "0.19.2",
"commands": [
"dotnet-fsharplint"
]
}
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- There is always Unreleased section on the top. Subsections (Add, Changed, Fix, Removed) should be Add as needed. -->
## Unreleased
- Update dependencies

## 4.0.0 - 2021-06-08
- Update to net5.0 and use F# 5.0
Expand Down
159 changes: 57 additions & 102 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.Tools.Git

type ToolDir =
/// Global tool dir must be in PATH - ${PATH}:/root/.dotnet/tools
| Global
/// Just a dir name, the location will be used as: ./{LocalDirName}
| Local of string

// ========================================================================================================
// === F# / Public Library fake build ============================================================= 1.1.0 =
// === F# / Public Library fake build ============================================================= 2.0.0 =
// --------------------------------------------------------------------------------------------------------
// Options:
// - no-clean - disables clean of dirs in the first step (required on CI)
Expand All @@ -36,12 +30,10 @@ type ToolDir =
let project = "Tuc Parser"
let summary = "A parser for TUC files."

let release = ReleaseNotes.parse (System.IO.File.ReadAllLines "CHANGELOG.md" |> Seq.filter ((<>) "## Unreleased"))
let changeLog = "CHANGELOG.md"
let gitCommit = Information.getCurrentSHA1(".")
let gitBranch = Information.getBranchName(".")

let toolsDir = Local "tools"

// --------------------------------------------------------------------------------------------------------
// 2. Utilities, DotnetCore functions, etc.
// --------------------------------------------------------------------------------------------------------
Expand All @@ -57,63 +49,45 @@ module private Utils =
then Trace.tracefn "Skipped ..."
else action p

module private DotnetCore =
let run cmd workingDir =
let options =
DotNet.Options.withWorkingDirectory workingDir
>> DotNet.Options.withRedirectOutput true
let createProcess exe arg dir =
CreateProcess.fromRawCommandLine exe arg
|> CreateProcess.withWorkingDirectory dir
|> CreateProcess.ensureExitCode

DotNet.exec options cmd ""

let runOrFail cmd workingDir =
run cmd workingDir
|> tee (fun result ->
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
)
let run proc arg dir =
proc arg dir
|> Proc.run
|> ignore

let runInRoot cmd = run cmd "."
let runInRootOrFail cmd = runOrFail cmd "."

let installOrUpdateTool toolDir tool =
let toolCommand action =
match toolDir with
| Global -> sprintf "tool %s --global %s" action tool
| Local dir -> sprintf "tool %s --tool-path ./%s %s" action dir tool

match runInRoot (toolCommand "install") with
| { ExitCode = code } when code <> 0 ->
match runInRoot (toolCommand "update") with
| { ExitCode = code } when code <> 0 -> Trace.tracefn "Warning: Install and update of %A has failed." tool
| _ -> ()
| _ -> ()

let execute command args (dir: string) =
let cmd =
sprintf "%s/%s"
(dir.TrimEnd('/'))
command

let processInfo = System.Diagnostics.ProcessStartInfo(cmd)
processInfo.RedirectStandardOutput <- true
processInfo.RedirectStandardError <- true
processInfo.UseShellExecute <- false
processInfo.CreateNoWindow <- true
processInfo.Arguments <- args |> String.concat " "

use proc =
new System.Diagnostics.Process(
StartInfo = processInfo
)
if proc.Start() |> not then failwith "Process was not started."
proc.WaitForExit()

if proc.ExitCode <> 0 then failwithf "Command '%s' failed in %s." command dir
(proc.StandardOutput.ReadToEnd(), proc.StandardError.ReadToEnd())

let stringToOption = function
| null | "" -> None
| string -> Some string
let orFail = function
| Error e -> raise e
| Ok ok -> ok

let stringToOption = function
| null | "" -> None
| string -> Some string

[<RequireQualifiedAccess>]
module Dotnet =
let dotnet = createProcess "dotnet"

let run command dir = try run dotnet command dir |> Ok with e -> Error e
let runInRoot command = run command "."
let runOrFail command dir = run command dir |> orFail

[<RequireQualifiedAccess>]
module ProjectSources =
let library =
!! "./*.fsproj"
++ "src/*.fsproj"
++ "src/**/*.fsproj"

let tests =
!! "tests/*.fsproj"

let all =
library
++ "tests/*.fsproj"

// --------------------------------------------------------------------------------------------------------
// 3. Targets for FAKE
Expand All @@ -130,6 +104,7 @@ Target.create "Clean" <| skipOn "no-clean" (fun _ ->
Target.create "AssemblyInfo" (fun _ ->
let getAssemblyInfoAttributes projectName =
let now = DateTime.Now
let release = ReleaseNotes.parse (System.IO.File.ReadAllLines changeLog |> Seq.filter ((<>) "## Unreleased"))

let gitValue initialValue =
initialValue
Expand All @@ -149,65 +124,45 @@ Target.create "AssemblyInfo" (fun _ ->
]

let getProjectDetails (projectPath: string) =
let projectName = IO.Path.GetFileNameWithoutExtension(projectPath)
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
(
projectPath,
projectName,
IO.Path.GetDirectoryName(projectPath),
System.IO.Path.GetDirectoryName(projectPath),
(getAssemblyInfoAttributes projectName)
)

!! "**/*.fsproj"
-- "example/**/*.*proj"
ProjectSources.all
|> Seq.map getProjectDetails
|> Seq.iter (fun (_, _, folderName, attributes) ->
AssemblyInfoFile.createFSharp (folderName </> "AssemblyInfo.fs") attributes
)
)

Target.create "Build" (fun _ ->
!! "**/*.fsproj"
-- "example/**/*.*proj"
ProjectSources.library
|> Seq.iter (DotNet.build id)
)

Target.create "BuildTests" (fun _ ->
ProjectSources.tests
|> Seq.iter (DotNet.build id)
)

Target.create "Lint" <| skipOn "no-lint" (fun _ ->
DotnetCore.installOrUpdateTool toolsDir ("dotnet-fsharplint")

let checkResult (messages: string list) =
let rec check: string list -> unit = function
| [] -> failwithf "Lint does not yield a summary."
| head :: rest ->
if head.Contains "Summary" then
match head.Replace("= ", "").Replace(" =", "").Replace("=", "").Replace("Summary: ", "") with
| "0 warnings" -> Trace.tracefn "Lint: OK"
| warnings -> failwithf "Lint ends up with %s." warnings
else check rest
messages
|> List.rev
|> check

!! "**/*.*proj"
-- "example/**/*.*proj"
|> Seq.map (fun fsproj ->
match toolsDir with
| Global ->
DotnetCore.runInRoot (sprintf "fsharplint lint %s" fsproj)
|> fun (result: ProcessResult) -> result.Messages
| Local dir ->
DotnetCore.execute "dotnet-fsharplint" ["lint"; fsproj] dir
|> fst
|> tee (Trace.tracefn "%s")
|> String.split '\n'
|> Seq.toList
ProjectSources.all
++ "./Build.fsproj"
|> Seq.iter (fun fsproj ->
match Dotnet.runInRoot (sprintf "fsharplint lint %s" fsproj) with
| Ok () -> Trace.tracefn "Lint %s is Ok" fsproj
| Error e -> raise e
)
|> Seq.iter checkResult
)

Target.create "Tests" (fun _ ->
if !! "tests/*.fsproj" |> Seq.isEmpty
if ProjectSources.tests |> Seq.isEmpty
then Trace.tracefn "There are no tests yet."
else DotnetCore.runOrFail "run" "tests"
else Dotnet.runOrFail "run" "tests"
)

Target.create "Release" (fun _ ->
Expand Down Expand Up @@ -242,7 +197,7 @@ Target.create "Release" (fun _ ->

"Clean"
==> "AssemblyInfo"
==> "Build"
==> "Build" <=> "BuildTests"
==> "Lint"
==> "Tests"
==> "Release"
Expand Down
9 changes: 3 additions & 6 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ source https://api.nuget.org/v3/index.json
nuget FSharp.Core ~> 5.0
nuget FSharp.Data ~> 4.1
nuget MF.ConsoleApplication ~> 2.0
nuget Tuc.DomainResolver ~> 2.0
nuget Tuc.DomainResolver ~> 2.1

group Tests
storage: none
source https://api.nuget.org/v3/index.json
nuget Expecto
nuget YoloDev.Expecto.TestSdk
nuget Expecto
nuget YoloDev.Expecto.TestSdk

// [ FAKE GROUP ]
group Build
Expand Down
69 changes: 31 additions & 38 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ NUGET
Colorful.Console (>= 1.2.10)
FSharp.Core (>= 4.7)
ShellProgressBar (>= 4.3)
FSharp.Compiler.Service (39.0)
FSharp.Core (5.0.1)
Microsoft.Build.Framework (>= 16.6)
Microsoft.Build.Tasks.Core (>= 16.6)
Microsoft.Build.Utilities.Core (>= 16.6)
Expecto (9.0.2)
FSharp.Core (>= 4.6)
Mono.Cecil (>= 0.11.2)
FSharp.Compiler.Service (40.0)
FSharp.Core (5.0.2)
Microsoft.Build.Framework (>= 16.9)
Microsoft.Build.Tasks.Core (>= 16.9)
Microsoft.Build.Utilities.Core (>= 16.9)
System.Buffers (>= 4.5.1)
System.Collections.Immutable (>= 5.0)
System.Diagnostics.Process (>= 4.3)
Expand All @@ -46,8 +49,8 @@ NUGET
System.Threading.Tasks.Parallel (>= 4.3)
System.Threading.Thread (>= 4.3)
System.Threading.ThreadPool (>= 4.3)
FSharp.Core (5.0.1)
FSharp.Data (4.1.1)
FSharp.Core (5.0.2)
FSharp.Data (4.2.2)
FSharp.Core (>= 4.7.2)
MF.ConsoleApplication (2.0)
ConsoleStyle (>= 2.0)
Expand Down Expand Up @@ -90,6 +93,7 @@ NUGET
System.Security.Principal.Windows (>= 5.0)
Microsoft.Win32.SystemEvents (5.0)
Microsoft.NETCore.Platforms (>= 5.0)
Mono.Cecil (0.11.4)
runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
Expand Down Expand Up @@ -579,11 +583,15 @@ NUGET
System.Runtime.Handles (>= 4.3)
System.Windows.Extensions (5.0)
System.Drawing.Common (>= 5.0)
Tuc.DomainResolver (2.0)
FSharp.Compiler.Service (>= 39.0)
FSharp.Core (>= 5.0.1)
FSharp.Data (>= 4.1.1)
Tuc.DomainResolver (2.1)
FSharp.Compiler.Service (>= 40.0)
FSharp.Core (>= 5.0.2)
FSharp.Data (>= 4.2.2)
MF.ConsoleApplication (>= 2.0)
YoloDev.Expecto.TestSdk (0.12.5)
Expecto (>= 9.0 < 10.0)
FSharp.Core (>= 4.6)
System.Collections.Immutable (>= 1.5 < 5.1)

GROUP Build
STORAGE: NONE
Expand Down Expand Up @@ -700,7 +708,7 @@ NUGET
FSharp.Control.Reactive (5.0.2) - restriction: >= netstandard2.0
FSharp.Core (>= 4.7.2) - restriction: >= netstandard2.0
System.Reactive (>= 5.0) - restriction: >= netstandard2.0
FSharp.Core (5.0.1) - restriction: >= netstandard2.0
FSharp.Core (5.0.2) - restriction: >= netstandard2.0
Microsoft.Bcl.AsyncInterfaces (5.0) - restriction: || (&& (>= monoandroid) (>= net50) (< netcoreapp2.0)) (&& (< monoandroid) (>= net50) (< netcoreapp2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= net50) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= net50) (< netcoreapp3.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= monotouch) (>= net50)) (&& (>= net461) (>= net50)) (>= net472) (&& (>= net50) (< netcoreapp2.0) (>= xamarinios)) (&& (>= net50) (< netcoreapp2.0) (>= xamarinmac)) (&& (>= net50) (< netstandard2.0) (>= xamarintvos)) (&& (>= net50) (< netstandard2.0) (>= xamarinwatchos)) (&& (>= net50) (>= uap10.1))
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net461) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1))
Microsoft.Build (16.10) - restriction: >= netstandard2.0
Expand Down Expand Up @@ -761,21 +769,21 @@ NUGET
Microsoft.Build.Tasks.Core (>= 16.4) - restriction: >= netstandard2.0
Microsoft.Build.Utilities.Core (>= 16.4) - restriction: >= netstandard2.0
Newtonsoft.Json (13.0.1) - restriction: >= netstandard2.0
NuGet.Common (5.9.1) - restriction: >= netstandard2.0
NuGet.Frameworks (>= 5.9.1) - restriction: || (>= net45) (>= netstandard2.0)
NuGet.Configuration (5.9.1) - restriction: >= netstandard2.0
NuGet.Common (>= 5.9.1) - restriction: || (>= net45) (>= netstandard2.0)
NuGet.Common (5.10) - restriction: >= netstandard2.0
NuGet.Frameworks (>= 5.10) - restriction: || (>= net45) (>= netstandard2.0)
NuGet.Configuration (5.10) - restriction: >= netstandard2.0
NuGet.Common (>= 5.10) - restriction: || (>= net45) (>= netstandard2.0)
System.Security.Cryptography.ProtectedData (>= 4.4) - restriction: && (< net45) (>= netstandard2.0)
NuGet.Frameworks (5.9.1) - restriction: >= netstandard2.0
NuGet.Packaging (5.9.1) - restriction: >= netstandard2.0
NuGet.Frameworks (5.10) - restriction: >= netstandard2.0
NuGet.Packaging (5.10) - restriction: >= netstandard2.0
Newtonsoft.Json (>= 9.0.1) - restriction: >= netstandard2.0
NuGet.Configuration (>= 5.9.1) - restriction: >= netstandard2.0
NuGet.Versioning (>= 5.9.1) - restriction: >= netstandard2.0
NuGet.Configuration (>= 5.10) - restriction: >= netstandard2.0
NuGet.Versioning (>= 5.10) - restriction: >= netstandard2.0
System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net50)
System.Security.Cryptography.Pkcs (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net50)
NuGet.Protocol (5.9.1) - restriction: >= netstandard2.0
NuGet.Packaging (>= 5.9.1) - restriction: >= netstandard2.0
NuGet.Versioning (5.9.1) - restriction: >= netstandard2.0
NuGet.Protocol (5.10) - restriction: >= netstandard2.0
NuGet.Packaging (>= 5.10) - restriction: >= netstandard2.0
NuGet.Versioning (5.10) - restriction: >= netstandard2.0
System.Buffers (4.5.1) - restriction: || (&& (>= monoandroid) (>= net50) (< netcoreapp2.0)) (&& (>= monoandroid) (< netcoreapp2.0) (>= netstandard2.0)) (&& (< monoandroid) (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (< monoandroid) (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= net50) (< netcoreapp2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard2.0) (< win8)) (&& (>= monotouch) (>= net50)) (&& (>= monotouch) (>= netstandard2.0)) (&& (>= net461) (>= net50)) (&& (>= net461) (>= netstandard2.0)) (>= net472) (&& (>= net50) (< netstandard2.0) (>= xamarintvos)) (&& (>= net50) (< netstandard2.0) (>= xamarinwatchos)) (&& (< netstandard1.1) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= uap10.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac)
System.CodeDom (5.0) - restriction: && (< net472) (>= netstandard2.0)
System.Collections.Immutable (5.0) - restriction: >= netstandard2.0
Expand Down Expand Up @@ -854,18 +862,3 @@ NUGET
System.ValueTuple (4.5) - restriction: || (&& (>= net45) (>= netstandard2.0)) (&& (>= net461) (>= net50)) (>= net472)
System.Windows.Extensions (5.0) - restriction: >= netcoreapp3.0
System.Drawing.Common (>= 5.0) - restriction: >= netcoreapp3.0

GROUP Tests
STORAGE: NONE
NUGET
remote: https://api.nuget.org/v3/index.json
Expecto (9.0.2)
FSharp.Core (>= 4.6) - restriction: || (>= net461) (>= netstandard2.0)
Mono.Cecil (>= 0.11.2) - restriction: || (>= net461) (>= netstandard2.0)
FSharp.Core (5.0.1) - restriction: || (>= net461) (>= netstandard2.0)
Mono.Cecil (0.11.3) - restriction: || (>= net461) (>= netstandard2.0)
System.Collections.Immutable (5.0) - restriction: >= netcoreapp2.1
YoloDev.Expecto.TestSdk (0.11.1)
Expecto (>= 9.0 < 10.0) - restriction: >= netcoreapp2.1
FSharp.Core (>= 4.6) - restriction: >= netcoreapp2.1
System.Collections.Immutable (>= 1.5 < 5.1) - restriction: >= netcoreapp2.1
5 changes: 2 additions & 3 deletions tests/paket.references
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FSharp.Core

group Tests
Expecto
YoloDev.Expecto.TestSdk
Expecto
YoloDev.Expecto.TestSdk

0 comments on commit 0639247

Please sign in to comment.