-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
83 lines (67 loc) · 2.05 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
// include Fake libs
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Testing.XUnit2
// Directories
let buildDir = "./build/"
let deployDir = "./deploy/"
// Filesets
let appReferences =
!! "/**/*.csproj"
++ "/**/*.fsproj"
// version info
let version = "0.1" // or retrieve from CI server
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; deployDir]
)
Target "Build" (fun _ ->
// compile all projects below src/app/
MSBuildDebug buildDir "Build" appReferences
|> Log "AppBuild-Output: "
)
Target "Test" (fun _ ->
!! (buildDir @@ "*.tests.dll")
|> xUnit2 (fun p -> { p with
HtmlOutputPath = Some ("xunit.html");
ToolPath = "packages/xunit.runner.console/tools/xunit.console.exe";
})
|> ignore
)
Target "Deploy" (fun _ ->
!! (buildDir + "/**/*.*")
-- "*.zip"
|> Zip buildDir (deployDir + "ApplicationName." + version + ".zip")
)
Target "Watch" (fun _ ->
use watcher = (!! "build/*.dll") |> WatchChanges (fun changes ->
tracefn "%A" changes
Run "Test")
System.Console.ReadLine() |> ignore //Needed to keep FAKE from exiting
watcher.Dispose() // Use to stop the watch from elsewhere, ie another task.
)
Target "Docker" (fun _ ->
ExecProcess (fun info ->
info.FileName <- "docker"
info.Arguments <- "build -t cache ."
info.WorkingDirectory <- ".") (System.TimeSpan.FromMinutes 5.0) |> ignore
)
Target "Migrations" (fun _ ->
!!("./migrations/up/**")
|> Seq.filter(fun filename ->
match filename with
| filename when filename.Contains(".sql") -> true
| _ -> false)
|> Seq.iter(fun (filename) ->
ExecProcess (fun info ->
info.FileName <- "psql"
info.Arguments <- sprintf "-U postgres -f %s -d hucache" filename
info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore
)
)
// Build order
"Clean"
==> "Build"
==> "Deploy"
// start build
RunTargetOrDefault "Build"