Skip to content

Commit

Permalink
Merge branch 'hotfix/0.15.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed Jul 28, 2016
2 parents 02a4a87 + 9362434 commit 1883823
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 29 deletions.
5 changes: 4 additions & 1 deletion GitVersionConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ branches:
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
track-merge-target: false
ignore:
sha:
- 2a4757b270f7946122ba6622e3d2e72b2b2808a7
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### New on 0.15.1 (Released 2016/07/28)

* Corrected Issues found with 0.15.0 AppVeyor updates

### New on 0.15.0 (Released 2016/07/26)

* Add support for adding messages to the AppVeyor build log
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Install tools.
#tool "nuget:?package=xunit.runner.console&version=2.1.0"
#tool "nuget:?package=gitreleasemanager&version=0.5.0"
#tool "nuget:?package=GitVersion.CommandLine&version=3.4.1"
#tool "nuget:?package=GitVersion.CommandLine&version=3.6.2"

// Load other scripts.
#load "./build/parameters.cake"
Expand Down
7 changes: 6 additions & 1 deletion src/Cake.Common.Tests/Fixtures/Build/AppVeyorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

using Cake.Common.Build.AppVeyor;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Testing;
using NSubstitute;

namespace Cake.Common.Tests.Fixtures.Build
Expand All @@ -14,13 +16,16 @@ internal sealed class AppVeyorFixture
public ICakeEnvironment Environment { get; set; }
public IProcessRunner ProcessRunner { get; set; }

public FakeLog CakeLog { get; set; }

public AppVeyorFixture()
{
Environment = Substitute.For<ICakeEnvironment>();
Environment.WorkingDirectory.Returns("/Working");
Environment.GetEnvironmentVariable("APPVEYOR").Returns((string)null);

ProcessRunner = Substitute.For<IProcessRunner>();
CakeLog = new FakeLog();
}

public void IsRunningOnAppVeyor()
Expand All @@ -30,7 +35,7 @@ public void IsRunningOnAppVeyor()

public AppVeyorProvider CreateAppVeyorService()
{
return new AppVeyorProvider(Environment, ProcessRunner);
return new AppVeyorProvider(Environment, ProcessRunner, CakeLog);
}
}
}
25 changes: 20 additions & 5 deletions src/Cake.Common.Tests/Unit/Build/AppVeyor/AppVeyorProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Cake.Common.Build.AppVeyor;
using Cake.Common.Tests.Fixtures.Build;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using NSubstitute;
using Xunit;
Expand All @@ -20,8 +21,9 @@ public sealed class TheConstructor
public void Should_Throw_If_Environment_Is_Null()
{
// Given, When
var cakeLog = Substitute.For<ICakeLog>();
var processRunner = Substitute.For<IProcessRunner>();
var result = Record.Exception(() => new AppVeyorProvider(null, processRunner));
var result = Record.Exception(() => new AppVeyorProvider(null, processRunner, cakeLog));

// Then
Assert.IsArgumentNullException(result, "environment");
Expand All @@ -31,12 +33,25 @@ public void Should_Throw_If_Environment_Is_Null()
public void Should_Throw_If_Process_Runner_Is_Null()
{
// Given, When
var cakeLog = Substitute.For<ICakeLog>();
var environment = Substitute.For<ICakeEnvironment>();
var result = Record.Exception(() => new AppVeyorProvider(environment, null));
var result = Record.Exception(() => new AppVeyorProvider(environment, null, cakeLog));

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

[Fact]
public void Should_Throw_If_Log_Is_Null()
{
// Given, When
var processRunner = Substitute.For<IProcessRunner>();
var environment = Substitute.For<ICakeEnvironment>();
var result = Record.Exception(() => new AppVeyorProvider(environment, processRunner, null));

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

public sealed class TheIsRunningOnAppVeyorProperty
Expand Down Expand Up @@ -148,7 +163,7 @@ public void Should_Upload_Artifact()
fixture.ProcessRunner.Received(1).Start(
Arg.Is<FilePath>(p => p.FullPath == "appveyor"),
Arg.Is<ProcessSettings>(p => p.Arguments.Render()
== "PushArtifact -Path \"/Working/file.zip\" -FileName \"file.zip\" -ArtifactType \"Auto\""));
== "PushArtifact \"/Working/file.zip\" -Type Auto"));
}

