forked from dotnetrdf/dotnetrdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
126 lines (110 loc) · 3.9 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
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
#tool nuget:?package=codecov
#tool nuget:?package=gitlink
#tool nuget:?package=GitVersion.CommandLine&prerelease
#addin nuget:?package=Cake.Codecov
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools"
#tool "nuget:?package=ReportGenerator&version=4.0.4"
var target = Argument("target", "Build");
var configuration = Argument("Configuration", "Debug");
var version = Argument("NuGetVersion", "");
var libraryProjects = GetFiles("./Libraries/**/*.csproj");
var unitTests = GetFiles("**\\unittest.csproj").Single();
var mockServerTests = GetFiles("**\\dotNetRdf.MockServerTests.csproj").Single();
Task("Pack")
.IsDependentOn("Build")
.DoesForEach(libraryProjects, path => {
var settings = new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = "./nugets/",
NoBuild = true,
MSBuildSettings = new DotNetCoreMSBuildSettings()
};
settings.MSBuildSettings.Properties["version"] = new [] { version };
DotNetCorePack(path.FullPath, settings);
});
Task("GitVersion")
.WithCriteria(BuildSystem.IsLocalBuild && string.IsNullOrWhiteSpace(version))
.Does(() => {
version = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
}).NuGetVersion;
});
Task("Build")
.IsDependentOn("GitVersion")
.Does(() => {
DotNetCoreBuild("dotnetrdf.sln", new DotNetCoreBuildSettings {
Configuration = configuration
});
});
Task("Codecov")
.Does(() => {
Codecov("coverage\\cobertura.xml");
});
Task("TestNet452")
.IsDependentOn("Build")
.Does(RunTests(unitTests, "net452"))
.Does(RunTests(unitTests, "net452", "Category=fulltext"))
.Does(RunTests(mockServerTests, "net452"))
.ContinueOnError();
Task("TestNetCore20")
.IsDependentOn("Build")
.Does(RunTests(unitTests, "netcoreapp2.0"))
.ContinueOnError();
Task("TestNetCore11")
.IsDependentOn("Build")
.Does(RunTests(unitTests, "netcoreapp1.1"))
.Does(RunTests(mockServerTests, "netcoreapp1.1"))
.ContinueOnError();
Task("Test")
.IsDependentOn("TestNet452")
.IsDependentOn("TestNetCore20")
.IsDependentOn("TestNetCore11")
.Does(() => { });
Task("Cover")
.IsDependentOn("TestNetCore20")
.IsDependentOn("TestNetCore11")
.Does(() => {
if (DirectoryExists("coverage"))
CleanDirectories("coverage");
})
.Does(RunTests(unitTests, "net452", "Category!=explicit & Coverage=Skip"))
.Does(DotCover("net452", RunTests(unitTests, "net452", "Category!=explicit & Coverage!=Skip")))
.Does(DotCover("fulltext", RunTests(unitTests, "net452", "Category=fulltext")))
.Does(() => {
DotCoverMerge(GetFiles("coverage\\*.dcvr"), "coverage\\merged.dcvr");
})
.Does(() => {
DotCoverReport(
"./coverage/merged.dcvr",
"./coverage/dotcover.xml",
new DotCoverReportSettings {
ReportType = DotCoverReportType.DetailedXML,
});
})
.Does(() => {
StartProcess(
@".\tools\ReportGenerator.4.0.4\tools\net47\ReportGenerator.exe",
@"-reports:.\coverage\dotcover.xml -targetdir:.\coverage -reporttypes:Cobertura -assemblyfilters:-xunit*;-dotNetRDF.*Test");
})
.DeferOnError();
public Action<ICakeContext> DotCover(string name, Action<ICakeContext> unitTestRun)
{
return (ICakeContext c) =>
DotCoverCover(
unitTestRun,
$"./coverage/{name}.dcvr",
new DotCoverCoverSettings());
}
public Action<ICakeContext> RunTests(FilePath project, string framework, string filter = "Category!=explicit")
{
return (ICakeContext ctx) =>
ctx.DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings
{
Configuration = configuration,
Framework = framework,
NoBuild = true,
Filter = filter
});
}
RunTarget(target);