-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
100 lines (87 loc) · 2.41 KB
/
build.cake
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
#addin Cake.Coveralls
#tool "nuget:?package=coveralls.io"
#tool "nuget:?package=OpenCover"
using System;
var target = Argument("target", "");
var coverallsToken = Argument("coverallsToken", "");
var buildConfig = Argument("buildconfiguration", "Debug");
var buildPath = "./bin";
var coverageFile = "./coverage-result.xml";
Task("Build")
.IsDependentOn("Clean")
.Does(() => {
Information("========== Restoring packages ==========");
DotNetCoreRestore();
Information("=============== Building ===============");
DotNetCoreBuild(".\\project.json");
Information("========================================");
})
.OnError(ex => {
Information("================ ERROR =================");
Information("Error.{0}{1}{0}", Environment.NewLine, ex);
RunTarget("Clean");
});
Task("Clean").Does(() => {
var totalKbs = 0M;
Func<string, decimal> getKbs = path =>
{
var fileKbs = FileSize(path) / 1024;
totalKbs = totalKbs + fileKbs;
return fileKbs;
};
CleanDirectory(buildPath,
fsInfo => {
if(!DirectoryExists(fsInfo.Path.FullPath))
{
Information("Excluding file \"{0}\". Size: {1} KB", fsInfo.Path.FullPath, getKbs(fsInfo.Path.FullPath));
}
return fsInfo.Exists;
}
);
if (FileExists(coverageFile))
{
Information("Excluding coverage results. File size: {0} KB", getKbs(coverageFile));
DeleteFile(coverageFile);
}
Information("Total deleted: {0} KB", totalKbs);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
Information("=============== Testing ================");
var testAssemblies = GetFiles("./bin/**/hippocampus-sql.dll");
DotNetCoreTest();
Information("========================================");
});
Task("UploadCoverageReport")
.IsDependentOn("GenerateCoverageReport")
.Does(() =>
{
if(string.IsNullOrEmpty(coverallsToken))
{
throw new ArgumentNullException("coverallsToken");
}
Information("======= UPLOADING COVERAGE DATA ========");
CoverallsIo(new FilePath(coverageFile),
new CoverallsIoSettings()
{
RepoToken = coverallsToken
});
Information("=============== FINISHED ===============");
})
.OnError(ex => {
Information("================ ERROR =================");
Information("Erro: {0}", ex);
});
Task("GenerateCoverageReport")
.IsDependentOn("Build")
.Does(() =>
{
OpenCover(tool => tool.DotNetCoreTest(),
new FilePath(coverageFile),
new OpenCoverSettings()
.WithFilter("+[hippocampus-sql]*"));
});
if(!string.IsNullOrEmpty(target))
RunTarget(target);