Skip to content

Commit

Permalink
Merge branch 'develop' into feature/cake-buildGH-930
Browse files Browse the repository at this point in the history
  • Loading branch information
fabionuno committed Jun 2, 2016
2 parents f6b896b + 999c319 commit 8403e8c
Show file tree
Hide file tree
Showing 39 changed files with 336 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class BuildParameters
IsLocalBuild = buildSystem.IsLocalBuild,
IsRunningOnUnix = context.IsRunningOnUnix(),
IsRunningOnWindows = context.IsRunningOnWindows(),
IsRunningOnAppVeyor = context.IsRunningOnWindows(),
IsRunningOnAppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor,
IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest,
IsMainCakeRepo = StringComparer.OrdinalIgnoreCase.Equals("cake-build/cake", buildSystem.AppVeyor.Environment.Repository.Name),
IsMainCakeBranch = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.AppVeyor.Environment.Repository.Branch),
Expand Down
32 changes: 32 additions & 0 deletions src/Cake.Common.Tests/Unit/Build/AppVeyor/AppVeyorProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,37 @@ public void Should_Update_Build_Version()
Arg.Is<ProcessSettings>(p => p.Arguments.Render() == "UpdateBuild -Version \"build-123\""));
}
}

public sealed class TheUploadTestResultsMethod
{
[Fact]
public void Should_Throw_If_Path_Is_Null()
{
// Given
var fixture = new AppVeyorFixture();
var appVeyor = fixture.CreateAppVeyorService();

// When
var result = Record.Exception(() => appVeyor.UploadTestResults(null, AppVeyorTestResultsType.XUnit));

// Then
Assert.IsArgumentNullException(result, "path");
}

[Fact]
public void Should_Throw_If_Not_Running_On_AppVeyor()
{
// Given
var fixture = new AppVeyorFixture();
var appVeyor = fixture.CreateAppVeyorService();

// When
var result = Record.Exception(() => appVeyor.UploadTestResults("./file.xml", AppVeyorTestResultsType.XUnit));

// Then
Assert.IsExceptionWithMessage<CakeException>(result,
"The current build is not running on AppVeyor.");
}
}
}
}
36 changes: 36 additions & 0 deletions src/Cake.Common/Build/AppVeyor/AppVeyorProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System.Globalization;
using System.IO;
using System.Net.Http;
using Cake.Common.Build.AppVeyor.Data;
using Cake.Core;
using Cake.Core.IO;
Expand Down Expand Up @@ -87,6 +90,39 @@ public void UploadArtifact(FilePath path)
_processRunner.Start("appveyor", new ProcessSettings { Arguments = arguments });
}

/// <summary>
/// Uploads test results XML file to AppVeyor. Results type can be one of the following: mstest, xunit, nunit, nunit3, junit.
/// </summary>
/// <param name="path">The file path of the test results XML to upload.</param>
/// <param name="resultsType">The results type. Can be mstest, xunit, nunit, nunit3 or junit.</param>
public void UploadTestResults(FilePath path, AppVeyorTestResultsType resultsType)
{
if (path == null)
{
throw new ArgumentNullException("path");
}

if (!IsRunningOnAppVeyor)
{
throw new CakeException("The current build is not running on AppVeyor.");
}

var baseUri = _environment.GetEnvironmentVariable("APPVEYOR_URL").TrimEnd('/');

if (string.IsNullOrWhiteSpace(baseUri))
{
throw new CakeException("Failed to get AppVeyor API url.");
}

var url = string.Format(CultureInfo.InvariantCulture, "{0}/api/testresults/{1}/{2}", baseUri, resultsType, Environment.JobId);

using (var stream = File.OpenRead(path.FullPath))
using (var client = new HttpClient())
{
client.PostAsync(url, new StreamContent(stream)).Wait();
}
}

/// <summary>
/// Updates the build version.
/// </summary>
Expand Down
33 changes: 33 additions & 0 deletions src/Cake.Common/Build/AppVeyor/AppVeyorTestResultsType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Cake.Common.Build.AppVeyor
{
/// <summary>
/// Provides the known values for the AppVeyor test results types.
/// </summary>
public enum AppVeyorTestResultsType
{
/// <summary>
/// MSTest test results.
/// </summary>
MSTest,

/// <summary>
/// XUnit test results.
/// </summary>
XUnit,

/// <summary>
/// NUnit test results.
/// </summary>
NUnit,

/// <summary>
/// NUnit v3 test results.
/// </summary>
NUnit3,

/// <summary>
/// JUnit test results.
/// </summary>
JUnit
}
}
7 changes: 7 additions & 0 deletions src/Cake.Common/Build/AppVeyor/IAppVeyorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public interface IAppVeyorProvider
/// <param name="path">The file path of the artifact to upload.</param>
void UploadArtifact(FilePath path);

/// <summary>
/// Uploads test results XML file to AppVeyor. Results type can be one of the following: mstest, xunit, nunit, nunit3, junit.
/// </summary>
/// <param name="path">The file path of the test results XML to upload.</param>
/// <param name="resultsType">The results type. Can be mstest, xunit, nunit, nunit3 or junit.</param>
void UploadTestResults(FilePath path, AppVeyorTestResultsType resultsType);

