Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

housekeeping: Add azure devops pipelines scripts #29

Merged
merged 8 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,10 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

# VS Code configurations
.vscode/

tools/

punchclock.binlog
27 changes: 27 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<PropertyGroup>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
</ItemGroup>
</When>
</Choose>
<!--
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version=" 2.1.65" PrivateAssets="all" />
</ItemGroup> -->

<PropertyGroup>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
</PropertyGroup>
</Project>
4 changes: 3 additions & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
next-version: 3.0.0
assembly-versioning-scheme: None
branches:
master:
Expand All @@ -6,7 +7,8 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
dev(elop)?(ment)?$:
develop:
regex: dev(elop)?(ment)?$
mode: ContinuousDeployment
tag: alpha
increment: Minor
Expand Down
194 changes: 91 additions & 103 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
//////////////////////////////////////////////////////////////////////
// ADDINS
//////////////////////////////////////////////////////////////////////

#addin "Cake.FileHelpers"
#addin "Cake.Coveralls"
#addin "Cake.PinNuGetDependency"

//////////////////////////////////////////////////////////////////////
// TOOLS
//////////////////////////////////////////////////////////////////////

#tool "GitReleaseManager"
#tool "GitVersion.CommandLine"
#tool "coveralls.io"
#tool "OpenCover"
#tool "ReportGenerator"
#tool nuget:?package=vswhere
#tool "nuget:?package=vswhere"
#tool "nuget:?package=OpenCover"
#tool "nuget:?package=ReportGenerator"
#tool "nuget:?package=xunit.runner.console"

#addin nuget:?package=Cake.Coverlet

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand All @@ -36,40 +30,46 @@ var treatWarningsAsErrors = false;

// Build configuration
var local = BuildSystem.IsLocalBuild;
var isRunningOnUnix = IsRunningOnUnix();
var isRunningOnWindows = IsRunningOnWindows();
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var isRepository = StringComparer.OrdinalIgnoreCase.Equals("paulcbetts/punchclock", AppVeyor.Environment.Repository.Name);

var isDevelopBranch = StringComparer.OrdinalIgnoreCase.Equals("develop", AppVeyor.Environment.Repository.Branch);
var isRepository = StringComparer.OrdinalIgnoreCase.Equals("reactiveui/punchclock", AppVeyor.Environment.Repository.Name);
var isReleaseBranch = StringComparer.OrdinalIgnoreCase.Equals("master", AppVeyor.Environment.Repository.Branch);
var isTagged = AppVeyor.Environment.Repository.Tag.IsTag;

var githubOwner = "paulcbetts";
var githubOwner = "reactiveui";
var githubRepository = "punchclock";
var githubUrl = string.Format("https://github.com/{0}/{1}", githubOwner, githubRepository);
var msBuildPath = VSWhereLatest().CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");

//var msBuildPath = VSWhereLatest().CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");

// Version
var gitVersion = GitVersion();
var majorMinorPatch = gitVersion.MajorMinorPatch;
var informationalVersion = gitVersion.InformationalVersion;
var nugetVersion = gitVersion.NuGetVersion;
var buildVersion = gitVersion.FullBuildMetaData;

// Artifacts
var artifactDirectory = "./artifacts/";
var testsArtifactDirectory = artifactDirectory + "tests/";
var packagesArtifactDirectory = artifactDirectory + "packages/";
var packageWhitelist = new[] { "Punchclock" };
var testCoverageOutputFile = artifactDirectory + "OpenCover.xml";

// Macros
Action Abort = () => { throw new Exception("a non-recoverable fatal error occurred."); };
// Test coverage files.
var testCoverageOutputFile = testsArtifactDirectory + "OpenCover.xml";

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup((context) =>
{
Information("Building version {0} of Punchclock. (isTagged: {1}) Nuget Version {2}", informationalVersion, isTagged, nugetVersion);
Information("Building version {0} of punchclock. (isTagged: {1})", informationalVersion, isTagged);

CleanDirectories(artifactDirectory);
CreateDirectory(artifactDirectory);
CreateDirectory(testsArtifactDirectory);
CreateDirectory(packagesArtifactDirectory);
});

