-
Notifications
You must be signed in to change notification settings - Fork 10
/
fake.fsx
121 lines (97 loc) · 4.18 KB
/
fake.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
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Testing.NUnit3
open System.IO
open AssemblyInfoFile
let solutionFilePath = "./src/Fettle.sln"
let mode = getBuildParamOrDefault "mode" "Release"
let version = File.ReadAllText("./VERSION")
let generateAssemblyInfoTarget() =
CreateCSharpAssemblyInfo "./src/SharedAssemblyInfoAutoGenerated.cs"
[Attribute.Version version
Attribute.FileVersion version]
let buildTarget() =
!! (sprintf "./src/**/bin/%s/" mode) |> CleanDirs
build (fun x ->
{ x with Verbosity = Some MSBuildVerbosity.Quiet
Properties = [ "Configuration", mode ] }) solutionFilePath
let testTarget() =
let testAssemblies = !! (sprintf "./src/**/bin/%s/*Tests.dll" mode)
-- (sprintf "./src/**/bin/%s/*XUnit*" mode)
let nUnitParams _ =
{
NUnit3Defaults with
Workers = Some(1)
Labels = LabelsLevel.Off
}
testAssemblies |> NUnit3 nUnitParams
let coverageTarget() =
let nunitArgs = [
// Only check coverage of fettle itself, don't bother with the example projects
sprintf "./src/Tests/bin/%s/Fettle.Tests.dll" mode;
"--trace=Off";
"--output=./nunit-output.log"
] |> String.concat " "
let allArgs = [
"-register:path64";
"-output:\"opencover.xml\"";
"-returntargetcode:1";
"-hideskipped:All";
"-skipautoprops";
// Workaround for issue where opencover tries to cover some dependencies
"-filter:\"+[*]* -[*.Tests]* -[Moq*]* -[nunit.framework*]*\"";
"-target:\"./packages/NUnit.ConsoleRunner/tools/nunit3-console.exe\"";
sprintf "-targetargs:\"%s\"" nunitArgs
]
let result =
ExecProcess (fun info ->
info.FileName <- "./packages/OpenCover/tools/OpenCover.Console.exe"
info.Arguments <- allArgs |> String.concat " "
)(System.TimeSpan.FromMinutes 7.0)
if result <> 0 then failwith "Test coverage via OpenCover failed or timed-out"
let coverageReportTarget() =
let args = [
"-reports:./opencover.xml";
"-verbosity:Warning";
"-targetdir:./coverage-report";
]
let result =
ExecProcess (fun info ->
info.FileName <- "./packages/reportgenerator/tools/ReportGenerator.exe"
info.Arguments <- args |> String.concat " "
)(System.TimeSpan.FromMinutes 7.0)
if result <> 0 then failwith "Test coverage via OpenCover failed or timed-out"
let watchTarget() =
use watcher = !! "src/**/*.fs" |> WatchChanges (fun changes ->
printfn ">>>>> Files changed: %s" (changes |> Seq.map (fun c -> c.FullPath) |> String.concat ", ")
buildTarget()
testTarget()
printfn ">>>>> Watching the file-system for changes..."
)
printfn ">>>>> Watching the file-system for changes..."
System.Console.ReadLine() |> ignore
watcher.Dispose()
let packageTarget() =
let buildVersion = File.ReadAllText("./VERSION")
NuGetPack (fun p ->
{p with
Version = buildVersion
WorkingDir = "."
ReleaseNotes = sprintf "https://github.com/ComparetheMarket/fettle/releases/tag/v%s" buildVersion
Files = [ (sprintf @"src\Console\bin\%s\*.*" mode, Some "tools", None) ]
OutputPath = "."
Publish = false
})
"./Fettle.Console.nuspec"
Target "GenerateAssemblyInfo" generateAssemblyInfoTarget
Target "Build" buildTarget
Target "Test" testTarget
Target "Coverage" coverageTarget
Target "CoverageReport" coverageReportTarget
Target "Package" packageTarget
"GenerateAssemblyInfo" ==> "Build"
"Build" ==> "Test"
"Build" ==> "Coverage" ==> "CoverageReport"
"Test" ==> "Package"
Target "Watch" watchTarget
RunTargetOrDefault "Test"