Skip to content

Commit 4606ac7

Browse files
Merge branch 'release/2.1.0'
2 parents 79402af + e729868 commit 4606ac7

File tree

75 files changed

+2950
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2950
-245
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "2.0.0-rc0002",
6+
"version": "2.0.0",
77
"commands": [
88
"dotnet-cake"
99
]

.gitpod.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
image: gitpod/workspace-dotnet
2+
3+
vscode:
4+
extensions:
5+
- "muhammad-sammy.csharp"

ReleaseNotes.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
### New in 2.1.0 (Released 2022/02/19)
2+
3+
* 2524 XmlTransform support for xsl arguments
4+
* 3479 Add alias for dotnet format command
5+
* 3480 Add alias for dotnet sdk check command
6+
* 3771 Add support for the Chocolatey Export command
7+
* 2746 Add duration of a task
8+
* 3733 Show relative path of addin assemblies that are being loaded
9+
* 3756 Update NuGet.* to 6.0.0
10+
* 3758 Update Autofac to 6.3.0
11+
* 3760 Update Spectre.Console to 0.43.0
12+
* 3764 Add missing GitHub Actions environment info
13+
* 3769 Update Microsoft.NETCore.Platforms to 6.0.1
14+
* 3776 Introduce IPath<T> interface for easier code reuse
15+
* 3777 GitHub Actions UploadArtifact command should accept relative paths
16+
* 3778 Add GitHub Actions DownloadArtifact command
17+
* 3743 SemVersion class crashes if compared to `null`
18+
* 3772 VSTest Alias does not work when only VS 2022 Preview is installed
19+
* 3794 VS2022 BuildTools are not found by the logic introduced in #3775
20+
121
### New in 2.0.0 (Released 2021/11/30)
222

323
* 3714 Use Basic.Reference.Assemblies.* to ensure all standard reference assemblies are available for Roslyn.

build.cake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Install addins.
2-
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=1.0.0"
3-
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Gitter&version=1.0.1"
2+
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=2.0.0"
3+
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Gitter&version=2.0.0"
44

55
// Install .NET Core Global tools.
6-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.7.0"
7-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=SignClient&version=1.2.109"
8-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.11.0"
6+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.8.1"
7+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=SignClient&version=1.3.155"
8+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.12.1"
99

1010
// Load other scripts.
1111
#load "./build/parameters.cake"

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"src"
44
],
55
"sdk": {
6-
"version": "6.0.100",
6+
"version": "6.0.102",
77
"rollForward": "latestFeature"
88
}
99
}

src/Cake.Cli/Cake.Cli.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Autofac" Version="6.2.0" />
22-
<PackageReference Include="Spectre.Console" Version="0.42.0" />
21+
<PackageReference Include="Autofac" Version="6.3.0" />
22+
<PackageReference Include="Spectre.Console" Version="0.43.0" />
2323
</ItemGroup>
2424
</Project>

src/Cake.Common.Tests/Cake.Common.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2424
</PackageReference>
25-
<PackageReference Include="NSubstitute" Version="4.2.2" />
25+
<PackageReference Include="NSubstitute" Version="4.3.0" />
2626
<PackageReference Include="Castle.Core" Version="4.4.1" />
2727
</ItemGroup>
2828
<!-- .NET Framework packages -->

src/Cake.Common.Tests/Fixtures/Build/GitHubActionsCommandsFixture.cs

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Cake.Common.Build.GitHubActions.Commands;
88
using Cake.Common.Build.GitHubActions.Data;
99
using Cake.Core;
10+
using Cake.Core.IO;
1011
using Cake.Testing;
1112
using NSubstitute;
1213

