forked from lecaillon/Evolve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
230 lines (202 loc) · 8.21 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#tool nuget:?package=ReportGenerator&version=4.2.20
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "default");
var configuration = Argument("configuration", "Release");
var version = XmlPeek(File("./build/common.props"), "/Project/PropertyGroup/Version/text()");
var sln = "./Evolve.sln";
var slnTestMsbuildWinx64 = "./Evolve.Test.MSBuild.Windows.x64.sln";
var distDir = "./dist";
var distDirFullPath = MakeAbsolute(Directory($"{distDir}")).FullPath;
var publishDir = "./publish";
var publishDirFullPath = MakeAbsolute(Directory($"{publishDir}")).FullPath;
var winWarpPacker = "./warp/windows-x64.warp-packer.exe";
var linuxWarpPacker = "./warp/linux-x64.warp-packer";
var framework = "netcoreapp3.0";
var logger = Environment.GetEnvironmentVariable("TF_BUILD") == "True" ? $"-l:trx --results-directory {publishDirFullPath}" : "-l:console;verbosity=normal";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
Information($"Building Evolve {version}");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("clean").Does(() =>
{
CreateDirectory(distDir);
CleanDirectories(distDir);
CleanDirectories(publishDir);
CleanDirectories($"./**/obj/{framework}");
CleanDirectories(string.Format("./**/obj/{0}", configuration));
CleanDirectories(string.Format("./**/bin/{0}", configuration));
});
Task("win-build").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
MSBuild(sln, new MSBuildSettings
{
Configuration = configuration,
Verbosity = Verbosity.Minimal,
Restore = true
});
});
Task("linux-build").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
DotNetCoreBuild("./test/Evolve.Tests", new DotNetCoreBuildSettings
{
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("test").Does(() =>
{
var pathFilter = Environment.GetEnvironmentVariable("APPVEYOR") == "True" ? "\\SCassandra" : "";
DotNetCoreTest("./test/Evolve.Tests", new DotNetCoreTestSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.AppendSwitchQuoted("--filter", "Category!=Cli")
.Append(logger)
.Append("/p:AltCover=true")
.Append("/p:AltCoverForce=true")
.Append("/p:AltCoverCallContext=[Fact]|[Theory]")
.Append("/p:AltCoverAssemblyFilter=Evolve.Tests|xunit.runner|MySqlConnector|xunit.assert|xunit.core|xunit.execution.dotnet")
.Append($"/p:AltCoverPathFilter={pathFilter}")
.Append("/p:AltCoverTypeFilter=Evolve.MSBuild.EvolveBoot|Evolve.MSBuild.AppConfigCliArgsBuilder|Evolve.Utilities.Check|SimpleJSON.JSON|SimpleJSON.JSONArray|SimpleJSON.JSONBool|SimpleJSON.JSONLazyCreator|SimpleJSON.JSONNode|SimpleJSON.JSONNull|SimpleJSON.JSONNumber|SimpleJSON.JSONObject|SimpleJSON.JSONString|ConsoleTables.ConsoleTable|ConsoleTables.ConsoleTableOptions")
.Append($"/p:AltCoverXmlReport={publishDirFullPath}/coverage.xml")
});
});
Task("report-coverage").Does(() =>
{
ReportGenerator($"{publishDir}/coverage.xml", $"{publishDir}/coverage", new ReportGeneratorSettings
{
ReportTypes = new[] { ReportGeneratorReportType.Badges, ReportGeneratorReportType.Cobertura, ReportGeneratorReportType.HtmlInline_AzurePipelines_Dark },
Verbosity = ReportGeneratorVerbosity.Info
});
});
Task("test-cli").Does(() =>
{
DotNetCoreTest("./test/Evolve.Tests", new DotNetCoreTestSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.AppendSwitchQuoted("--filter", "Category=Cli")
.Append(logger)
});
});
Task("win-publish-cli").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
DotNetCorePublish("./src/Evolve.Cli", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = publishDir + "/cli/win-x64",
Runtime = "win-x64"
});
});
Task("linux-publish-cli").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
DotNetCorePublish("./src/Evolve.Cli", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = publishDir + "/cli/linux-x64",
Runtime = "linux-x64"
});
});
Task("win-warp-cli").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
StartProcess(winWarpPacker, new ProcessSettings().WithArguments
(
args => args.Append($"--arch windows-x64")
.Append($"--input_dir {publishDir}/cli/win-x64")
.Append($"--exec Evolve.Cli.exe")
.Append($"--output {distDir}/evolve.exe")
));
});
Task("linux-warp-cli").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
StartProcess(linuxWarpPacker, new ProcessSettings().WithArguments
(
args => args.Append($"--arch linux-x64")
.Append($"--input_dir {publishDir}/cli/linux-x64")
.Append($"--exec Evolve.Cli")
.Append($"--output {distDir}/evolve")
));
});
Task("pack-evolve").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
NuGetPack("./src/Evolve/Evolve.nuspec", new NuGetPackSettings
{
OutputDirectory = distDir,
Version = version
});
});
Task("pack-evolve.msbuild.windows.x64").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
NuGetPack("./src/Evolve.MSBuild/Evolve.MSBuild.Windows.x64.nuspec", new NuGetPackSettings
{
DevelopmentDependency = true,
OutputDirectory = distDir,
Version = version
});
});
Task("pack-evolve-tool").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
DotNetCorePack("./src/Evolve.Tool/", new DotNetCorePackSettings
{
OutputDirectory = distDir,
Configuration = configuration,
NoRestore = false,
NoBuild = false
});
});
Task("test-msbuild.windows.x64-for-net").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
foreach(var file in GetFiles("./test-msbuild-package/Windows.x64/**/packages.config"))
{
XmlPoke(file, "/packages/package[@id = 'Evolve.MSBuild.Windows.x64']/@version", version);
}
NuGetRestore(slnTestMsbuildWinx64, new NuGetRestoreSettings
{
Source = new[] { "https://api.nuget.org/v3/index.json", distDirFullPath.Replace('/', '\\') }
});
MSBuild(slnTestMsbuildWinx64, new MSBuildSettings
{
Configuration = configuration,
Verbosity = Verbosity.Minimal,
Restore = false
});
});
Task("test-msbuild.windows.x64-for-netcore").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
NuGetRestore(slnTestMsbuildWinx64, new NuGetRestoreSettings
{
Source = new[] { "https://api.nuget.org/v3/index.json", distDirFullPath.Replace('/', '\\') }
});
foreach(var project in GetFiles("./test-msbuild-package/Windows.x64/**/Evolve.*Core*.Test.csproj"))
{
DotNetCoreBuild(project.FullPath, new DotNetCoreBuildSettings
{
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal,
NoRestore = true
});
}
});
Task("default")
.IsDependentOn("clean")
.IsDependentOn("win-build")
.IsDependentOn("linux-build")
.IsDependentOn("test")
.IsDependentOn("report-coverage")
.IsDependentOn("win-publish-cli")
.IsDependentOn("win-warp-cli")
.IsDependentOn("linux-publish-cli")
.IsDependentOn("linux-warp-cli")
.IsDependentOn("test-cli")
.IsDependentOn("pack-evolve.msbuild.windows.x64")
.IsDependentOn("test-msbuild.windows.x64-for-net")
.IsDependentOn("test-msbuild.windows.x64-for-netcore")
.IsDependentOn("pack-evolve")
.IsDependentOn("pack-evolve-tool");
RunTarget(target);