-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapters for - `IHostedService` - `IServiceProvider` and `IScope` - `ILoggerFactory` and `ILogger` Extension methods to enrich `IServiceCollection`
- Loading branch information
Showing
11 changed files
with
490 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
next-version: 1.0.0 | ||
mode: ContinuousDeployment | ||
continuous-delivery-fallback-tag: preview | ||
|
||
branches: | ||
develop: | ||
tag: vnext |
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,51 @@ | ||
max_jobs: 1 | ||
|
||
image: Visual Studio 2017 | ||
|
||
environment: | ||
COVERALLS_REPO_TOKEN: | ||
secure: FLG2WTxc1Gvrikrvj/UXnb9IAklUhPKGYV5pxOzlwsOWGQBiiEigRnyWCvCc2Zga | ||
MYGET_TOKEN: | ||
secure: yP12k1vrHJyValU1UWnW3NySjKfXlRomR8p4qqmYs26FDztsGMlCQeT5jdCVHlz6 | ||
|
||
cache: | ||
- '%LocalAppData%\NuGet\v3-cache' | ||
|
||
nuget: | ||
account_feed: false | ||
project_feed: false | ||
disable_publish_on_pr: true | ||
|
||
install: | ||
- cmd: dotnet tool install -g Cake.Tool --version 0.33.0 | ||
- cmd: dotnet tool install coveralls.net --tool-path tools | ||
|
||
build_script: | ||
- cmd: dotnet cake --target=Full | ||
|
||
|
||
# after_build: | ||
# - ps: if ($env:COVERALLS_REPO_TOKEN -ne $null) { .\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 } | ||
|
||
test: off | ||
|
||
artifacts: | ||
- path: outputs\*.nupkg | ||
name: packages | ||
- path: outputs\*.snupkg | ||
name: symbols | ||
- path: outputs\tests\report | ||
name: report | ||
type: zip | ||
|
||
deploy: | ||
- provider: NuGet | ||
server: https://www.myget.org/F/nybus/api/v2/package | ||
api_key: | ||
secure: yP12k1vrHJyValU1UWnW3NySjKfXlRomR8p4qqmYs26FDztsGMlCQeT5jdCVHlz6 | ||
artifact: packages | ||
- provider: Environment | ||
name: NuGet | ||
on: | ||
branch: master | ||
appveyor_repo_tag: true |
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,244 @@ | ||
#tool "nuget:?package=ReportGenerator&version=4.0.5" | ||
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools&version=2018.3.1" | ||
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0" | ||
|
||
#load "./build/types.cake" | ||
|
||
|
||
var target = Argument("Target", "Full"); | ||
|
||
Setup<BuildState>(_ => | ||
{ | ||
var state = new BuildState | ||
{ | ||
Paths = new BuildPaths | ||
{ | ||
SolutionFile = MakeAbsolute(File("./NybusLegacyAdapter.sln")) | ||
} | ||
}; | ||
|
||
CleanDirectory(state.Paths.OutputFolder); | ||
|
||
return state; | ||
}); | ||
|
||
Task("Version") | ||
.Does<BuildState>(state => | ||
{ | ||
var version = GitVersion(); | ||
|
||
var packageVersion = version.SemVer; | ||
var buildVersion = $"{version.FullSemVer}+{DateTimeOffset.UtcNow:yyyyMMddHHmmss}"; | ||
|
||
state.Version = new VersionInfo | ||
{ | ||
PackageVersion = packageVersion, | ||
BuildVersion = buildVersion | ||
}; | ||
|
||
|
||
Information($"Package version: {state.Version.PackageVersion}"); | ||
Information($"Build version: {state.Version.BuildVersion}"); | ||
|
||
if (BuildSystem.IsRunningOnAppVeyor) | ||
{ | ||
AppVeyor.UpdateBuildVersion(state.Version.BuildVersion); | ||
} | ||
}); | ||
|
||
Task("Restore") | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCoreRestoreSettings | ||
{ | ||
}; | ||
DotNetCoreRestore(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Restore") | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCoreBuildSettings | ||
{ | ||
Configuration = "Debug", | ||
NoRestore = true | ||
}; | ||
DotNetCoreBuild(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
Task("RunTests") | ||
.IsDependentOn("Build") | ||
.Does<BuildState>(state => | ||
{ | ||
var projectFiles = GetFiles($"{state.Paths.TestFolder}/**/Tests.*.csproj"); | ||
var frameworks = new[]{"netcoreapp2.2", "net472"}; | ||
bool success = true; | ||
foreach (var file in projectFiles) | ||
{ | ||
var targetFrameworks = GetTargetFrameworks(file); | ||
foreach (var framework in targetFrameworks) | ||
{ | ||
var frameworkFriendlyName = framework.Replace(".", "-"); | ||
try | ||
{ | ||
Information($"Testing {file.GetFilenameWithoutExtension()} ({framework})"); | ||
var testResultFile = state.Paths.TestOutputFolder.CombineWithFilePath($"{file.GetFilenameWithoutExtension()}-{frameworkFriendlyName}.trx"); | ||
var coverageResultFile = state.Paths.TestOutputFolder.CombineWithFilePath($"{file.GetFilenameWithoutExtension()}-{frameworkFriendlyName}.dcvr"); | ||
var projectFile = MakeAbsolute(file).ToString(); | ||
var dotCoverSettings = new DotCoverCoverSettings() | ||
.WithFilter("+:Nybus*") | ||
.WithFilter("-:Tests*") | ||
.WithFilter("-:TestUtils"); | ||
var settings = new DotNetCoreTestSettings | ||
{ | ||
NoBuild = true, | ||
NoRestore = true, | ||
Logger = $"trx;LogFileName={testResultFile.FullPath}", | ||
Filter = "TestCategory!=External", | ||
Framework = framework | ||
}; | ||
DotCoverCover(c => c.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"); | ||
} | ||
string[] GetTargetFrameworks(FilePath file) | ||
{ | ||
XmlPeekSettings settings = new XmlPeekSettings | ||
{ | ||
SuppressWarning = true | ||
}; | ||
return (XmlPeek(file, "/Project/PropertyGroup/TargetFrameworks", settings) ?? XmlPeek(file, "/Project/PropertyGroup/TargetFramework", settings)).Split(";"); | ||
} | ||
}); | ||
|
||
Task("MergeCoverageResults") | ||
.IsDependentOn("RunTests") | ||
.Does<BuildState>(state => | ||
{ | ||
Information("Merging coverage files"); | ||
var coverageFiles = GetFiles($"{state.Paths.TestOutputFolder}/*.dcvr"); | ||
DotCoverMerge(coverageFiles, state.Paths.DotCoverOutputFile); | ||
DeleteFiles(coverageFiles); | ||
}); | ||
|
||
Task("GenerateXmlReport") | ||
.IsDependentOn("MergeCoverageResults") | ||
.Does<BuildState>(state => | ||
{ | ||
Information("Generating dotCover XML report"); | ||
DotCoverReport(state.Paths.DotCoverOutputFile, state.Paths.DotCoverOutputFileXml, new DotCoverReportSettings | ||
{ | ||
ReportType = DotCoverReportType.DetailedXML | ||
}); | ||
}); | ||
|
||
Task("ExportReport") | ||
.IsDependentOn("GenerateXmlReport") | ||
.Does<BuildState>(state => | ||
{ | ||
Information("Executing ReportGenerator to generate HTML report"); | ||
ReportGenerator(state.Paths.DotCoverOutputFileXml, state.Paths.ReportFolder, new ReportGeneratorSettings { | ||
ReportTypes = new[]{ReportGeneratorReportType.Html, ReportGeneratorReportType.Xml} | ||
}); | ||
}); | ||
|
||
Task("UploadTestsToAppVeyor") | ||
.IsDependentOn("RunTests") | ||
.WithCriteria(BuildSystem.IsRunningOnAppVeyor) | ||
.Does<BuildState>(state => | ||
{ | ||
Information("Uploading test result files to AppVeyor"); | ||
var testResultFiles = GetFiles($"{state.Paths.TestOutputFolder}/*.trx"); | ||
foreach (var file in testResultFiles) | ||
{ | ||
Information($"\tUploading {file.GetFilename()}"); | ||
AppVeyor.UploadTestResults(file, AppVeyorTestResultsType.MSTest); | ||
} | ||
}); | ||
|
||
Task("Test") | ||
.IsDependentOn("RunTests") | ||
.IsDependentOn("MergeCoverageResults") | ||
.IsDependentOn("GenerateXmlReport") | ||
.IsDependentOn("ExportReport") | ||
.IsDependentOn("UploadTestsToAppVeyor"); | ||
|
||
Task("PackLibraries") | ||
.IsDependentOn("Version") | ||
.IsDependentOn("Restore") | ||
.Does<BuildState>(state => | ||
{ | ||
var settings = new DotNetCorePackSettings | ||
{ | ||
Configuration = "Release", | ||
NoRestore = true, | ||
OutputDirectory = state.Paths.OutputFolder, | ||
IncludeSymbols = true, | ||
ArgumentCustomization = args => args.Append($"-p:SymbolPackageFormat=snupkg -p:Version={state.Version.PackageVersion}") | ||
}; | ||
DotNetCorePack(state.Paths.SolutionFile.ToString(), settings); | ||
}); | ||
|
||
Task("Pack") | ||
.IsDependentOn("PackLibraries"); | ||
|
||
Task("UploadPackagesToAppVeyor") | ||
.IsDependentOn("Pack") | ||
.WithCriteria(BuildSystem.IsRunningOnAppVeyor) | ||
.Does<BuildState>(state => | ||
{ | ||
Information("Uploading packages"); | ||
var files = GetFiles($"{state.Paths.OutputFolder}/*.nukpg"); | ||
foreach (var file in files) | ||
{ | ||
Information($"\tUploading {file.GetFilename()}"); | ||
AppVeyor.UploadArtifact(file, new AppVeyorUploadArtifactsSettings { | ||
ArtifactType = AppVeyorUploadArtifactType.NuGetPackage, | ||
DeploymentName = "NuGet" | ||
}); | ||
} | ||
}); | ||
|
||
Task("Push") | ||
.IsDependentOn("UploadPackagesToAppVeyor"); | ||
|
||
Task("Full") | ||
.IsDependentOn("Version") | ||
.IsDependentOn("Restore") | ||
.IsDependentOn("Build") | ||
.IsDependentOn("Test") | ||
.IsDependentOn("Pack") | ||
.IsDependentOn("Push"); | ||
|
||
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,46 @@ | ||
public class BuildState | ||
{ | ||
public VersionInfo Version { get; set; } | ||
|
||
public BuildPaths Paths { get; set; } | ||
} | ||
|
||
public class BuildParameters | ||
{ | ||
|
||
} | ||
|
||
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 DotCoverOutputFileXml => TestOutputFolder.CombineWithFilePath("coverage.xml"); | ||
|
||
public FilePath OpenCoverResultFile => OutputFolder.CombineWithFilePath("OpenCover.xml"); | ||
} | ||
|
||
public class VersionInfo | ||
{ | ||
public string PackageVersion { get; set; } | ||
|
||
public string BuildVersion {get; set; } | ||
} | ||
|
||
[Flags] | ||
public enum CoverageTool | ||
{ | ||
OpenCover = 1, | ||
DotCover = 2 | ||
} |
Oops, something went wrong.