@@ -16,6 +17,8 @@ internal sealed class GitHubActionsCommandsFixture : HttpMessageHandler
1617
{
1718
private const string ApiVersion = "6.0-preview";
1819
private const string AcceptHeader = "application/json; api-version=" + ApiVersion;
20+
private const string AcceptGzip = "application/octet-stream; api-version=" + ApiVersion;
21+
private const string AcceptEncodingGzip = "gzip";
1922
private const string CreateArtifactUrl = GitHubActionsInfoFixture.ActionRuntimeUrl +
2023
"_apis/pipelines/workflows/34058136/artifacts?api-version=" + ApiVersion + "&artifactName=artifact";
2124
private const string CreateArtifactsUrl = GitHubActionsInfoFixture.ActionRuntimeUrl +
@@ -54,6 +57,54 @@ internal sealed class GitHubActionsCommandsFixture : HttpMessageHandler
5457
private const string PutDirectoryFolderBFolderCUrl = GitHubActionsInfoFixture.ActionRuntimeUrl +
5558
"_apis/resources/Containers/942031?itemPath=artifacts%2Ffolder_b%2Ffolder_c%2Fartifact.txt";
5659

60+
private const string GetArtifactResourceUrl = GitHubActionsInfoFixture.ActionRuntimeUrl +
61+
"_apis/pipelines/workflows/34058136/artifacts?api-version=6.0-preview&artifactName=artifact";
62+
private const string FileContainerResourceUrl = GitHubActionsInfoFixture.ActionRuntimeUrl + @"_apis/resources/Containers/4794789";
63+
private const string GetArtifactResourceResponse = @"{
64+
""count"": 1,
65+
""value"": [
66+
{
67+
""containerId"": 4794789,
68+
""size"": 4,
69+
""signedContent"": null,
70+
""fileContainerResourceUrl"": """ + FileContainerResourceUrl + @""",
71+
""type"": ""actions_storage"",
72+
""name"": ""artifact"",
73+
""url"": """ + GitHubActionsInfoFixture.ActionRuntimeUrl + @"_apis/pipelines/1/runs/7/artifacts?artifactName=artifact"",
74+
""expiresOn"": ""2022-03-16T08:22:01.5699067Z"",
75+
""items"": null
76+
}
77+
]
78+
}";
79+
80+
private const string GetContainerItemResourcesUrl = FileContainerResourceUrl + "?itemPath=artifact";
81+
private const string GetContainerItemResourcesResponse = @"{
82+
""count"": 1,
83+
""value"": [
84+
{
85+
""containerId"": 4794789,
86+
""scopeIdentifier"": ""00000000-0000-0000-0000-000000000000"",
87+
""path"": ""artifact/test.txt"",
88+
""itemType"": ""file"",
89+
""status"": ""created"",
90+
""fileLength"": 4,
91+
""fileEncoding"": 1,
92+
""fileType"": 1,
93+
""dateCreated"": ""2021-12-16T09:05:18.803Z"",
94+
""dateLastModified"": ""2021-12-16T09:05:18.907Z"",
95+
""createdBy"": ""2daeb16b-86ae-4e46-ba89-92a8aa076e52"",
96+
""lastModifiedBy"": ""2daeb16b-86ae-4e46-ba89-92a8aa076e52"",
97+
""itemLocation"": """ + GetContainerItemResourcesUrl + @"%2Ftest.txt&metadata=True"",
98+
""contentLocation"": """ + GetContainerItemResourcesUrl + @"%2Ftest.txt"",
99+
""fileId"": 1407,
100+
""contentId"": """"
101+
}
102+
]
103+
}";
104+
105+
private const string DownloadItemResourceUrl = GetContainerItemResourcesUrl + "%2Ftest.txt";
106+
private const string DownloadItemResourceResponse = "Cake";
107+
57108
private GitHubActionsInfoFixture GitHubActionsInfoFixture { get; }
58109
private ICakeEnvironment Environment { get; }
59110
public FakeFileSystem FileSystem { get; }
@@ -71,6 +122,12 @@ public GitHubActionsCommands CreateGitHubActionsCommands()
71122
return new GitHubActionsCommands(Environment, FileSystem, GitHubActionsInfoFixture.CreateEnvironmentInfo(), CreateClient);
72123
}
73124

125+
public GitHubActionsCommandsFixture WithWorkingDirectory(DirectoryPath workingDirectory)
126+
{
127+
Environment.WorkingDirectory = workingDirectory;
128+
return this;
129+
}
130+
74131
public GitHubActionsCommandsFixture WithNoGitHubEnv()
75132
{
76133
Environment.GetEnvironmentVariable("GITHUB_ENV").Returns(null as string);
@@ -95,18 +152,26 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
95152
};
96153
}
97154

98-
if (!request.Headers.TryGetValues("Accept", out var values) || !values.Contains(AcceptHeader))
155+
if (
156+
!request.Headers.TryGetValues("Accept", out var values)
157+
|| !values.Contains(AcceptHeader))
99158
{
100-
return new HttpResponseMessage
159+
if (request.RequestUri.AbsoluteUri != DownloadItemResourceUrl
160+
|| !values.Contains(AcceptGzip)
161+
|| !request.Headers.TryGetValues("Accept-Encoding", out var encodingValues)
162+
|| !encodingValues.Contains(AcceptEncodingGzip))
101163
{
102-
StatusCode = HttpStatusCode.BadRequest
103-
};
164+
return new HttpResponseMessage
165+
{
166+
StatusCode = HttpStatusCode.BadRequest
167+
};
168+
}
104169
}
105170

