Skip to content

Commit 84d919b

Browse files
robinaughdevlead
authored andcommitted
Add RWX as a build provider
Adds Cake.Common.Build.Rwx alongside the 14 existing build providers, exposing IsRunningOnRwx and BuildSystem.Rwx.Environment.{Run,Task,Actor} populated from the documented RWX env var contract (https://www.rwx.com/docs/environment-variables). Detection is via the RWX env var; RWX does not currently expose a PR identifier so this provider does not contribute to BuildSystem.IsPullRequest.
1 parent 4ad5f9b commit 84d919b

30 files changed

Lines changed: 2222 additions & 84 deletions

.rwx/cake.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
on:
2+
github:
3+
pull_request:
4+
init:
5+
commit-sha: ${{ event.git.sha }}
6+
push:
7+
- if: ${{ event.git.branch == 'develop' || event.git.branch == 'main' || starts-with(event.git.branch, 'hotfix/') }}
8+
init:
9+
commit-sha: ${{ event.git.sha }}
10+
cli:
11+
init:
12+
commit-sha: ${{ event.git.sha }}
13+
14+
base:
15+
image: ubuntu:26.04
16+
config: rwx/base 1.1.1
17+
18+
tasks:
19+
- key: code
20+
call: git/clone 2.0.7
21+
with:
22+
repository: https://github.com/cake-build/cake.git
23+
ref: ${{ init.commit-sha }}
24+
fetch-full-depth: true
25+
preserve-git-dir: true
26+
27+
- key: libicu-dev
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y --no-install-recommends libicu-dev
31+
32+
- key: build
33+
use: [code, libicu-dev]
34+
run: |
35+
# We clone at a commit SHA, so HEAD is detached; GitVersion needs a named branch ref.
36+
# Use plumbing commands so the working tree (including any patched files) is untouched.
37+
git branch -f develop HEAD
38+
git symbolic-ref HEAD refs/heads/develop
39+
40+
./build.sh --target=Rwx --integration-tests-target=Cake.Common.Build.RwxProvider
41+
env:
42+
CAKE_INSTALL_SUPPORTED_SDKS: "true"
43+
NuGetAudit: "false"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Cake (C# Make) is a build automation system with a C# DSL to do things like comp
2727
| GitLab | Debian | [![pipeline status](https://gitlab.com/cake-build/cake/badges/develop/pipeline.svg)](https://gitlab.com/cake-build/cake/commits/develop) | |
2828
| GitHub | Windows / Ubuntu/ macOS | [![Build Status](https://github.com/cake-build/cake/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/cake-build/cake/actions/workflows/build.yml) | |
2929
| Woodpecker CI | Debian | [![Woodpecker CI status](https://ci.codeberg.org/api/badges/15091/status.svg)](https://ci.codeberg.org/repos/15091) | [![Woodpecker CI Status](https://ci.codeberg.org/api/badges/15091/status.svg)](https://ci.codeberg.org/repos/15091) |
30+
| RWX | Ubuntu | [![RWX Build Status](https://cloud.rwx.com/status_badges/cake.svg?branch=develop&definition=.rwx%2Fcake.yml&repo=cake)](https://cloud.rwx.com/runs/latest/cake?branch=develop&definition=.rwx%2Fcake.yml&repo=cake) | [![RWX Build Status](https://cloud.rwx.com/status_badges/cake.svg?branch=develop&definition=.rwx%2Fcake.yml&repo=cake)](https://cloud.rwx.com/runs/latest/cake?branch=develop&definition=.rwx%2Fcake.yml&repo=cake) |
3031

3132
## Code Coverage
3233

build.cake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ Task("GitHubActions-Release")
492492
Task("Travis")
493493
.IsDependentOn("Run-Unit-Tests");
494494

495+
Task("Rwx")
496+
.IsDependentOn("Run-Integration-Tests");
497+
495498
Task("ReleaseNotes")
496499
.IsDependentOn("Create-Release-Notes");
497500

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.Build.Rwx.Commands;
6+
using Cake.Core;
7+
using Cake.Core.IO;
8+
using Cake.Testing;
9+
using NSubstitute;
10+
11+
namespace Cake.Common.Tests.Fixtures.Build
12+
{
13+
internal sealed class RwxCommandsFixture
14+
{
15+
public RwxInfoFixture InfoFixture { get; }
16+
17+
public ICakeEnvironment Environment => InfoFixture.Environment;
18+
19+
public FakeFileSystem FileSystem { get; }
20+
21+
public RwxCommandsFixture()
22+
{
23+
InfoFixture = new RwxInfoFixture();
24+
Environment.WorkingDirectory.Returns("/work");
25+
FileSystem = new FakeFileSystem(Environment);
26+
FileSystem.CreateDirectory("/rwx/values");
27+
FileSystem.CreateDirectory("/rwx/artifacts");
28+
}
29+
30+
public RwxCommands CreateRwxCommands()
31+
{
32+
return new RwxCommands(Environment, FileSystem, InfoFixture.CreateEnvironmentInfo());
33+
}
34+
35+
public RwxCommandsFixture WithNoRwxValues()
36+
{
37+
Environment.GetEnvironmentVariable("RWX_VALUES").Returns(null as string);
38+
return this;
39+
}
40+
41+
public RwxCommandsFixture WithNoRwxArtifacts()
42+
{
43+
Environment.GetEnvironmentVariable("RWX_ARTIFACTS").Returns(null as string);
44+
return this;
45+
}
46+
}
47+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.Build.Rwx;
6+
using Cake.Core;
7+
using Cake.Core.IO;
8+
using NSubstitute;
9+
10+
namespace Cake.Common.Tests.Fixtures.Build
11+
{
12+
internal sealed class RwxFixture
13+
{
14+
public ICakeEnvironment Environment { get; set; }
15+
16+
public IFileSystem FileSystem { get; set; }
17+
18+
public RwxFixture()
19+
{
20+
Environment = Substitute.For<ICakeEnvironment>();
21+
FileSystem = Substitute.For<IFileSystem>();
22+
}
23+
24+
public void IsRunningOnRwx()
25+
{
26+
Environment.GetEnvironmentVariable("RWX").Returns("true");
27+
}
28+
29+
public RwxProvider CreateRwxProvider()
30+
{
31+
return new RwxProvider(Environment, FileSystem);
32+
}
33+
}
34+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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.Build.Rwx.Data;
6+
using Cake.Core;
7+
using NSubstitute;
8+
9+
namespace Cake.Common.Tests.Fixtures.Build
10+
{
11+
internal sealed class RwxInfoFixture
12+
{
13+
public ICakeEnvironment Environment { get; set; }
14+
15+
public RwxInfoFixture()
16+
{
17+
Environment = Substitute.For<ICakeEnvironment>();
18+
19+
// RwxEnvironmentInfo
20+
Environment.GetEnvironmentVariable("CI").Returns("true");
21+
Environment.GetEnvironmentVariable("RWX").Returns("true");
22+
23+
// RwxRunInfo
24+
Environment.GetEnvironmentVariable("RWX_RUN_ID").Returns("01J9ABCDEFG");
25+
Environment.GetEnvironmentVariable("RWX_RUN_TITLE").Returns("Build and test");
26+
Environment.GetEnvironmentVariable("RWX_RUN_URL").Returns("https://cloud.rwx.com/runs/01J9ABCDEFG");
27+
28+
// RwxTaskInfo
29+
Environment.GetEnvironmentVariable("RWX_TASK_ID").Returns("01J9TASKABC");
30+
Environment.GetEnvironmentVariable("RWX_TASK_URL").Returns("https://cloud.rwx.com/tasks/01J9TASKABC");
31+
Environment.GetEnvironmentVariable("RWX_TASK_ATTEMPT_NUMBER").Returns("2");
32+
33+
// RwxActorInfo
34+
Environment.GetEnvironmentVariable("RWX_ACTOR_ID").Returns("usr_12345");
35+
Environment.GetEnvironmentVariable("RWX_ACTOR").Returns("octocat");
36+
37+
// RwxGitInfo
38+
Environment.GetEnvironmentVariable("RWX_GIT_REPOSITORY_URL").Returns("https://github.com/cake-build/cake.git");
39+
Environment.GetEnvironmentVariable("RWX_GIT_REPOSITORY_NAME").Returns("cake-build/cake");
40+
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_SHA").Returns("0123456789abcdef0123456789abcdef01234567");
41+
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_MESSAGE").Returns("Add RWX build provider\n\nMore details here.");
42+
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_SUMMARY").Returns("Add RWX build provider");
43+
Environment.GetEnvironmentVariable("RWX_GIT_COMMITTER_NAME").Returns("Octo Cat");
44+
Environment.GetEnvironmentVariable("RWX_GIT_COMMITTER_EMAIL").Returns("octocat@example.com");
45+
Environment.GetEnvironmentVariable("RWX_GIT_REF").Returns("refs/heads/main");
46+
Environment.GetEnvironmentVariable("RWX_GIT_REF_NAME").Returns("main");
47+
48+
// RwxRuntimeInfo
49+
Environment.GetEnvironmentVariable("RWX_VALUES").Returns("/rwx/values");
50+
Environment.GetEnvironmentVariable("RWX_ARTIFACTS").Returns("/rwx/artifacts");
51+
}
52+
53+
public RwxRunInfo CreateRunInfo()
54+
{
55+
return new RwxRunInfo(Environment);
56+
}
57+
58+
public RwxTaskInfo CreateTaskInfo()
59+
{
60+
return new RwxTaskInfo(Environment);
61+
}
62+
63+
public RwxActorInfo CreateActorInfo()
64+
{
65+
return new RwxActorInfo(Environment);
66+
}
67+
68+
public RwxGitInfo CreateGitInfo()
69+
{
70+
return new RwxGitInfo(Environment);
71+
}
72+
73+
public RwxRuntimeInfo CreateRuntimeInfo()
74+
{
75+
return new RwxRuntimeInfo(Environment);
76+
}
77+
78+
public RwxEnvironmentInfo CreateEnvironmentInfo()
79+
{
80+
return new RwxEnvironmentInfo(Environment);
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)