-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.fsx
209 lines (182 loc) · 8.14 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.DotNet.PaketTemplate
open Fake.DotNet.FSFormatting
type Project =
{ Name : string
Summary : string
Description : string list
GitHubUrl : string
NuGetUrl : string
Authors : string list }
let project =
{ Name = "FScenario"
Summary = "Reusable integration test building blocks to write integration tests in a more safe and fun way"
Description =
[ "Reusable integration test building blocks to write integration tests in a more safe and fun way. "
"The package consists of several functions to help write tests that clean up after themselves, "
"making assertions more reliable by polling for required results, "
"adds some standard building blocks for you to start creating your own disposable fixture, ..." ]
GitHubUrl = "https://github.com/stijnmoreels/FScenario"
NuGetUrl = "http://nuget.org/packages/FScenario"
Authors = [ "Stijn Moreels" ] }
let projectHttp =
{ Name = "FScenario.Http"
Summary = "Reusable HTTP server integration test building blocks to write integration tests in a more safe and fun way"
Description =
[ "Reusable HTTP server integration test building blocks to write integration tests in a more safe and fun way. "
"The package consists of several functions to help write tests that clean up after themselves, "
"making assertions more reliable by polling for required results, "
"adds some standard building blocks for you to start creating your own disposable fixture, ..." ]
GitHubUrl = "https://github.com/stijnmoreels/FScenario.Http"
NuGetUrl = "http://nuget.org/packages/FScenario.Http"
Authors = [ "Stijn Moreels" ] }
let projects = [ project; projectHttp ]
let dotnetExePath = "dotnet"
let releaseNotes = ReleaseNotes.load "RELEASE_NOTES.md"
let solution = project.Name + ".sln"
Target.create "Clean" <| fun _ ->
!! "src/**/bin"
++ "src/**/obj"
++ "tests/**/bin"
++ "tests/**/obj"
++ "docs"
++ "bin"
|> Shell.cleanDirs
Target.create "Build" <| fun _ ->
AssemblyInfoFile.createFSharp ("src/" + project.Name + "/AssemblyInfo.fs")
[ AssemblyInfo.Title project.Name
AssemblyInfo.Description project.Summary
AssemblyInfo.Guid "871111ca-f7e3-48c5-95b1-6eec4c289948"
AssemblyInfo.Product project.Name
AssemblyInfo.Version releaseNotes.NugetVersion
AssemblyInfo.FileVersion releaseNotes.NugetVersion ]
AssemblyInfoFile.createFSharp ("src/" + projectHttp.Name + "/AssemblyInfo.fs")
[ AssemblyInfo.Title projectHttp.Name
AssemblyInfo.Description projectHttp.Summary
AssemblyInfo.Guid "871111ca-f7e3-48c5-95b1-6eec4c289949"
AssemblyInfo.Product projectHttp.Name
AssemblyInfo.Version releaseNotes.NugetVersion
AssemblyInfo.FileVersion releaseNotes.NugetVersion ]
DotNet.restore id solution
!! "src/**/*.fsproj"
++ "tests/**/*.fsproj"
++ "tests/**/*.csproj"
|> Seq.iter (DotNet.build (fun defaults ->
{ defaults with
Configuration = DotNet.BuildConfiguration.Release }))
Target.create "Tests" <| fun _ ->
let runTest project =
DotNet.exec (DotNet.Options.withDotNetCliPath dotnetExePath)
("run --project " + project)
"--summary"
|> fun r -> if r.ExitCode <> 0 then project + " failed" |> failwith
runTest "tests/FScenario.Tests/FScenario.Tests.fsproj"
Target.create "Paket" <| fun _ ->
for project in projects do
let templateFile = "src" @@ project.Name @@ "paket.template"
let referencesFile = "src" @@ project.Name @@ "paket.references"
PaketTemplate.create (fun defaults ->
{ defaults with
TemplateFilePath = Some templateFile
TemplateType = PaketTemplate.PaketTemplateType.File
Id = Some project.Name
Version = Some releaseNotes.NugetVersion
Description = project.Description
Title = Some project.Name
Authors = project.Authors
Owners = project.Authors
ReleaseNotes = releaseNotes.Notes
Summary = [ project.Summary ]
ProjectUrl = Some project.GitHubUrl
LicenseUrl = Some (project.GitHubUrl + "/blob/master/LICENSE.txt")
IconUrl = Some "https://raw.githubusercontent.com/stijnmoreels/FScenario/master/docs/img/logo.png"
Copyright = Some "Copyright 2019"
Tags = [ "fsharp"; "integration-tests"; "integration"; "tests"; "disposable"; "polling"; "fixture"; "teardown" ]
Files =
[ PaketFileInfo.Include ("bin/Release/netstandard2.0/*.dll", "lib/netstandard2.0")
PaketFileInfo.Include ("bin/Release/netstandard2.0/*.xml", "lib/netstandard2.0") ]
Dependencies =
Paket.getDependenciesForReferencesFile referencesFile
|> Array.map (fun (package, version) -> PaketDependency (package, GreaterOrEqual (Version version)))
|> List.ofArray })
Paket.pack (fun defaults ->
{ defaults with
OutputPath = "bin"
WorkingDir = "."
TemplateFile = templateFile })
Target.create "Docs" <| fun _ ->
let content = __SOURCE_DIRECTORY__ @@ "docsrc/content"
let docsOutput = __SOURCE_DIRECTORY__ @@ "docs"
let files = __SOURCE_DIRECTORY__ @@ "docsrc/files"
let templates = __SOURCE_DIRECTORY__ @@ "docsrc/tools/templates"
let formatting = __SOURCE_DIRECTORY__ @@ "packages/formatting/FSharp.Formatting"
let docTemplate = formatting @@ "templates/docpage.cshtml"
let root = "/" + project.Name
let info =
[ "project-name", project.Name
"project-author", project.Authors |> List.head
"project-summary", project.Summary
"project-github", project.GitHubUrl
"project-nuget", project.NuGetUrl ]
let layoutRootsAll = System.Collections.Generic.Dictionary<string, string list>()
layoutRootsAll.Add("en", [ templates
formatting @@ "templates"
formatting @@ "templates/reference" ])
File.delete "docsrc/content/release-notes.md"
Shell.copyFile "docsrc/content/" "RELEASE_NOTES.md"
Shell.rename "docsrc/content/release-notes.md" "docsrc/content/RELEASE_NOTES.md"
File.delete "docsrc/content/license.md"
Shell.copyFile "docsrc/content/" "LICENSE.txt"
Shell.rename "docsrc/content/license.md" "docsrc/content/LICENSE.txt"
DirectoryInfo.getSubDirectories (DirectoryInfo.ofPath templates)
|> Seq.iter (fun d ->
let name = d.Name
if name.Length = 2 || name.Length = 3
then let value =
[ templates @@ name
formatting @@ "templates"
formatting @@ "templates/reference" ]
layoutRootsAll.Add(name, value))
Shell.copyRecursive files docsOutput true
|> Trace.logItems "Copying file: "
Directory.ensure (docsOutput @@ "content")
Shell.copyRecursive (formatting @@ "styles") (docsOutput @@ "content") true
|> Trace.logItems "Copying styles and scripts: "
let langSpecificPath (lang, path:string) =
path.Split([|'/'; '\\'|], System.StringSplitOptions.RemoveEmptyEntries)
|> Array.exists(fun i -> i = lang)
let layoutRoots =
let key = layoutRootsAll.Keys |> Seq.tryFind (fun i -> langSpecificPath(i, content))
match key with
| Some lang -> layoutRootsAll.[lang]
| None -> layoutRootsAll.["en"]
Directory.ensure (docsOutput @@ "reference")
!! ("src/FScenario/bin/Release/**/FScenario.dll")
++ ("src/FScenario.Http/bin/Release/**/FScenario.Http.dll")
|> FSFormatting.createDocsForDlls (fun args ->
{ args with
OutputDirectory = docsOutput @@ "reference"
LayoutRoots = layoutRootsAll.["en"]
ProjectParameters = ("root", root) :: info
SourceRepository = project.GitHubUrl @@ "tree/master" })
FSFormatting.createDocs (fun args ->
{ args with
Source = content
OutputDirectory = docsOutput
LayoutRoots = layoutRoots
ProjectParameters = ("root", root) :: info
Template = docTemplate })
Target.create "All" ignore
"Clean"
==> "Build"
==> "Tests"
==> "Docs"
==> "Paket"
==> "All"
Target.runOrDefault "All"