-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
78 lines (65 loc) · 2.63 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
// ------------------------------------------------------------------------------
// Baby FAKE build script!
// ------------------------------------------------------------------------------
// FAKE
#r "packages/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
open Fake.Git
open Fake.ReleaseNotesHelper
let releaseNotes = LoadReleaseNotes "RELEASE_NOTES.md"
Target "Package" (fun _ ->
// Delete any existing .nupkg files
if Directory.Exists("bin") then
Directory.EnumerateFiles("bin", "*.nupkg", SearchOption.TopDirectoryOnly)
|> Seq.iter File.Delete
// Package up the build script
Paket.Pack (fun p ->
{ p with
OutputPath = "bin";
Version = releaseNotes.NugetVersion;
ReleaseNotes = releaseNotes.Notes |> toLines;
})
)
let runTestScript script =
let dir = Path.GetDirectoryName script
let template = Path.GetFileName dir
printfn "Running tests for the %s template" template
let (ranOkay, output) = Fake.FSIHelper.executeFSI dir script []
output |> Seq.iter (fun x -> System.Console.WriteLine x.Message)
let errors = output |> Seq.exists (fun x -> x.IsError)
if not ranOkay then
failwithf "FSI returned an error code after running the %s tests." template
if errors then
failwithf "FSI generated error messages while running the %s tests." template
printfn "Successfully ran tests for the %s template" template
let runBadScript script =
let f1 = Path.GetDirectoryName >> Path.GetFileName
let f2 = Path.GetDirectoryName >> f1
let relPath = (f2 script) @@ (f1 script) @@ (Path.GetFileName script)
let relPath = relPath.Replace("\\", "/")
printfn "Running the test script '%s', which should result in errors" relPath
let dir = Path.GetDirectoryName script
let template = f2 script
let (ranOkay, output) = Fake.FSIHelper.executeFSI dir script []
output |> Seq.iter (fun x -> System.Console.WriteLine x.Message)
let errors = output |> Seq.exists (fun x -> x.IsError)
if ranOkay && not errors then
failwithf "FSI successfully ran a %s test that should have failed." template
printfn "Test script '%s' finished running with errors, as expected.\n" relPath
Target "RunTests" (fun _ ->
!! "tests/**/test.fsx"
|> Seq.iter runTestScript
!! "tests/**/bad_tests/**.fsx"
|> Seq.iter runBadScript
)
Target "GitTag" (fun _ ->
let tag = sprintf "%s" releaseNotes.NugetVersion
Branches.tag "" tag
)
Target "Default" DoNothing
Target "Release" DoNothing
"RunTests" ==> "Package" ==> "Default"
"Package" ==> "GitTag" ==> "Release"
RunTargetOrDefault "Default"