Skip to content

Commit

Permalink
Merge branch 'develop' into rmarusyk/3817-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Marusyk authored Nov 12, 2024
2 parents f8667df + edafec7 commit 9d0a3c5
Show file tree
Hide file tree
Showing 18 changed files with 1,052 additions and 27 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ on:
- develop
- hotfix/*
jobs:
prepare:
name: Prepare integration tests
runs-on: ubuntu-latest
steps:
- run: echo "Cake Integration Tests" > cake-integration-tests.txt
- uses: actions/upload-artifact@v4
with:
name: cake-integration-tests
path: cake-integration-tests.txt

build:
name: Build
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -34,7 +45,7 @@ jobs:

- name: Run Cake script
id: build-cake
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@master
with:
target: Run-Integration-Tests
cake-version: tool-manifest
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"src"
],
"sdk": {
"version": "9.0.100-rc.2.24474.11",
"version": "9.0.100",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Cake.Common.Build.GitHubActions.Commands;
using Cake.Common.Build.GitHubActions.Commands.Artifact;
using Cake.Common.Build.GitHubActions.Data;
using Cake.Common.Tests.Fakes;
using Cake.Core;
using Cake.Core.IO;
Expand All @@ -22,21 +21,45 @@ internal sealed class GitHubActionsCommandsFixture : HttpMessageHandler
private const string ArtifactUrl = GitHubActionsInfoFixture.ActionResultsUrl + "twirp/github.actions.results.api.v1.ArtifactService/";
private const string CreateArtifactUrl = ArtifactUrl + "CreateArtifact";
private const string FinalizeArtifactUrl = ArtifactUrl + "FinalizeArtifact";
private const string GetSignedArtifactURLurl = ArtifactUrl + "GetSignedArtifactURL";
private const string GetSignedArtifactURLUrl = ArtifactUrl + "GetSignedArtifactURL";
private const string ListArtifactsUrl = ArtifactUrl + "ListArtifacts";
private const string UploadFileUrl = "https://cake.build.net/actions-results/a9d82106-d5d5-4310-8f60-0bfac035cf02/workflow-job-run-1d849a45-2f30-5fbb-3226-b730a17a93af/artifacts/91e64594182918fa8012cdbf7d1a4f801fa0c35f485c3277268aad8e3f45377c.zip?sig=upload";
private const string DownloadFileUrl = "https://cake.build.net/actions-results/a9d82106-d5d5-4310-8f60-0bfac035cf02/workflow-job-run-1d849a45-2f30-5fbb-3226-b730a17a93af/artifacts/91e64594182918fa8012cdbf7d1a4f801fa0c35f485c3277268aad8e3f45377c.zip?sig=download";
private const string CreateArtifactResponse = @"{
""ok"": true,
""signed_upload_url"": """ + UploadFileUrl + @"""
}";
private const string FinalizeArtifactResponse = @"{
""ok"": true,
""artifact_id"": ""1991105334""
}";
private const string GetSignedArtifactURLResponse = @"{
""name"": ""artifact"",
""signed_url"": """ + DownloadFileUrl + @"""
}";
private const string CreateArtifactResponse =
$$"""
{
"ok": true,
"signed_upload_url": "{{UploadFileUrl}}"
}
""";
private const string FinalizeArtifactResponse =
"""
{
"ok": true,
"artifact_id": "1991105334"
}
""";
private const string GetSignedArtifactURLResponse =
$$"""
{
"name": "artifact",
"signed_url": "{{DownloadFileUrl}}"
}
""";
private const string ListArtifactsResponse =
$$"""
{
"artifacts": [
{
"workflow_run_backend_id": "b9e28153-ca20-4b86-91dd-09e8f644efdf",
"workflow_job_run_backend_id": "1d849a45-2f30-5fbb-3226-b730a17a93af",
"database_id": "1",
"name": "artifact",
"created_at": "2024-11-09T21:53:00.7110204+00:00"
}
]
}
""";

private GitHubActionsInfoFixture GitHubActionsInfoFixture { get; }
private ICakeEnvironment Environment { get; }
Expand Down Expand Up @@ -122,7 +145,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
// Get Signed Artifact Url
case
{
RequestUri: { AbsoluteUri: GetSignedArtifactURLurl },
RequestUri: { AbsoluteUri: GetSignedArtifactURLUrl },
Method: { Method: "POST" },
}:
{
Expand Down Expand Up @@ -189,6 +212,16 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
return Ok();
}

// List Artifacts
case
{
RequestUri: { AbsoluteUri: ListArtifactsUrl },
Method: { Method: "POST" }
}:
{
return Ok(new StringContent(ListArtifactsResponse));
}

// Download File
case
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Cake.Common.Tools.DotNet.Sln.Add;
using Cake.Core.IO;

namespace Cake.Common.Tests.Fixtures.Tools.DotNet.Sln.Add
{
internal sealed class DotNetSlnAdderFixture : DotNetFixture<DotNetSlnAddSettings>
{
public FilePath Solution { get; set; }

public IEnumerable<FilePath> ProjectPath { get; set; }

protected override void RunTool()
{
var tool = new DotNetSlnAdder(FileSystem, Environment, ProcessRunner, Tools);
tool.Add(Solution, ProjectPath, Settings);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Cake.Common.Tools.DotNet.Sln.List;

namespace Cake.Common.Tests.Fixtures.Tools.DotNet.Sln.List
{
internal sealed class DotNetSlnListerFixture : DotNetFixture<DotNetSlnListSettings>
{
public string Solution { get; set; }

public string StandardError { get; set; }

public IEnumerable<string> Projects { get; private set; }

public void GivenProjectsResult()
{
ProcessRunner.Process.SetStandardOutput(new string[]
{
"Project(s)",
"--------------------",
"Common\\Common.AspNetCore\\Common.AspNetCore.csproj",
"Common\\Common.Messaging\\Common.Messaging.csproj",
"Common\\Common.Utilities\\Common.Utilities.csproj"
});
}

public void GivenErrorResult()
{
ProcessRunner.Process.SetStandardError(new string[]
{
StandardError
});
}

protected override void RunTool()
{
var tool = new DotNetSlnLister(FileSystem, Environment, ProcessRunner, Tools);
Projects = tool.List(Solution, Settings);
}
}
}
Loading

0 comments on commit 9d0a3c5

Please sign in to comment.