-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cake for all build related and fix code coverage
- Loading branch information
Showing
6 changed files
with
150 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,4 +285,9 @@ tools/** | |
*.btp.cs | ||
*.btm.cs | ||
*.odx.cs | ||
*.xsd.cs | ||
*.xsd.cs | ||
|
||
|
||
|
||
|
||
/coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"shadowCopy": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,144 @@ | ||
var target = Argument("target", "Default"); | ||
// Install addins. | ||
#addin "nuget:?package=Cake.Coveralls&version=0.5.0" | ||
|
||
Task("Set-Build-Version") | ||
// Install tools. | ||
#tool "nuget:?package=OpenCover&version=4.6.519" | ||
#tool "nuget:?package=coveralls.io&version=1.3.4" | ||
#tool "nuget:?package=xunit.runner.console&version=2.2.0" | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument<string>("target", "Default"); | ||
var configuration = Argument<string>("configuration", "Release"); | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// GLOBAL VARIABLES | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var libraryName = "BencodeNET"; | ||
|
||
var sourceFolder = "./"; | ||
|
||
var projectFile = "./BencodeNET/BencodeNET.csproj"; | ||
|
||
var testProjectFile = "./BencodeNET.Tests/BencodeNET.Tests.csproj"; | ||
var codeCoverageOutput = "coverage.xml"; | ||
var codeCoverageFilter = "+[*]* -[*.Tests]*"; | ||
|
||
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString(); | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// SETUP / TEARDOWN | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Setup(context => | ||
{ | ||
Information($"Building using version {cakeVersion} of Cake"); | ||
}); | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TASK DEFINITIONS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Update-Build-Version") | ||
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor) | ||
.Does(() => | ||
{ | ||
var projectFile = "./BencodeNET/BencodeNET.csproj"; | ||
var versionPeekXpath = "/Project/PropertyGroup/Version/text()"; | ||
var versionPokeXpath = "/Project/PropertyGroup/Version"; | ||
var buildNumber = AppVeyor.Environment.Build.Number; | ||
var version = XmlPeek(projectFile, versionPeekXpath); | ||
Information("AppVeyor build version is " + AppVeyor.Environment.Build.Version); | ||
Information("Project version is " + version); | ||
var parts = version.Split('.'); | ||
version = string.Join(".", parts[0], parts[1], buildNumber); | ||
Information("Changing versions to " + version); | ||
AppVeyor.UpdateBuildVersion(version); | ||
XmlPoke(projectFile, versionPokeXpath, version); | ||
}); | ||
|
||
var buildNumber = 0; | ||
Task("Restore-NuGet-Packages") | ||
.Does(() => | ||
{ | ||
DotNetCoreRestore(); | ||
}); | ||
|
||
if (BuildSystem.IsRunningOnAppVeyor) | ||
Task("Build") | ||
.IsDependentOn("Restore-NuGet-Packages") | ||
.Does(() => | ||
{ | ||
DotNetCoreBuild(sourceFolder + libraryName + ".sln", new DotNetCoreBuildSettings | ||
{ | ||
buildNumber = AppVeyor.Environment.Build.Number; | ||
} | ||
Configuration = configuration | ||
}); | ||
}); | ||
|
||
version = string.Join(".", parts[0], parts[1], buildNumber); | ||
Task("Run-Unit-Tests") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
DotNetCoreTest(testProjectFile, new DotNetCoreTestSettings | ||
{ | ||
NoBuild = true, | ||
Configuration = configuration | ||
}); | ||
}); | ||
|
||
if (BuildSystem.IsRunningOnAppVeyor) | ||
Task("Run-Code-Coverage") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
Action<ICakeContext> testAction = ctx => ctx.DotNetCoreTest(testProjectFile, new DotNetCoreTestSettings | ||
{ | ||
AppVeyor.UpdateBuildVersion(version); | ||
Information("Updated AppVeyor build version to " + version); | ||
} | ||
NoBuild = true, | ||
Configuration = configuration | ||
}); | ||
XmlPoke(projectFile, versionPokeXpath, version); | ||
Information("Set project version to " + version); | ||
OpenCover(testAction, | ||
codeCoverageOutput, | ||
new OpenCoverSettings | ||
{ | ||
OldStyle = true, | ||
SkipAutoProps = true, | ||
MergeOutput = false | ||
} | ||
.WithFilter(codeCoverageFilter) | ||
); | ||
}); | ||
|
||
Task("Upload-Coverage-Result") | ||
.Does(() => | ||
{ | ||
CoverallsIo(codeCoverageOutput); | ||
}); | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TARGETS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Task("AppVeyor") | ||
.IsDependentOn("Update-Build-Version") | ||
.IsDependentOn("Run-Code-Coverage") | ||
.IsDependentOn("Upload-Coverage-Result"); | ||
|
||
Task("Default") | ||
.IsDependentOn("Set-Build-Version"); | ||
.IsDependentOn("AppVeyor"); | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
RunTarget(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake" version="0.21.1" /> | ||
</packages> |