Skip to content

Commit 29a66b3

Browse files
committed
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 885b0a5 commit 29a66b3

25 files changed

Lines changed: 1484 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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 NSubstitute;
8+
9+
namespace Cake.Common.Tests.Fixtures.Build
10+
{
11+
internal sealed class RwxFixture
12+
{
13+
public ICakeEnvironment Environment { get; set; }
14+
15+
public RwxFixture()
16+
{
17+
Environment = Substitute.For<ICakeEnvironment>();
18+
}
19+
20+
public void IsRunningOnRwx()
21+
{
22+
Environment.GetEnvironmentVariable("RWX").Returns("true");
23+
}
24+
25+
public RwxProvider CreateRwxProvider()
26+
{
27+
return new RwxProvider(Environment);
28+
}
29+
}
30+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
49+
public RwxRunInfo CreateRunInfo()
50+
{
51+
return new RwxRunInfo(Environment);
52+
}
53+
54+
public RwxTaskInfo CreateTaskInfo()
55+
{
56+
return new RwxTaskInfo(Environment);
57+
}
58+
59+
public RwxActorInfo CreateActorInfo()
60+
{
61+
return new RwxActorInfo(Environment);
62+
}
63+
64+
public RwxGitInfo CreateGitInfo()
65+
{
66+
return new RwxGitInfo(Environment);
67+
}
68+
69+
public RwxEnvironmentInfo CreateEnvironmentInfo()
70+
{
71+
return new RwxEnvironmentInfo(Environment);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)