106171
switch (request)
107172
{
108173
#pragma warning disable SA1013
109-
// FilePath
174+
// Create Artifact FilePath
110175
case
111176
{
112177
RequestUri: { AbsoluteUri: CreateArtifactUrl },
@@ -116,7 +181,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
116181
return Ok(new StringContent(CreateArtifactResponse));
117182
}
118183

119-
// DirectoryPath
184+
// Create Artifact DirectoryPath
120185
case
121186
{
122187
RequestUri: { AbsoluteUri: CreateArtifactsUrl },
@@ -126,7 +191,37 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
126191
return Ok(new StringContent(CreateArtifactsResponse));
127192
}
128193

129-
// FilePath
194+
// Download Artifact - Get Artifact Container Resource
195+
case
196+
{
197+
RequestUri: { AbsoluteUri: GetArtifactResourceUrl },
198+
Method: { Method: "GET" }
199+
}:
200+
{
201+
return Ok(new StringContent(GetArtifactResourceResponse));
202+
}
203+
204+
// Download Artifact - Get Artifact Container Item Resource
205+
case
206+
{
207+
RequestUri: { AbsoluteUri: GetContainerItemResourcesUrl },
208+
Method: { Method: "GET" }
209+
}:
210+
{
211+
return Ok(new StringContent(GetContainerItemResourcesResponse));
212+
}
213+
214+
// Download Artifact - DownloadItemResource
215+
case
216+
{
217+
RequestUri: { AbsoluteUri: DownloadItemResourceUrl },
218+
Method: { Method: "GET" }
219+
}:
220+
{
221+
return Ok(new StringContent(DownloadItemResourceResponse));
222+
}
223+
224+
// Put FilePath
130225
case
131226
{
132227
RequestUri: { AbsoluteUri: PutFileUrl },
@@ -138,7 +233,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
138233
Method: { Method: "PATCH" },
139234
}:
140235

141-
// DirectoryPath
236+
// Put DirectoryPath
142237
case
143238
{
144239
RequestUri: { AbsoluteUri: PutDirectoryRootUrl },

src/Cake.Common.Tests/Fixtures/Build/GitHubActionsInfoFixture.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public GitHubActionsInfoFixture()
2626
Environment.GetEnvironmentVariable("RUNNER_TEMP").Returns("/home/runner/work/_temp");
2727
Environment.GetEnvironmentVariable("RUNNER_TOOL_CACHE").Returns("/opt/hostedtoolcache");
2828
Environment.GetEnvironmentVariable("RUNNER_WORKSPACE").Returns("/home/runner/work/cake");
29+
Environment.GetEnvironmentVariable("ImageOS").Returns("ubuntu20");
30+
Environment.GetEnvironmentVariable("ImageVersion").Returns("20211209.3");
31+
Environment.GetEnvironmentVariable("RUNNER_USER").Returns("runner");
2932

3033
Environment.GetEnvironmentVariable("GITHUB_ACTION").Returns("run1");
3134
Environment.GetEnvironmentVariable("GITHUB_ACTION_PATH").Returns("/path/to/action");
@@ -46,6 +49,9 @@ public GitHubActionsInfoFixture()
4649
Environment.GetEnvironmentVariable("GITHUB_SHA").Returns("d1e4f990f57349334368c8253382abc63be02d73");
4750
Environment.GetEnvironmentVariable("GITHUB_WORKFLOW").Returns("Build");
4851
Environment.GetEnvironmentVariable("GITHUB_WORKSPACE").Returns("/home/runner/work/cake/cake");
52+
Environment.GetEnvironmentVariable("GITHUB_RUN_ATTEMPT").Returns("2");
53+
Environment.GetEnvironmentVariable("GITHUB_REF_PROTECTED").Returns("true");
54+
Environment.GetEnvironmentVariable("GITHUB_REF_NAME").Returns("main");
4955

5056
Environment.GetEnvironmentVariable("ACTIONS_RUNTIME_TOKEN").Returns(ActionRuntimeToken);
5157
Environment.GetEnvironmentVariable("ACTIONS_RUNTIME_URL").Returns(ActionRuntimeUrl);
@@ -54,13 +60,15 @@ public GitHubActionsInfoFixture()
5460
Environment.WorkingDirectory.Returns("/home/runner/work/cake/cake");
5561
}
5662

57-
public GitHubActionsRunnerInfo CreateRunnerInfo()
63+
public GitHubActionsRunnerInfo CreateRunnerInfo(string architecture = null)
5864
{
65+
Environment.GetEnvironmentVariable("RUNNER_ARCH").Returns(architecture);
5966
return new GitHubActionsRunnerInfo(Environment);
6067
}
6168

62-
public GitHubActionsWorkflowInfo CreateWorkflowInfo()
69+
public GitHubActionsWorkflowInfo CreateWorkflowInfo(string refType = null)
6370
{
71+
Environment.GetEnvironmentVariable("GITHUB_REF_TYPE").Returns(refType);
6472
return new GitHubActionsWorkflowInfo(Environment);
6573
}
6674

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Cake.Common.Tools.Chocolatey.Export;
6+
7+
namespace Cake.Common.Tests.Fixtures.Tools.Chocolatey.Export
8+
{
9+
internal sealed class ChocolateyExportFixture : ChocolateyFixture<ChocolateyExportSettings>
10+
{
11+
public ChocolateyExportFixture()
12+
{
13+
}
14+
15+
protected override void RunTool()
16+
{
17+
var tool = new ChocolateyExporter(FileSystem, Environment, ProcessRunner, Tools, Resolver);
18+
tool.Export(Settings);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)