forked from cake-contrib/Cake.Codecov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.cake
60 lines (50 loc) · 2.03 KB
/
setup.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
#tool nuget:?package=GitVersion.CommandLine
#tool nuget:?package=OpenCover&version=4.6.519
#tool nuget:?package=Codecov&version=1.0.3
#addin nuget:?package=Cake.Figlet&version=1.0.0
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
Setup(context =>
{
Information(Figlet("Cake.Codecov"));
});
Task("Clean").Does(() =>
{
CleanDirectories(new[]{"./Source/Cake.Codecov/bin","./Source/Cake.Codecov.Tests/bin"});
});
Task("Restore").IsDependentOn("Clean").Does(() =>
{
DotNetCoreRestore("./Source");
});
Task("Build").IsDependentOn("Restore").Does(() =>
{
DotNetCoreBuild("./Source", new DotNetCoreBuildSettings{Configuration = configuration});
});
Task("Tests").IsDependentOn("Build").Does(() =>
{
OpenCover(tool => tool.DotNetCoreTest("./Source/Cake.Codecov.Tests/Cake.Codecov.Tests.csproj"), new FilePath("./Source/Cake.Codecov/bin/coverage.xml"), new OpenCoverSettings { OldStyle = true }.WithFilter("+[Cake.Codecov]*"));
});
Task("Coverage").IsDependentOn("Tests").WithCriteria(AppVeyor.IsRunningOnAppVeyor).Does(() =>
{
// Using GetFiles instead of File just so we don't need to make a call to MakeAbsolute.
var file = GetFiles("./Source/**/net46/Cake.Codecov.dll").First();
var tool = Context.Tools.Resolve("Codecov.exe");
var reportFile = GetFiles("./Source/**/coverage.xml").First();
Information("Loading built addin from: {0}", file);
Information("Using Codecov tool from: {0}", tool);
Information("Using Coverage report from: {0}", reportFile);
CakeExecuteExpression(
string.Format(
@"#reference ""{0}""
Codecov(new CodecovSettings {{ ToolPath = ""{1}"", Files = new[] {{ ""{2}"" }}, Root = ""{3}"" }});
",
file, tool, reportFile, Directory("./").Path.MakeAbsolute(Context.Environment))
);
});
Task("Pack").IsDependentOn("Coverage").Does(() =>
{
var version = GitVersion();
DotNetCorePack("./Source/Cake.Codecov",new DotNetCorePackSettings{VersionSuffix = version.MajorMinorPatch, Configuration = configuration});
});
Task("Default").IsDependentOn("Pack");
RunTarget(target);