[Theory]
Expand All @@ -169,7 +184,7 @@ public void Should_Upload_Artifact_For_ArtifactType(AppVeyorUploadArtifactType t
fixture.ProcessRunner.Received(1).Start(
Arg.Is<FilePath>(p => p.FullPath == "appveyor"),
Arg.Is<ProcessSettings>(p => p.Arguments.Render()
== string.Format("PushArtifact -Path \"/Working/file.zip\" -FileName \"file.zip\" -ArtifactType \"{0}\"", arg)));
== string.Format("PushArtifact \"/Working/file.zip\" -Type {0}", arg)));
}

[Fact]
Expand All @@ -187,7 +202,7 @@ public void Should_Upload_Artifact_For_DeploymentName()
fixture.ProcessRunner.Received(1).Start(
Arg.Is<FilePath>(p => p.FullPath == "appveyor"),
Arg.Is<ProcessSettings>(p => p.Arguments.Render()
== "PushArtifact -Path \"/Working/file.zip\" -FileName \"file.zip\" -ArtifactType \"Auto\" -DeploymentName \"MyApp.Web\""));
== "PushArtifact \"/Working/file.zip\" -Type Auto -DeploymentName \"MyApp.Web\""));
}

[Fact]
Expand Down
32 changes: 22 additions & 10 deletions src/Cake.Common/Build/AppVeyor/AppVeyorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Cake.Common.Build.AppVeyor.Data;
using Cake.Common.Net;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;

