-
Notifications
You must be signed in to change notification settings - Fork 157
/
build.fsx
96 lines (73 loc) · 2.78 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#r "nuget: Fun.Build, 1.0.4"
#r "nuget: Fake.IO.FileSystem, 6.0.0"
#r "nuget: Ionide.KeepAChangelog, 0.1.8"
open System.IO
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.IO
open Ionide.KeepAChangelog
open Ionide.KeepAChangelog.Domain
open Fun.Build
let root = __SOURCE_DIRECTORY__
// Information about the project to be used at NuGet and in AssemblyInfo files
let project = "FSharp.Formatting"
let summary =
"A package of libraries for building great F# documentation, samples and blogs"
let license = "Apache 2.0 License"
let configuration = "Release"
// Folder to deposit deploy artifacts
let artifactsDir = root @@ "artifacts"
// Local fsdocs-tool
let fsdocTool = artifactsDir @@ "fsdocs"
// Read release notes document
let releaseNugetVersion, _, _ =
let changeLog = FileInfo(__SOURCE_DIRECTORY__ </> "RELEASE_NOTES.md")
match Parser.parseChangeLog changeLog with
| Error(msg, error) -> failwithf "%s msg\n%A" msg error
| Ok result -> result.Releases |> List.head
let solutionFile = "FSharp.Formatting.sln"
let lintStage =
stage "Lint" {
run "dotnet tool restore"
run $"dotnet fantomas {__SOURCE_FILE__} src tests docs --check"
}
let testStage =
stage "Tests" {
run
$"dotnet test {solutionFile} --configuration {configuration} --no-build --blame --logger trx --results-directory TestResults -tl"
}
pipeline "CI" {
lintStage
stage "Clean" {
run (fun _ ->
!!artifactsDir ++ "temp" |> Shell.cleanDirs
// in case the above pattern is empty as it only matches existing stuff
[ "bin"; "temp"; "tests/bin" ] |> Seq.iter Directory.ensure)
}
stage "Build" {
run $"dotnet restore {solutionFile} -tl"
run $"dotnet build {solutionFile} --configuration {configuration} -tl"
}
stage "NuGet" { run $"dotnet pack {solutionFile} --output \"{artifactsDir}\" --configuration {configuration} -tl" }
testStage
stage "GenerateDocs" {
run (fun _ ->
Shell.cleanDir ".fsdocs"
Shell.cleanDir ".packages")
// Τhe tool has been uninstalled when the
// artifacts folder was removed in the Clean stage.
run
$"dotnet tool install --no-cache --version %A{releaseNugetVersion} --add-source \"%s{artifactsDir}\" --tool-path \"%s{artifactsDir}\" fsdocs-tool"
run $"\"{fsdocTool}\" build --strict --clean --properties Configuration=Release"
run $"dotnet tool uninstall fsdocs-tool --tool-path \"%s{artifactsDir}\""
run (fun _ -> Shell.cleanDir ".packages")
}
runIfOnlySpecified false
}
pipeline "Verify" {
lintStage
testStage
stage "Analyzers" { run "dotnet msbuild /t:AnalyzeSolution" }
runIfOnlySpecified true
}
tryPrintPipelineCommandHelp ()