/// <summary>
/// Updates the build version.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Cake.Common/Build/BuildSystemAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public static BuildSystem BuildSystem(this ICakeContext context)
/// <param name="context">The context.</param>
/// <returns>A <see cref="Cake.Common.Build.AppVeyor"/> instance.</returns>
[CakePropertyAlias(Cache = true)]
[CakeNamespaceImport("Cake.Common.Build.AppVeyor")]
[CakeNamespaceImport("Cake.Common.Build.AppVeyor.Data")]
public static IAppVeyorProvider AppVeyor(this ICakeContext context)
{
if (context == null)
Expand Down
1 change: 1 addition & 0 deletions src/Cake.Common/Cake.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Reference Include="System.IO.Compression.FileSystem" />
</ItemGroup>
<ItemGroup>
<Compile Include="Build\AppVeyor\AppVeyorTestResultsType.cs" />
<Compile Include="Build\AppVeyor\Data\AppVeyorEnvironmentInfo.cs" />
<Compile Include="Build\AppVeyor\AppVeyorInfo.cs" />
<Compile Include="Build\AppVeyor\AppVeyorProvider.cs" />
Expand Down
7 changes: 6 additions & 1 deletion src/Cake.Common/Tools/Chocolatey/ChocolateyAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
namespace Cake.Common.Tools.Chocolatey
{
/// <summary>
/// Contains functionality for working with Chocolatey.
/// <para>Contains functionality for working with <see href="https://github.com/chocolatey/choco">Chocolatey</see>.</para>
/// <para>
/// In order to use the commands for this alias, Chocolatey will require to be installed on the machine where the build script
/// is being run. See this <see href="https://github.com/chocolatey/choco/wiki/Installation">page</see> for details on how
/// Chocolatey can be installed.
/// </para>
/// </summary>
[CakeAliasCategory("Chocolatey")]
public static class ChocolateyAliases
Expand Down
2 changes: 2 additions & 0 deletions src/Cake.Common/Tools/DNU/DNUAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Cake.Common.Tools.DNU.Build;
using Cake.Common.Tools.DNU.Pack;
using Cake.Common.Tools.DNU.Restore;
using Cake.Common.Tools.DotNetCore;
using Cake.Core;
using Cake.Core.Annotations;
using Cake.Core.IO;
Expand All @@ -10,6 +11,7 @@ namespace Cake.Common.Tools.DNU
{
/// <summary>
/// Contains functionality for working with the DNU Utility.
/// <para>These aliases have been marked as Obsolete. Use the <see cref="DotNetCoreAliases" /> instead.</para>
/// </summary>
[CakeAliasCategory("DNU")]
public static class DNUAliases
Expand Down
9 changes: 8 additions & 1 deletion src/Cake.Common/Tools/DotCover/DotCoverAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
namespace Cake.Common.Tools.DotCover
{
/// <summary>
/// Contains functionality related to DotCover.
/// <para>Contains functionality related to <see href="https://www.jetbrains.com/dotcover/">DotCover</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the appropriate settings class:
/// <code>
/// #tool "nuget:?package=JetBrains.dotCover.CommandLineTools"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("DotCover")]
public static class DotCoverAliases
Expand Down
7 changes: 6 additions & 1 deletion src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
namespace Cake.Common.Tools.DotNetCore
{
/// <summary>
/// Contains functionality for working with the .NET Core CLI.
/// <para>Contains functionality related to <see href="https://github.com/dotnet/cli">.NET Core CLI</see>.</para>
/// <para>
/// In order to use the commands for this alias, the .Net Core CLI tools will need to be installed on the machine where
/// the Cake script is being executed. See this <see href="https://www.microsoft.com/net/core">page</see> for information
/// on how to install.
/// </para>
/// </summary>
[CakeAliasCategory("DotNetCore")]
public static class DotNetCoreAliases
Expand Down
9 changes: 8 additions & 1 deletion src/Cake.Common/Tools/DupFinder/DupFinderAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
namespace Cake.Common.Tools.DupFinder
{
/// <summary>
/// Contains functionality related to ReSharper's duplication finder
/// <para>Contains functionality related to ReSharper's <see href="https://www.jetbrains.com/help/resharper/2016.1/dupFinder.html">dupFinder</see> tool.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="DupFinderSettings" /> class:
/// <code>
/// #tool "nuget:?package=JetBrains.ReSharper.CommandLineTools"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("ReSharper")]
public static class DupFinderAliases
Expand Down
9 changes: 8 additions & 1 deletion src/Cake.Common/Tools/Fixie/FixieAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
namespace Cake.Common.Tools.Fixie
{
/// <summary>
/// Contains functionality related to running Fixie tests.
/// <para>Contains functionality related to running <see href="https://github.com/fixie/fixie">Fixie</see> tests.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="FixieSettings" /> class:
/// <code>
/// #tool "nuget:?package=Fixie"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("Fixie")]
public static class FixieAliases
Expand Down
9 changes: 8 additions & 1 deletion src/Cake.Common/Tools/GitLink/GitLinkAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
namespace Cake.Common.Tools.GitLink
{
/// <summary>
/// Contains functionality for working with GitLink.
/// <para>Contains functionality related to <see href="https://github.com/gittools/gitlink">GitLink</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="GitLinkSettings" /> class:
/// <code>
/// #tool "nuget:?package=gitlink"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("GitTools")]
public static class GitLinkAliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
namespace Cake.Common.Tools.GitReleaseManager
{
/// <summary>
/// Contains functionality for working with GitReleaseManager.
/// <para>Contains functionality related to <see href="https://github.com/gittools/gitreleasemanager">GitReleaseManager</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the appropriate settings class:
/// <code>
/// #tool "nuget:?package=gitreleasemanager"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("GitReleaseManager")]
public static class GitReleaseManagerAliases
Expand Down Expand Up @@ -249,7 +256,7 @@ public static void GitReleaseManagerPublish(this ICakeContext context, string us
{
throw new ArgumentNullException("context");
}

var publisher = new GitReleaseManagerPublisher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
publisher.Publish(userName, password, owner, repository, tagName, settings);
}
Expand Down Expand Up @@ -305,7 +312,7 @@ public static void GitReleaseManagerExport(this ICakeContext context, string use
{
throw new ArgumentNullException("context");
}

var publisher = new GitReleaseManagerExporter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
publisher.Export(userName, password, owner, repository, fileOutputPath, settings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
namespace Cake.Common.Tools.GitReleaseNotes
{
/// <summary>
/// Contains functionality related to GitReleaseNotes
/// <para>Contains functionality related to <see href="https://github.com/gittools/gitreleasenotes">GitReleaseNotes</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="GitReleaseNotesSettings" /> class:
/// <code>
/// #tool "nuget:?package=GitReleaseNotes"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("GitReleaseNotes")]
public static class GitReleaseNotesAliases
Expand Down
11 changes: 8 additions & 3 deletions src/Cake.Common/Tools/GitVersion/GitVersionAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
namespace Cake.Common.Tools.GitVersion
{
/// <summary>
/// Contains functionality related to GitVersion.
/// <see href="http://gitversion.readthedocs.org/en/latest/">GitVersion Documentation</see>
/// <see href="https://www.nuget.org/packages/GitVersion.CommandLine/">GitVersion NuGet Package</see>
/// <para>Contains functionality related to <see href="https://github.com/gittools/gitversion">GitVersion</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="GitVersionSettings" /> class:
/// <code>
/// #tool "nuget:?package=GitVersion.CommandLine"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("GitVersion")]
public static class GitVersionAliases
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.Common/Tools/ILMerge/ILMergeAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
namespace Cake.Common.Tools.ILMerge
{
/// <summary>
/// <para>Contains functionality related to ILMerge.</para>
/// <para>Contains functionality related to <see href="http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx">ILMerge</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and install from NuGet.org, or specify the ToolPath within the ILMergeSettings class:
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="ILMergeSettings" /> class:
/// <code>
/// #tool "nuget:?package=ilmerge"
/// </code>
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.Common/Tools/ILRepack/ILRepackAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
namespace Cake.Common.Tools.ILRepack
{
/// <summary>
/// <para>Contains functionality related to ILRepack.</para>
/// <para>Contains functionality related to <see href="https://github.com/gluck/il-repack">ILRepack</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and install from NuGet.org, or specify the ToolPath within the ILRepackSettings class:
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="ILRepackSettings" /> class:
/// <code>
/// #tool "nuget:?package=ILRepack"
/// </code>
Expand Down
9 changes: 8 additions & 1 deletion src/Cake.Common/Tools/InspectCode/InspectCodeAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
namespace Cake.Common.Tools.InspectCode
{
/// <summary>
/// Contains functionality related to Resharper's code inspection.
/// <para>Contains functionality related to ReSharper's <see href="https://www.jetbrains.com/help/resharper/2016.1/InspectCode.html">InspectCode</see> tool.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// install from NuGet.org, or specify the ToolPath within the <see cref="InspectCodeSettings" /> class:
/// <code>
/// #tool "nuget:?package=JetBrains.ReSharper.CommandLineTools"
/// </code>
/// </para>
/// </summary>
[CakeAliasCategory("ReSharper")]
public static class InspectCodeAliases
Expand Down
6 changes: 5 additions & 1 deletion src/Cake.Common/Tools/MSBuild/MSBuildAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
namespace Cake.Common.Tools.MSBuild
{
/// <summary>
/// Contains functionality related to MSBuild.
/// <para>Contains functionality related to <see href="https://msdn.microsoft.com/en-us/library/dd393574.aspx">MSBuild</see>.</para>
/// <para>
/// In order to use the commands for this alias, MSBuild will already have to be installed on the machine the Cake Script
/// is being executed.
/// </para>
/// </summary>
[CakeAliasCategory("MSBuild")]
public static class MSBuildAliases
Expand Down
Loading

0 comments on commit 8403e8c

Please sign in to comment.