Teardown((context) =>
Expand All @@ -78,112 +78,102 @@ Teardown((context) =>
});

//////////////////////////////////////////////////////////////////////
// TASKS
// HELPER METHODS
//////////////////////////////////////////////////////////////////////
Task("UpdateAppVeyorBuildNumber")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
Action<string, string, string, bool> Build = (projectFile, packageOutputPath, configuration, forceUseFullDebugType) =>
{
AppVeyor.UpdateBuildVersion(buildVersion);

}).ReportError(exception =>
{
// When a build starts, the initial identifier is an auto-incremented value supplied by AppVeyor.
// As part of the build script, this version in AppVeyor is changed to be the version obtained from
// GitVersion. This identifier is purely cosmetic and is used by the core team to correlate a build
// with the pull-request. In some circumstances, such as restarting a failed/cancelled build the
// identifier in AppVeyor will be already updated and default behaviour is to throw an
// exception/cancel the build when in fact it is safe to swallow.
// See https://github.com/reactiveui/ReactiveUI/issues/1262

Warning("Build with version {0} already exists.", buildVersion);
});
Information("Building {0} using {1}, forceUseFullDebugType = {2}", projectFile, "", forceUseFullDebugType);


Task("Build")
.Does (() =>
{
Action<string> build = (solution) =>
{
Information("Building {0}", solution);


MSBuild(solution, new MSBuildSettings() {
ToolPath= msBuildPath
var msBuildSettings = new MSBuildSettings() {
//ToolPath = msBuildPath,
ArgumentCustomization = args => args.Append("/bl:punchclock.binlog"),
MaxCpuCount = 0,
Restore = true
}
.WithTarget("restore;build;pack")
.WithProperty("PackageOutputPath", MakeAbsolute(Directory(artifactDirectory)).ToString())
.WithProperty("PackageOutputPath", MakeAbsolute(Directory(packagesArtifactDirectory)).ToString())
.WithProperty("TreatWarningsAsErrors", treatWarningsAsErrors.ToString())
.SetConfiguration("Release")
.SetConfiguration(configuration)
// Due to https://github.com/NuGet/Home/issues/4790 and https://github.com/NuGet/Home/issues/4337 we
// have to pass a version explicitly
.WithProperty("Version", nugetVersion.ToString())
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false));

};
.UseToolVersion(MSBuildToolVersion.VS2017)
.SetNodeReuse(false);

build("./src/Punchclock.sln");
});

