-
Notifications
You must be signed in to change notification settings - Fork 29
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
1 parent
cf55c0d
commit d6c0f7c
Showing
10 changed files
with
277 additions
and
9 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
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,180 @@ | ||
#addin "nuget:?package=Cake.Sonar&version=1.1.18" | ||
#addin "nuget:?package=Cake.FileHelpers&version=3.1.0" | ||
#addin "nuget:?package=Cake.Incubator&version=3.0.0" | ||
#tool "nuget:?package=MSBuild.SonarQube.Runner.Tool&version=4.3.1" | ||
|
||
|
||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
////////////////////////////////////////////////////////////////////// | ||
var target = Argument("target", "Default"); | ||
|
||
var configuration = EnvironmentVariable<string>("Build_Configuration", "Release"); | ||
|
||
var nugetToken = EnvironmentVariable<string>("Nuget_Token", default(string)); | ||
var sonarLogin = EnvironmentVariable<string>("Sonar_Token", default(string)); | ||
|
||
var packageVersion = EnvironmentVariable<string>("Version", default(string)); | ||
|
||
|
||
var version = EnvironmentVariable<string>("Build_Version", default(string)); | ||
|
||
var sonarPrKey = EnvironmentVariable<string>("Sonar_Pr_Key", default(string)); | ||
var sonarBranch = EnvironmentVariable<string>("Sonar_Branch", default(string)); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// PREPARATION | ||
////////////////////////////////////////////////////////////////////// | ||
var testOutputDir = Directory("./testoutput"); | ||
var publishOutputDir = Directory("./artifacts"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
DotNetCoreClean("./src"); | ||
}); | ||
|
||
Task("Restore") | ||
.Does(() => | ||
{ | ||
DotNetCoreRestore("./src"); | ||
}); | ||
|
||
Task("Build") | ||
.Does(() => | ||
{ | ||
var settings = new DotNetCoreBuildSettings | ||
{ | ||
Configuration = configuration, | ||
}; | ||
DotNetCoreBuild("./src", settings); | ||
}); | ||
|
||
Task("Publish") | ||
.Does(() => | ||
{ | ||
using(var process = StartAndReturnProcess("msbuild", | ||
new ProcessSettings{ Arguments = "./src/Snapshooter.sln /t:restore /p:configuration=" + configuration })) | ||
{ | ||
process.WaitForExit(); | ||
} | ||
using(var process = StartAndReturnProcess("msbuild", | ||
new ProcessSettings{ Arguments = "./src/Snapshooter.sln /t:build /p:configuration=" + configuration })) | ||
{ | ||
process.WaitForExit(); | ||
} | ||
using(var process = StartAndReturnProcess("msbuild", | ||
new ProcessSettings{ Arguments = "./src/Snapshooter.sln /t:pack /p:configuration=" + configuration + " /p:IncludeSource=true /p:IncludeSymbols=true" })) | ||
{ | ||
process.WaitForExit(); | ||
} | ||
}); | ||
|
||
Task("Push") | ||
.Does(() => | ||
{ | ||
var packages = GetFiles("./**/*.nupkg"); | ||
NuGetPush(packages, new NuGetPushSettings { | ||
Source = "https://api.nuget.org/v3/index.json", | ||
ApiKey = nugetToken | ||
}); | ||
}); | ||
|
||
Task("Tests") | ||
.Does(() => | ||
{ | ||
var buildSettings = new DotNetCoreBuildSettings | ||
{ | ||
Configuration = "Debug" | ||
}; | ||
int i = 0; | ||
var testSettings = new DotNetCoreTestSettings | ||
{ | ||
Configuration = "Debug", | ||
ResultsDirectory = $"./{testOutputDir}", | ||
Logger = "trx", | ||
NoRestore = true, | ||
NoBuild = true, | ||
ArgumentCustomization = args => args | ||
.Append("/p:CollectCoverage=true") | ||
.Append("/p:Exclude=[xunit.*]*") | ||
.Append("/p:CoverletOutputFormat=opencover") | ||
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/full_{i++}\" --blame") | ||
}; | ||
DotNetCoreBuild("./src", buildSettings); | ||
foreach(var file in GetFiles("./src/**/*.Tests.csproj")) | ||
{ | ||
DotNetCoreTest(file.FullPath, testSettings); | ||
} | ||
}); | ||
|
||
Task("SonarBegin") | ||
.Does(() => | ||
{ | ||
SonarBegin(new SonarBeginSettings | ||
{ | ||
Url = "https://sonarcloud.io", | ||
Login = sonarLogin, | ||
Key = "SwissLife-OSS_Snapshooter", | ||
Organization = "swisslife", | ||
VsTestReportsPath = "**/*.trx", | ||
OpenCoverReportsPath = "**/*.opencover.xml", | ||
Exclusions = "**/*.js,**/*.html,**/*.css,**/examples/**/*.*,**/benchmarks/**/*.*,**/src/Templates/**/*.*", | ||
Verbose = false, | ||
Version = packageVersion, | ||
ArgumentCustomization = args => { | ||
var a = args; | ||
if(!string.IsNullOrEmpty(sonarPrKey)) | ||
{ | ||
a = a.Append($"/d:sonar.pullrequest.key=\"{sonarPrKey}\""); | ||
a = a.Append($"/d:sonar.pullrequest.branch=\"{sonarBranch}\""); | ||
a = a.Append($"/d:sonar.pullrequest.base=\"master\""); | ||
a = a.Append($"/d:sonar.pullrequest.provider=\"github\""); | ||
a = a.Append($"/d:sonar.pullrequest.github.repository=\"SwissLife-OSS/Snapshooter\""); | ||
} | ||
return a; | ||
} | ||
}); | ||
}); | ||
|
||
Task("SonarEnd") | ||
.Does(() => | ||
{ | ||
SonarEnd(new SonarEndSettings | ||
{ | ||
Login = sonarLogin, | ||
}); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASK TARGETS | ||
////////////////////////////////////////////////////////////////////// | ||
Task("Default") | ||
.IsDependentOn("Tests"); | ||
|
||
Task("Sonar") | ||
.IsDependentOn("SonarBegin") | ||
.IsDependentOn("Tests") | ||
.IsDependentOn("SonarEnd"); | ||
|
||
Task("Release") | ||
.IsDependentOn("Sonar") | ||
.IsDependentOn("Publish"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// 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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<config> | ||
<add key="DefaultPushSource" value="https://api.nuget.org/v3/index.json" /> | ||
</config> | ||
<packageRestore> | ||
<add key="enabled" value="True" /> | ||
<add key="automatic" value="True" /> | ||
</packageRestore> | ||
<activePackageSource> | ||
<clear /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
</activePackageSource> | ||
<packageSources> | ||
<clear /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||
</packageSources> | ||
</configuration> |
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,12 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<CCSourceDirectory>$(MSBuildThisFileDirectory.TrimEnd('\').TrimEnd('/'))</CCSourceDirectory> | ||
<CCSettingsProps>$([System.IO.Path]::Combine($(CCSourceDirectory), 'Settings.props'))</CCSettingsProps> | ||
<CCVersionProps>$([System.IO.Path]::Combine($(CCSourceDirectory), 'Version.props'))</CCVersionProps> | ||
<CCPackageProps>$([System.IO.Path]::Combine($(CCSourceDirectory), 'Package.props'))</CCPackageProps> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(CCSettingsProps)" Condition="Exists('$(CCSettingsProps)')"/> | ||
<Import Project="$(CCVersionProps)" Condition="Exists('$(CCVersionProps)')"/> | ||
<Import Project="$(CCPackageProps)" Condition="Exists('$(CCPackageProps)')"/> | ||
</Project> |
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,6 @@ | ||
<Project> | ||
<Target Name="CheckCCPropertyFiles" BeforeTargets="Build"> | ||
<Error Text="Could not load version.props file." Condition="!Exists('$(CCVersionProps)')" /> | ||
<Error Text="Could not load package.props file." Condition="!Exists('$(CCPackageProps)')" /> | ||
</Target> | ||
</Project> |
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,30 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<Product>Snapshooter</Product> | ||
<Authors>Swiss Life authors and contributors</Authors> | ||
<Company>Swiss Life</Company> | ||
<Copyright>Copyright © 2018 Swiss Life</Copyright> | ||
<PackageLicenseUrl>https://github.com/SwissLife-OSS/Snapshooter/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/SwissLife-OSS/Snapshooter</PackageProjectUrl> | ||
<PackageReleaseNotes>Release notes: https://github.com/ChilliCream/SwissLife-OSS/Snapshooter/releases/$(Version)</PackageReleaseNotes> | ||
<PackageTags>XUnit SwissLife Snapshot</PackageTags> | ||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||
<!--PackageIconUrl>https://cdn.rawgit.com/ChilliCream/Snapshooter-logo/master/img/Snapshooter-signet.png</PackageIconUrl--> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<RepositoryUrl>https://github.com/SwissLife-OSS/Snapshooter.git</RepositoryUrl> | ||
<RepositoryType>GitHub</RepositoryType> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<LangVersion>7.2</LangVersion> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
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 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<Version Condition="$(Version) == ''">0.0.0</Version> | ||
</PropertyGroup> | ||
|
||
</Project> |