forked from Zaid-Ajaj/Fable.Remoting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
307 lines (250 loc) · 10.5 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
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#r "paket: groupref build //"
#load "./.fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
#endif
open System
open Fake
open Fake.Core
open Fake.IO
open Fake.SystemHelper
open System.Threading
let (</>) x y = System.IO.Path.Combine(x, y);
let cwd = __SOURCE_DIRECTORY__
let run workingDir fileName args =
printfn "CWD: %s" workingDir
let fileName, args =
if Environment.isUnix
then fileName, args else "cmd", ("/C " + fileName + " " + args)
CreateProcess.fromRawCommandLine fileName args
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.withTimeout TimeSpan.MaxValue
|> CreateProcess.ensureExitCodeWithMessage (sprintf "'%s> %s %s' task failed" workingDir fileName args)
|> Proc.run
|> ignore
let proj file = (sprintf "Fable.Remoting.%s" file) </> (sprintf "Fable.Remoting.%s.fsproj" file)
let testDll file = (sprintf "Fable.Remoting.%s.Tests" file) </> "bin" </> "Release" </> "net6.0" </> (sprintf "Fable.Remoting.%s.Tests.dll" file)
let JsonTestsDll = testDll "Json"
let MsgPackTestsDll = testDll "MsgPack"
let ServerTestsDll = testDll "Server"
let SuaveTestDll = testDll "Suave"
let GiraffeTestDll = testDll "Giraffe"
let dotnet = "dotnet"
let getPath x = cwd </> (sprintf "Fable.Remoting.%s" x)
let ClientV2 = getPath "ClientV2"
let Json = getPath "Json"
let Server = getPath "Server"
let Suave = getPath "Suave"
let Giraffe = getPath "Giraffe"
let GiraffeNET5 = getPath "GiraffeNET5"
let DotnetClient = getPath "DotnetClient"
let AspNetCore = getPath "AspNetCore"
let MsgPack = getPath "MsgPack"
let AzureFunctionsWorker = getPath "AzureFunctions.Worker"
let clean projectPath =
Shell.cleanDirs [
projectPath </> "bin"
projectPath </> "obj"
]
let publish projectPath = fun _ ->
clean projectPath
"pack -c Release"
|> run projectPath dotnet
let nugetKey =
match Environment.environVarOrNone "NUGET_KEY" with
| Some nugetKey -> nugetKey
| None -> failwith "The Nuget API key must be set in a NUGET_KEY environmental variable"
let nupkg = System.IO.Directory.GetFiles(projectPath </> "bin" </> "Release") |> Seq.head
let pushCmd = sprintf "nuget push %s -s nuget.org -k %s" nupkg nugetKey
run projectPath dotnet pushCmd
Target.create "PublishClient" (publish ClientV2)
Target.create "PublishJson" (publish Json)
Target.create "PublishServer" (publish Server)
Target.create "PublishDotnetClient" (publish DotnetClient)
Target.create "PublishSuave" (publish Suave)
Target.create "PublishGiraffe" (publish Giraffe)
Target.create "PublishGiraffeNET5" (publish GiraffeNET5)
Target.create "PublishAspnetCore" (publish AspNetCore)
Target.create "PublishMsgPack" (publish MsgPack)
Target.create "PublishMsgPackDownstream" (fun ctx ->
publish MsgPack ctx
publish ClientV2 ctx
publish Server ctx
publish Suave ctx
publish GiraffeNET5 ctx
publish AspNetCore ctx
publish DotnetClient ctx
publish AzureFunctionsWorker ctx
)
Target.create "PublishJsonDownstream" (fun ctx ->
publish Json ctx
publish Server ctx
publish Suave ctx
publish GiraffeNET5 ctx
publish AspNetCore ctx
publish DotnetClient ctx
publish AzureFunctionsWorker ctx
)
Target.create "CleanGiraffe" <| fun _ ->
clean (getPath "Giraffe")
clean (getPath "Giraffe.Tests")
Target.create "CleanSuave" <| fun _ ->
clean (getPath "Suave")
clean (getPath "Suave.Tests")
Target.create "RestoreBuildRunJsonTests" <| fun _ ->
run cwd "dotnet" ("restore " + proj "Json.Tests")
run cwd "dotnet" ("build " + proj "Json.Tests" + " --configuration=Release")
run cwd "dotnet" JsonTestsDll
Target.create "BuildRunJsonTests" <| fun _ ->
run cwd "dotnet" ("build " + proj "Json.Tests" + " --configuration=Release")
run cwd "dotnet" JsonTestsDll
Target.create "RunJsonTests" <| fun _ ->
run cwd "dotnet" JsonTestsDll
Target.create "RestoreBuildRunServerTests" <| fun _ ->
run cwd "dotnet" ("restore " + proj "Server.Tests")
run cwd "dotnet" ("build " + proj "Server.Tests" + " --configuration=Release")
run cwd "dotnet" ServerTestsDll
Target.create "BuildGiraffeTests" <| fun _ ->
let path = getPath "Giraffe.Tests"
run path "dotnet" "restore --no-cache"
run path "dotnet" "build -c Debug"
Target.create "BuildDotnetClientTests" <| fun _ ->
clean (getPath "IntegrationTests" </> "DotnetClient")
run (getPath "IntegrationTests" </> "DotnetClient") "dotnet" "build"
Target.create "RunDotnetClientTests" <| fun _ ->
let path = getPath "IntegrationTests" </> "DotnetClient"
clean path
run path "dotnet" "restore --no-cache"
run path "dotnet" "run"
Target.create "BuildRunServerTests" <| fun _ ->
run cwd "dotnet" ("build " + proj "Server.Tests" + " --configuration=Release")
run cwd "dotnet" ServerTestsDll
Target.create "RunServerTests" <| fun _ ->
run cwd "dotnet" ServerTestsDll
Target.create "RestoreBuildRunSuaveTests" <| fun _ ->
run cwd "dotnet" ("restore " + proj "Suave.Tests")
run cwd "dotnet" ("build " + proj "Suave.Tests" + " --configuration=Release")
run cwd "dotnet" SuaveTestDll
Target.create "BuildRunSuaveTests" <| fun _ ->
run cwd "dotnet" ("build " + proj "Suave.Tests" + " --configuration=Release")
run cwd "dotnet" SuaveTestDll
Target.create "RunSuaveTests" <| fun _ ->
run cwd "dotnet" SuaveTestDll
Target.create "RestoreBuildRunGiraffeTests" <| fun _ ->
run cwd "dotnet" ("restore " + proj "Giraffe.Tests")
run cwd "dotnet" ("build " + proj "Giraffe.Tests" + " --configuration=Release")
run cwd "dotnet" GiraffeTestDll
Target.create "BuildRunGiraffeTests" <| fun _ ->
run cwd "dotnet" ("build " + proj "Giraffe.Tests" + " --configuration=Release")
run cwd "dotnet" GiraffeTestDll
Target.create "RunGiraffeTests" <| fun _ ->
run cwd "dotnet" GiraffeTestDll
Target.create "InstallDocs" <| fun _ ->
run "documentation" "npm" "install"
Target.create "BuildDocs" <| fun _ ->
run "documentation" "npm" "run build"
Target.create "ServeDocs" <| fun _ ->
run "documentation" "npm" "run serve"
Target.create "PublishDocs" <| fun _ ->
run "documentation" "npm" "run publish"
Target.create "Default" (fun _ -> ())
open Fake.Core.TargetOperators
"CleanGiraffe" ==> "BuildRunGiraffeTests"
"CleanSuave" ==> "BuildRunSuaveTests"
let buildRunAzureFunctionsTests onTestsFinished =
let funcsPath = "Fable.Remoting.AzureFunctions.Worker.Tests" </> "FunctionApp"
let clientPath = "Fable.Remoting.AzureFunctions.Worker.Tests" </> "Client"
let mutable started = false
// Azure Functions Server
let server = Tasks.Task.Run (fun () ->
run funcsPath "dotnet" "restore --no-cache"
started <- true
run funcsPath "func start" "."
)
// Azure Functions Client
let client = Tasks.Task.Run (fun () ->
while started = false do
printfn "Waiting for Azure Functions server to start"
Thread.Sleep 2000
Thread.Sleep 5000 // give it time to start
run clientPath "dotnet" "restore --no-cache"
run clientPath "dotnet" "build --configuration=Release"
run cwd "dotnet" (clientPath </> "bin" </> "Release" </> "net6.0" </> "Fable.Remoting.AzureFunctions.Worker.Tests.Client.dll")
onTestsFinished()
Tasks.Task.CompletedTask
)
Tasks.Task.WaitAll (server, client)
Target.create "BuildRunAzureFunctionsTests" <| fun _ -> buildRunAzureFunctionsTests (fun _ -> Environment.Exit(0)) // necessary hack to finish func process
Target.create "PublishAzureFunctionsWorker" <| fun _ -> buildRunAzureFunctionsTests (publish AzureFunctionsWorker)
Target.create "BuildRunAllTests" <| fun _ ->
// Json
run cwd "dotnet" ("build " + proj "Json.Tests" + " --configuration=Release")
run cwd "dotnet" JsonTestsDll
// MsgPack
run cwd "dotnet" ("build " + proj "MsgPack.Tests" + " --configuration=Release")
run cwd "dotnet" MsgPackTestsDll
// Server
run cwd "dotnet" ("build " + proj "Server.Tests" + " --configuration=Release")
run cwd "dotnet" ServerTestsDll
// Suave
run cwd "dotnet" ("build " + proj "Suave.Tests" + " --configuration=Release")
run cwd "dotnet" SuaveTestDll
// Giraffe
run cwd "dotnet" ("build " + proj "Giraffe.Tests" + " --configuration=Release")
run cwd "dotnet" GiraffeTestDll
Target.create "IntegrationTests" <| fun _ ->
clean (getPath "Server")
clean (getPath "Json")
clean (getPath "MsgPack")
clean (getPath "Suave")
clean (getPath "UITests")
clean (getPath "IntegrationTests" </> "Server.Suave")
clean "ClientV2Tests"
Shell.rm (getPath "IntegrationTests" </> "client-dist" </> "bundle.js")
run ("ClientV2Tests" </> "src") "dotnet" "restore"
run "ClientV2Tests" "npm" "install"
run "ClientV2Tests" "npm" "run build"
run "UITests" "dotnet" "restore --no-cache"
run "UITests" "dotnet" "run --headless"
Target.create "IntegrationTestsNagareyama" <| fun _ ->
clean (getPath "Server")
clean (getPath "Json")
clean (getPath "MsgPack")
clean (getPath "Suave")
clean (getPath "UITests")
clean (getPath "IntegrationTests" </> "Server.Suave")
Shell.rm (getPath "IntegrationTests" </> "client-dist" </> "bundle.js")
clean "ClientV2Tests"
run ("ClientV2Tests" </> "src") "dotnet" "restore"
run "ClientV2Tests" "npm" "install"
run "ClientV2Tests" "npm" "run build-nagareyama"
run "UITests" "dotnet" "restore --no-cache"
run "UITests" "dotnet" "run --headless"
Target.create "IntegrationTestsNagareyamaLive" <| fun _ ->
clean (getPath "Server")
clean (getPath "Json")
clean (getPath "MsgPack")
clean (getPath "Suave")
clean (getPath "UITests")
clean (getPath "IntegrationTests" </> "Server.Suave")
Shell.rm (getPath "IntegrationTests" </> "client-dist" </> "bundle.js")
clean "ClientV2Tests"
run ("ClientV2Tests" </> "src") "dotnet" "restore"
run "ClientV2Tests" "npm" "install"
run "ClientV2Tests" "npm" "run build-nagareyama"
run "UITests" "dotnet" "restore --no-cache"
run "UITests" "dotnet" "run"
Target.create "IntegrationTestsLive" <| fun _ ->
clean (getPath "Server")
clean (getPath "Json")
clean (getPath "MsgPack")
clean (getPath "Suave")
clean (getPath "UITests")
clean (getPath "IntegrationTests" </> "Server.Suave")
clean "ClientV2Tests"
run "ClientV2Tests" "npm" "install"
run "UITests" "dotnet" "restore --no-cache"
run "ClientV2Tests" "npm" "run build"
run "UITests" "dotnet" "run"
Target.runOrDefault "BuildRunAllTests"