Task("RunUnitTests")
.IsDependentOn("Build")
.Does(() =>
{

if (forceUseFullDebugType)
{
msBuildSettings = msBuildSettings.WithProperty("DebugType", "full");
}

Action<ICakeContext> testAction = tool => {
if (!string.IsNullOrWhiteSpace(packageOutputPath))
{
msBuildSettings = msBuildSettings.WithProperty("PackageOutputPath", MakeAbsolute(Directory(packageOutputPath)).ToString().Quote());
}

tool.XUnit2("./src/Punchclock.Tests/bin/Release/**/*.Tests.dll", new XUnit2Settings {
OutputDirectory = artifactDirectory,
XmlReportV1 = true,
NoAppDomain = false
});
MSBuild(projectFile, msBuildSettings);
};

OpenCover(testAction,
testCoverageOutputFile,
new OpenCoverSettings {
ReturnTargetCodeOffset = 0,
ArgumentCustomization = args => args.Append("-mergeoutput")
}
.WithFilter("+[*]* -[*.Tests*]* -[Splat*]*")
.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
.ExcludeByFile("*/*Designer.cs;*/*.g.cs;*/*.g.i.cs;*splat/splat*"));
Action Clean = () =>
{
CleanDirectories(string.Format("./src/**/obj/{0}", "Release"));
CleanDirectories(string.Format("./src/**/bin/{0}", "Release"));
CleanDirectories(string.Format("./src/**/obj/{0}", "Debug"));
CleanDirectories(string.Format("./src/**/bin/{0}", "Debug"));
};

ReportGenerator(testCoverageOutputFile, artifactDirectory);
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

Task("Package")
.IsDependentOn("Build")
.IsDependentOn("RunUnitTests")
.IsDependentOn("PinNuGetDependencies")
Task("Clean")
.Does(() =>
{
Clean();
});

Task("Build")
.IsDependentOn("Clean")
.Does (() =>
{

Build("./src/punchclock.sln", null, "Release", true);
});

Task("PinNuGetDependencies")
.Does (() =>
Task("RunUnitTests")
.IsDependentOn("Build")
.Does(() =>
{
// only pin whitelisted packages.
foreach(var package in packageWhitelist)
{
// only pin the package which was created during this build run.
var packagePath = artifactDirectory + File(string.Concat(package, ".", nugetVersion, ".nupkg"));
var testSettings = new DotNetCoreTestSettings {
NoBuild = true,
Configuration = "Debug",
ResultsDirectory = testsArtifactDirectory,
Logger = $"trx;LogFileName=testresults.trx",
};

// see https://github.com/cake-contrib/Cake.PinNuGetDependency
PinNuGetDependency(packagePath, "punchclock");
}
var coverletSettings = new CoverletSettings {
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.opencover,
CoverletOutputDirectory = testsArtifactDirectory,
CoverletOutputName = testCoverageOutputFile
};

var projectName = "./src/Punchclock.Tests/Punchclock.Tests.csproj";
Build(projectName, null, "Debug", true);
DotNetCoreTest(projectName, testSettings, coverletSettings);

}).ReportError(exception =>
{
//var apiApprovals = GetFiles("./**/ApiApprovalTests.*");
// CopyFiles(apiApprovals, artifactDirectory);
});

Task("PublishPackages")
.IsDependentOn("Build")
.IsDependentOn("RunUnitTests")
.IsDependentOn("Package")
.WithCriteria(() => !local)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRepository)
.WithCriteria(() => isDevelopBranch || isReleaseBranch)
.Does (() =>
{
if (isReleaseBranch && !isTagged)
Expand All @@ -209,7 +199,7 @@ Task("PublishPackages")
foreach(var package in packageWhitelist)
{
// only push the package which was created during this build run.
var packagePath = artifactDirectory + File(string.Concat(package, ".", nugetVersion, ".nupkg"));
var packagePath = packagesArtifactDirectory + File(string.Concat(package, ".", nugetVersion, ".nupkg"));

// Push the package.
NuGetPush(packagePath, new NuGetPushSettings {
Expand All @@ -220,8 +210,8 @@ Task("PublishPackages")
});

Task("CreateRelease")
.IsDependentOn("Build")
.IsDependentOn("RunUnitTests")
.IsDependentOn("Package")
.WithCriteria(() => !local)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRepository)
Expand Down Expand Up @@ -250,8 +240,8 @@ Task("CreateRelease")
});

Task("PublishRelease")
.IsDependentOn("Build")
.IsDependentOn("RunUnitTests")
.IsDependentOn("Package")
.WithCriteria(() => !local)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRepository)
Expand All @@ -275,7 +265,7 @@ Task("PublishRelease")
foreach(var package in packageWhitelist)
{
// only push the package which was created during this build run.
var packagePath = artifactDirectory + File(string.Concat(package, ".", nugetVersion, ".nupkg"));
var packagePath = packagesArtifactDirectory + File(string.Concat(package, ".", nugetVersion, ".nupkg"));

GitReleaseManagerAddAssets(username, token, githubOwner, githubRepository, majorMinorPatch, packagePath);
}
Expand All @@ -288,13 +278,11 @@ Task("PublishRelease")
//////////////////////////////////////////////////////////////////////

Task("Default")
.IsDependentOn("UpdateAppVeyorBuildNumber")
.IsDependentOn("CreateRelease")
.IsDependentOn("PublishPackages")
.IsDependentOn("PublishRelease")
.Does (() =>
{

});


Expand Down
Empty file modified build.sh
100644 → 100755
Empty file.
3 changes: 0 additions & 3 deletions src/Punchclock.Tests/OperationQueue.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using DynamicData;
using Xunit;
using System.Reactive;
Expand Down
Loading