forked from Nhowka/Elmish.Bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.fsx
More file actions
264 lines (213 loc) · 8.49 KB
/
build.fsx
File metadata and controls
264 lines (213 loc) · 8.49 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#r @"paket:
source https://nuget.org/api/v2
framework netstandard2.0
nuget Fake.Core.Target
nuget Fake.Core.Process
nuget Fake.Core.ReleaseNotes
nuget Fake.IO.FileSystem
nuget Fake.DotNet.Cli
nuget Fake.DotNet.MSBuild
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.DotNet.Paket
nuget Fake.DotNet.Testing.Expecto
nuget Fake.DotNet.FSFormatting
nuget Fake.Tools.Git
nuget Fake.Api.GitHub //"
#if !FAKE
#load "./.fake/build.fsx/intellisense.fsx"
#r "netstandard" // Temp fix for https://github.com/fsharp/FAKE/issues/1985
#endif
open Fake
open Fake.Core.TargetOperators
open Fake.Core
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.DotNet
open Fake.DotNet.Testing
open Fake.Tools
open Fake.Tools.Git
open System
open System.IO
Target.initEnvironment()
// --------------------------------------------------------------------------------------
// Longer description of the project
// (used as a description for NuGet package; line breaks are automatically cleaned up)
let description = "F# Type Provider for Swagger & Open API"
// Pattern specifying assemblies to be tested using Expecto
let testAssemblies = "tests/**/bin/Release" </> "**" </> "*Tests*.exe"
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "fsprojects"
// The name of the project on GitHub
let gitName = "SwaggerProvider"
// --------------------------------------------------------------------------------------
// Read additional information from the release notes document
let release = ReleaseNotes.load "RELEASE_NOTES.md"
// Generate assembly info files with the right version & up-to-date information
Target.create "AssemblyInfo" (fun _ ->
let fileName = "src/Common/AssemblyInfo.fs"
AssemblyInfoFile.createFSharp fileName
[ AssemblyInfo.Title gitName
AssemblyInfo.Product gitName
AssemblyInfo.Description description
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.FileVersion release.AssemblyVersion ]
)
// --------------------------------------------------------------------------------------
// Clean build results
Target.create "Clean" (fun _ ->
!! "**/**/bin/" |> Shell.cleanDirs
//!! "**/**/obj/" |> Shell.cleanDirs
Shell.cleanDirs ["bin"; "temp"]
//try File.Delete("swaggerlog") with | _ -> ()
)
Target.create "CleanDocs" (fun _ ->
Shell.cleanDirs ["docs/output"]
)
// --------------------------------------------------------------------------------------
// Build library & test project
Target.create "Build" (fun _ ->
DotNet.exec id "build" ".\Elmish.Bridge.sln -c Release" |> ignore
)
let webApiInputStream = StreamRef.Empty
Target.create "StartServer" (fun _ ->
Target.activateFinal "StopServer"
CreateProcess.fromRawCommandLine "dotnet" "tests/Swashbuckle.WebApi.Server/bin/Release/netcoreapp3.1/Swashbuckle.WebApi.Server.dll"
|> CreateProcess.withStandardInput (CreatePipe webApiInputStream)
|> Proc.start
|> ignore
// We need delay to guarantee that server is bootstrapped
System.Threading.Thread.Sleep(2000)
)
Target.createFinal "StopServer" (fun _ ->
// Write something to input stream to stop server
try
webApiInputStream.Value.Write([|0uy|],0,1)
with
| e -> printfn "%s" e.Message
//Process.killAllByName "dotnet"
)
Target.create "BuildTests" (fun _ ->
DotNet.exec id "build" "SwaggerProvider.TestsAndDocs.sln -c Release" |> ignore
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner
let runTests assembly =
[Path.Combine(__SOURCE_DIRECTORY__, assembly)]
|> Testing.Expecto.run (fun p ->
{ p with
WorkingDirectory = __SOURCE_DIRECTORY__
FailOnFocusedTests = true
PrintVersion = true
Parallel = false
Summary = true
Debug = false
})
Target.create "RunUnitTests" (fun _ ->
runTests "tests/SwaggerProvider.Tests/bin/Release/netcoreapp3.1/SwaggerProvider.Tests.dll"
)
Target.create "RunIntegrationTests" (fun _ ->
runTests "tests/SwaggerProvider.ProviderTests/bin/Release/netcoreapp3.1/SwaggerProvider.ProviderTests.dll"
)
Target.create "RunTests" ignore
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target.create "NuGet" (fun _ ->
Paket.pack(fun p ->
{ p with
ToolType = ToolType.CreateGlobalTool()
OutputPath = "bin"
Version = release.NugetVersion
ReleaseNotes = String.toLines release.Notes})
)
Target.create "PublishNuget" (fun _ ->
Paket.push(fun p ->
{ p with
ToolType = ToolType.CreateLocalTool()
WorkingDir = "bin" })
)
// --------------------------------------------------------------------------------------
// Generate the documentation
// module Fake =
// let fakePath = "packages" </> "build" </> "FAKE" </> "tools" </> "FAKE.exe"
// let fakeStartInfo script workingDirectory args fsiargs environmentVars =
// (fun (info: Diagnostics.ProcessStartInfo) ->
// info.FileName <- Path.GetFullPath fakePath
// info.Arguments <- sprintf "%s --fsiargs -d:FAKE %s \"%s\"" args fsiargs script
// info.WorkingDirectory <- workingDirectory
// let setVar k v = info.EnvironmentVariables.[k] <- v
// for (k, v) in environmentVars do setVar k v
// setVar "MSBuild" msBuildExe
// setVar "GIT" CommandHelper.gitPath
// setVar "FSI" fsiPath)
// /// Run the given buildscript with FAKE.exe
// let executeFAKEWithOutput workingDirectory script fsiargs envArgs =
// let exitCode =
// ExecProcessWithLambdas
// (fakeStartInfo script workingDirectory "" fsiargs envArgs)
// TimeSpan.MaxValue false ignore ignore
// System.Threading.Thread.Sleep 1000
// exitCode
Target.create "BrowseDocs" (fun _ ->
CreateProcess.fromRawCommandLine "dotnet" "serve -o -d ./docs"
|> (Proc.run >> ignore)
)
// Target.create "GenerateDocs" (fun _ ->
// let exit = Fake.executeFAKEWithOutput "docs" "docs.fsx" "" ["target", "GenerateDocs"]
// if exit <> 0 then failwith "Generating documentation failed"
// )
// Target.create "PublishDocs" (fun _ ->
// let exit = Fake.executeFAKEWithOutput "docs" "docs.fsx" "" ["target", "PublishDocs"]
// if exit <> 0 then failwith "Publishing documentation failed"
// )
// Target.create "PublishStaticPages" (fun _ ->
// let exit = Fake.executeFAKEWithOutput "docs" "docs.fsx" "" ["target", "PublishStaticPages"]
// if exit <> 0 then failwith "Publishing documentation failed"
// )
// --------------------------------------------------------------------------------------
// Release Scripts
//#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
//open Octokit
Target.create "Release" (fun _ ->
// not fully converted from FAKE 4
// StageAll ""
// Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
// Branches.push ""
// Branches.tag "" release.NugetVersion
// Branches.pushTag "" "origin" release.NugetVersion
// // release on github
// createClient (getBuildParamOrDefault "github-user" "") (getBuildParamOrDefault "github-pw" "")
// |> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
// // TODO: |> uploadFile "PATH_TO_FILE"
// |> releaseDraft
// |> Async.RunSynchronously
// using simplified FAKE 5 release for now
Git.Staging.stageAll ""
Git.Commit.exec "" (sprintf "Bump version to %s" release.NugetVersion)
Git.Branches.push ""
Git.Branches.tag "" release.NugetVersion
Git.Branches.pushTag "" "origin" release.NugetVersion
)
Target.create "BuildPackage" ignore
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target.create "All" ignore
// https://github.com/fsharp/FAKE/issues/2283
let skipTests = Environment.environVarAsBoolOrDefault "skipTests" false
"Clean"
//==> "AssemblyInfo"
==> "Build"
//==> "RunUnitTests"
//==> "StartServer"
//==> "BuildTests"
//=?> ("RunIntegrationTests", not skipTests)
//==> "StopServer"
//==> "RunTests"
//=?> ("GenerateDocs", BuildServer.isLocalBuild)
==> "NuGet"
==> "All"
==> "BuildPackage"
==> "PublishNuget"
==> "Release"
Target.runOrDefault "BuildPackage"