namespace Cake.Common.Build.AppVeyor
Expand All @@ -21,6 +23,7 @@ public sealed class AppVeyorProvider : IAppVeyorProvider
{
private readonly ICakeEnvironment _environment;
private readonly IProcessRunner _processRunner;
private readonly ICakeLog _cakeLog;
private readonly AppVeyorEnvironmentInfo _environmentInfo;

/// <summary>
Expand Down Expand Up @@ -50,7 +53,8 @@ public AppVeyorEnvironmentInfo Environment
/// </summary>
/// <param name="environment">The environment.</param>
/// <param name="processRunner">The process runner.</param>
public AppVeyorProvider(ICakeEnvironment environment, IProcessRunner processRunner)
/// <param name="cakeLog">The cake log.</param>
public AppVeyorProvider(ICakeEnvironment environment, IProcessRunner processRunner, ICakeLog cakeLog)
{
if (environment == null)
{
Expand All @@ -60,8 +64,13 @@ public AppVeyorProvider(ICakeEnvironment environment, IProcessRunner processRunn
{
throw new ArgumentNullException("processRunner");
}
if (cakeLog == null)
{
throw new ArgumentNullException("cakeLog");
}
_environment = environment;
_processRunner = processRunner;
_cakeLog = cakeLog;
_environmentInfo = new AppVeyorEnvironmentInfo(environment);
}

Expand Down Expand Up @@ -101,12 +110,9 @@ public void UploadArtifact(FilePath path, AppVeyorUploadArtifactsSettings settin
// Build the arguments.
var arguments = new ProcessArgumentBuilder();
arguments.Append("PushArtifact");
arguments.Append("-Path");
arguments.AppendQuoted(path.FullPath);
arguments.Append("-FileName");
arguments.AppendQuoted(path.GetFilename().FullPath);
arguments.Append("-ArtifactType");
arguments.AppendQuoted(settings.ArtifactType.ToString());
arguments.Append("-Type");
arguments.Append(settings.ArtifactType.ToString());
if (!string.IsNullOrEmpty(settings.DeploymentName))
{
if (settings.DeploymentName.Contains(" "))
Expand Down Expand Up @@ -162,12 +168,18 @@ public void UploadTestResults(FilePath path, AppVeyorTestResultsType resultsType
throw new CakeException("Failed to get AppVeyor API url.");
}

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

using (var client = new HttpClient())
_cakeLog.Write(Verbosity.Diagnostic, LogLevel.Verbose, "Uploading [{0}] to [{1}]", path.FullPath, url);
Task.Run(async () =>
{
client.UploadFileAsync(url, path.FullPath).Wait();
}
using (var client = new HttpClient())
{
var response = await client.UploadFileAsync(url, path.FullPath, "text/xml");
var content = await response.Content.ReadAsStringAsync();
_cakeLog.Write(Verbosity.Diagnostic, LogLevel.Verbose, "Server response [{0}:{1}]:\n\r{2}", response.StatusCode, response.ReasonPhrase, content);
}
}).Wait();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Common/Build/BuildSystemAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static BuildSystem BuildSystem(this ICakeContext context)
{
throw new ArgumentNullException("context");
}
var appVeyorProvider = new AppVeyorProvider(context.Environment, context.ProcessRunner);
var appVeyorProvider = new AppVeyorProvider(context.Environment, context.ProcessRunner, context.Log);
var teamCityProvider = new TeamCityProvider(context.Environment, context.Log);
var myGetProvider = new MyGetProvider(context.Environment);
var bambooProvider = new BambooProvider(context.Environment);
Expand Down
20 changes: 13 additions & 7 deletions src/Cake.Common/Net/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace Cake.Common.Net
Expand Down Expand Up @@ -49,7 +50,7 @@ public static async Task DownloadFileAsync(this HttpClient client, Uri requestUr
}
}

public static async Task UploadFileAsync(this HttpClient client, Uri requestUri, string path)
public static async Task<HttpResponseMessage> UploadFileAsync(this HttpClient client, Uri requestUri, string path, string contentType = "application/octet-stream")
{
if (!File.Exists(path))
{
Expand All @@ -59,10 +60,10 @@ public static async Task UploadFileAsync(this HttpClient client, Uri requestUri,
var file = new FileInfo(path);
var fileName = file.Name;

await UploadFileAsync(client, requestUri, file.OpenRead(), fileName).ConfigureAwait(false);
return await UploadFileAsync(client, requestUri, file.OpenRead(), fileName, contentType).ConfigureAwait(false);
}

public static async Task UploadFileAsync(this HttpClient client, Uri requestUri, Stream stream, string fileName)
public static async Task<HttpResponseMessage> UploadFileAsync(this HttpClient client, Uri requestUri, Stream stream, string fileName, string contentType = "application/octet-stream")
{
if (stream == null)
{
Expand All @@ -77,20 +78,25 @@ public static async Task UploadFileAsync(this HttpClient client, Uri requestUri,
var multipartFormDataContent = new MultipartFormDataContent(boundary);

stream.Position = 0;
var streamContent = new StreamContent(stream);
multipartFormDataContent.Add(streamContent, fileName);
var streamContent = new StreamContent(stream)
{
Headers = { ContentType = MediaTypeHeaderValue.Parse(contentType) }
};

multipartFormDataContent.Add(streamContent, fileName, fileName);
var response = await client.PostAsync(requestUri, multipartFormDataContent).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
return response;
}

public static async Task UploadFileAsync(this HttpClient client, Uri requestUri, byte[] data, string fileName)
public static async Task<HttpResponseMessage> UploadFileAsync(this HttpClient client, Uri requestUri, byte[] data, string fileName, string contentType = "application/octet-stream")
{
if (data == null)
{
throw new ArgumentNullException("data", "No data to send");
}

await UploadFileAsync(client, requestUri, new MemoryStream(data), fileName).ConfigureAwait(false);
return await UploadFileAsync(client, requestUri, new MemoryStream(data), fileName, contentType).ConfigureAwait(false);
}
}
}
6 changes: 3 additions & 3 deletions src/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Reflection;

[assembly: AssemblyProduct("Cake")]
[assembly: AssemblyVersion("0.15.0.0")]
[assembly: AssemblyFileVersion("0.15.0.0")]
[assembly: AssemblyInformationalVersion("0.15.0-beta.1+0.Branch.release/0.15.0.Sha.d72a28ffde17c00e9807c81fe532fe60415319ca")]
[assembly: AssemblyVersion("0.15.1.0")]
[assembly: AssemblyFileVersion("0.15.1.0")]
[assembly: AssemblyInformationalVersion("0.15.1-beta.1+2.Branch.hotfix/0.15.1.Sha.2a4757b270f7946122ba6622e3d2e72b2b2808a7")]
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]

0 comments on commit 1883823

Please sign in to comment.