-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
184 additions
and
41 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 |
---|---|---|
@@ -1,33 +1,47 @@ | ||
version: 0.6.0.{build} | ||
version: 1.0.{build} | ||
|
||
branches: | ||
only: | ||
- master | ||
configuration: Release | ||
platform: Any CPU | ||
assembly_info: | ||
patch: true | ||
file: '**\AssemblyInfo.*' | ||
assembly_version: '{version}' | ||
assembly_file_version: '{version}' | ||
assembly_informational_version: '{version}' | ||
before_build: | ||
- nuget restore NyBus.sln | ||
- nuget restore packages.config | ||
build: | ||
project: NyBus.sln | ||
publish_nuget: true | ||
include_nuget_references: true | ||
verbosity: minimal | ||
- master | ||
|
||
only_commits: | ||
files: | ||
- src/ | ||
|
||
max_jobs: 1 | ||
|
||
image: Visual Studio 2017 | ||
|
||
clone_folder: c:\projects\nybus | ||
|
||
environment: | ||
COVERALLS_REPO_TOKEN: | ||
secure: FLG2WTxc1Gvrikrvj/UXnb9IAklUhPKGYV5pxOzlwsOWGQBiiEigRnyWCvCc2Zga | ||
test: | ||
assemblies: '**\Tests.*.dll' | ||
artifacts: | ||
- path: report.zip | ||
after_test: | ||
- packages\OpenCover.4.6.166\tools\OpenCover.Console.exe -register:user -filter:"+[Nybus.*]*" -target:".\packages\NUnit.Runners.2.6.4\tools\nunit-console.exe" -targetargs:"/process:multiple /noshadow /domain:multiple Nybus.nunit" -output:coverage.xml | ||
- packages\coveralls.io.1.3.4\tools\coveralls.net.exe --opencover coverage.xml | ||
- packages\ReportGenerator.2.3.1.0\tools\ReportGenerator.exe -reports:coverage.xml -targetdir:Reports | ||
- 7z a report.zip Reports | ||
|
||
cache: | ||
- '%LocalAppData%\NuGet\v3-cache' | ||
|
||
install: | ||
|
||
nuget: | ||
account_feed: false | ||
project_feed: false | ||
disable_publish_on_pr: true | ||
|
||
before_build: | ||
- cmd: dotnet tool install -g Cake.Tool --version 0.30.0 | ||
- cmd: dotnet tool install coveralls.net --tool-path tools | ||
|
||
build_script: | ||
- cmd: dotnet cake --target=Full | ||
|
||
after_build: | ||
- ps: .\tools\csmacnz.coveralls.exe --reportgenerator -i .\outputs\tests\report --repoToken $env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID | ||
|
||
artifacts: | ||
- path: outputs\*.nupkg | ||
name: packages | ||
- path: outputs\tests\coverage.xml | ||
name: dotCover coverage summary | ||
- path: outputs\tests\*.trx | ||
name: test results |
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,48 +1,139 @@ | ||
//#tool "nuget:https://www.myget.org/F/opencover/api/v3/index.json?package=OpenCover&version=4.6.831-rc" | ||
#tool "nuget:?package=ReportGenerator&version=4.0.5" | ||
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools&version=2018.3.1" | ||
|
||
#load "./build/types.cake" | ||
|
||
var target = Argument("Target", "Test"); | ||
Setup<BuildState>(context => | ||
{ | ||
var state = new BuildState | ||
{ | ||
Parameters = new BuildParameters | ||
{ | ||
CoverageTools = CoverageTool.OpenCover | CoverageTool.DotCover | ||
}, | ||
Paths = new BuildPaths | ||
{ | ||
SolutionFile = MakeAbsolute(File("./Nybus.sln")) | ||
} | ||
}; | ||
CleanDirectory(state.Paths.OutputFolder); | ||
return state; | ||
}); | ||
Task("Restore") | ||
.Does(() => | ||
.Does<BuildState>(state => | ||
{ | ||
DotNetCoreRestore(); | ||
var settings = new DotNetCoreRestoreSettings | ||
{ | ||
}; | ||
DotNetCoreRestore(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Restore") | ||
.Does(()=> | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCoreBuildSettings | ||
{ | ||
Configuration = "Debug", | ||
NoRestore = true | ||
}; | ||
DotNetCoreBuild("./Nybus.sln", settings); | ||
DotNetCoreBuild(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
Task("Test") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCoreTestSettings | ||
var projectFiles = GetFiles($"{state.Paths.TestFolder}/**/*.csproj"); | ||
bool success = true; | ||
foreach (var file in projectFiles) | ||
{ | ||
NoRestore = true, | ||
NoBuild = true | ||
}; | ||
try | ||
{ | ||
Information($"Testing {file.GetFilenameWithoutExtension()}"); | ||
DotNetCoreTest("./Nybus.sln", settings); | ||
var testResultFile = state.Paths.TestOutputFolder.CombineWithFilePath(file.GetFilenameWithoutExtension() + ".trx"); | ||
var coverageResultFile = state.Paths.TestOutputFolder.CombineWithFilePath(file.GetFilenameWithoutExtension() + ".dvcr"); | ||
var projectFile = MakeAbsolute(file).ToString(); | ||
var dotCoverSettings = new DotCoverCoverSettings() | ||
.WithFilter("+:Nybus*") | ||
.WithFilter("-:Tests.*"); | ||
var settings = new DotNetCoreTestSettings | ||
{ | ||
NoBuild = true, | ||
NoRestore = true, | ||
Logger = $"trx;LogFileName={testResultFile.FullPath}" | ||
}; | ||
DotCoverCover(context => | ||
{ | ||
context.DotNetCoreTest(projectFile, settings); | ||
}, coverageResultFile, dotCoverSettings); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Error($"There was an error while executing the tests: {file.GetFilenameWithoutExtension()}", ex); | ||
success = false; | ||
} | ||
Information(""); | ||
} | ||
if (!success) | ||
{ | ||
throw new CakeException("There was an error while executing the tests"); | ||
} | ||
Information("Merging coverage files"); | ||
var coverageFiles = GetFiles($"{state.Paths.TestOutputFolder}/*.dvcr"); | ||
DotCoverMerge(coverageFiles, state.Paths.DotCoverOutputFile); | ||
DeleteFiles(coverageFiles); | ||
Information("Generating dotCover XML report"); | ||
var xmlFilePath = state.Paths.TestOutputFolder.CombineWithFilePath("coverage.xml"); | ||
DotCoverReport(state.Paths.DotCoverOutputFile, xmlFilePath, new DotCoverReportSettings | ||
{ | ||
ReportType = DotCoverReportType.DetailedXML | ||
}); | ||
Information("Executing ReportGenerator to generate HTML report"); | ||
ReportGenerator(xmlFilePath, state.Paths.ReportFolder, new ReportGeneratorSettings { | ||
ReportTypes = new[]{ReportGeneratorReportType.Html, ReportGeneratorReportType.Xml} | ||
}); | ||
}); | ||
|
||
Task("Pack") | ||
.IsDependentOn("Test") | ||
.Does(() => | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCorePackSettings | ||
{ | ||
Configuration = "Release", | ||
NoRestore = true | ||
NoRestore = true, | ||
OutputDirectory = state.Paths.OutputFolder | ||
}; | ||
DotNetCorePack("./Nybus.sln", settings); | ||
DotNetCorePack(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
RunTarget(target); | ||
Task("Full") | ||
.IsDependentOn("Pack") | ||
.IsDependentOn("Test") | ||
.IsDependentOn("Build") | ||
.IsDependentOn("Restore"); | ||
|
||
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,38 @@ | ||
public class BuildState | ||
{ | ||
public BuildParameters Parameters { get; set; } | ||
|
||
public BuildPaths Paths { get; set; } | ||
} | ||
|
||
public class BuildParameters | ||
{ | ||
|
||
public CoverageTool CoverageTools { get; set; } | ||
} | ||
|
||
public class BuildPaths | ||
{ | ||
public FilePath SolutionFile { get; set; } | ||
|
||
public DirectoryPath SolutionFolder => SolutionFile.GetDirectory(); | ||
|
||
public DirectoryPath TestFolder => SolutionFolder.Combine("tests"); | ||
|
||
public DirectoryPath OutputFolder => SolutionFolder.Combine("outputs"); | ||
|
||
public DirectoryPath TestOutputFolder => OutputFolder.Combine("tests"); | ||
|
||
public DirectoryPath ReportFolder => TestOutputFolder.Combine("report"); | ||
|
||
public FilePath DotCoverOutputFile => TestOutputFolder.CombineWithFilePath("coverage.dcvr"); | ||
|
||
public FilePath OpenCoverResultFile => OutputFolder.CombineWithFilePath("OpenCover.xml"); | ||
} | ||
|
||
[Flags] | ||
public enum CoverageTool | ||
{ | ||
OpenCover = 1, | ||
DotCover = 2 | ||
} |