This repository has been archived by the owner on Apr 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.cake
107 lines (90 loc) · 2.8 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
#tool "xunit.runner.console&version=2.2.0"
#addin "Cake.Docker&version=0.10.0"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// GLOBALS
//////////////////////////////////////////////////////////////////////
const string sln = "./evlog.sln";
readonly string testDbContainerName = $"evlogtesdb-{Guid.NewGuid()}";
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("build")
.Does(() =>
{
DotNetCoreBuild(sln,
new DotNetCoreBuildSettings
{
Configuration = configuration
}
);
});
Task("startdb")
.Does(async () =>
{
DockerRun(settings: new DockerContainerRunSettings {
Name = testDbContainerName,
Env = new[] { "MYSQL_ROOT_PASSWORD=Pa5sw0rd" },
Publish = new[] { "3307:3306" },
Detach = true,
Rm = true
},
image: "mysql:8.0.16",
command: null, args: null);
await System.Threading.Tasks.Task.Delay(10_000); // wait for 10 seconds
});
Task("stopdb")
.Does(() =>
{
DockerStop(testDbContainerName);
});
Task("xunit")
.IsDependentOn("startdb")
.IsDependentOn("build")
.Does(() =>
{
var projects = GetFiles("./tests/**/*.csproj");
foreach(var project in projects)
{
DotNetCoreTest(
project.FullPath,
new DotNetCoreTestSettings()
{
Configuration = configuration,
NoRestore = true,
NoBuild = true,
ResultsDirectory = project.GetDirectory(),
ArgumentCustomization = args => args.Append("--logger:trx;LogFileName=test_result.xml")
}
);
}
RunTarget("stopdb");
});
Task("docker-build")
.Does(() =>
{
const string DOCKERFILE = "Dockerfile";
const string CONTEXT = ".";
const string REPOSITORY = "gldraphael/evlog";
DockerBuild(new DockerImageBuildSettings {
Tag = new string[] { REPOSITORY },
File = DOCKERFILE
}, CONTEXT);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("xunit");
Task("azure-pipelines")
.IsDependentOn("xunit");
Task("travis")
.IsDependentOn("docker-build");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);