Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .rwx/cake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
on:
github:
pull_request:
init:
commit-sha: ${{ event.git.sha }}
push:
- if: ${{ event.git.branch == 'develop' || event.git.branch == 'main' || starts-with(event.git.branch, 'hotfix/') }}
init:
commit-sha: ${{ event.git.sha }}
cli:
init:
commit-sha: ${{ event.git.sha }}

base:
image: ubuntu:26.04
config: rwx/base 1.1.1

tasks:
- key: code
call: git/clone 2.0.7
with:
repository: https://github.com/cake-build/cake.git
ref: ${{ init.commit-sha }}
fetch-full-depth: true
preserve-git-dir: true

- key: libicu-dev
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libicu-dev

- key: build
use: [code, libicu-dev]
run: |
# We clone at a commit SHA, so HEAD is detached; GitVersion needs a named branch ref.
# Use plumbing commands so the working tree (including any patched files) is untouched.
git branch -f develop HEAD
git symbolic-ref HEAD refs/heads/develop

./build.sh --target=Rwx --integration-tests-target=Cake.Common.Build.RwxProvider
env:
CAKE_INSTALL_SUPPORTED_SDKS: "true"
NuGetAudit: "false"

- key: validate-output-artifact
use: [code, build]
run: |
CONTENTS=$(cat "$ARTIFACT_PATH")
if [ "$CONTENTS" != "cake integration test" ]; then
echo "Integration tests artifact contents are incorrect: '$CONTENTS'"
exit 1
fi
echo "Integration tests artifact contents are correct: $CONTENTS"
env:
ARTIFACT_PATH: ${{ tasks.build.artifacts['cake-rwx-artifact.txt'] }}

- key: validate-output-value
use: [code, build]
run: |
if [ "$OUTPUT_VALUE" != "ok" ]; then
echo "Output value contents are incorrect: '$CONTENTS'"
exit 1
fi
echo "Output value contents are correct: $CONTENTS"
env:
OUTPUT_VALUE: ${{ tasks.build.values.cake_integration_test }}

- key: validate-environment-variable
use: [code, build]
run: |
if [ "$CAKE_INTEGRATION_TEST" != "ok" ]; then
echo "Environment variable contents are incorrect: '$CAKE_INTEGRATION_TEST'"
exit 1
fi
echo "Environment variable contents are correct: $CAKE_INTEGRATION_TEST"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Cake (C# Make) is a build automation system with a C# DSL to do things like comp
| GitLab | Debian | [![pipeline status](https://gitlab.com/cake-build/cake/badges/develop/pipeline.svg)](https://gitlab.com/cake-build/cake/commits/develop) | |
| 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) | |
| 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) |
| 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) |

## Code Coverage

Expand Down
3 changes: 3 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ Task("GitHubActions-Release")
Task("Travis")
.IsDependentOn("Run-Unit-Tests");

Task("Rwx")
.IsDependentOn("Run-Integration-Tests");

Task("ReleaseNotes")
.IsDependentOn("Create-Release-Notes");

Expand Down
54 changes: 54 additions & 0 deletions src/Cake.Common.Tests/Fixtures/Build/RwxCommandsFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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 Cake.Common.Build.Rwx.Commands;
using Cake.Core;
using Cake.Core.IO;
using Cake.Testing;
using NSubstitute;

namespace Cake.Common.Tests.Fixtures.Build
{
internal sealed class RwxCommandsFixture
{
public RwxInfoFixture InfoFixture { get; }

public ICakeEnvironment Environment => InfoFixture.Environment;

public FakeFileSystem FileSystem { get; }

public RwxCommandsFixture()
{
InfoFixture = new RwxInfoFixture();
Environment.WorkingDirectory.Returns("/work");
FileSystem = new FakeFileSystem(Environment);
FileSystem.CreateDirectory("/rwx/values");
FileSystem.CreateDirectory("/rwx/artifacts");
FileSystem.CreateDirectory("/rwx/env");
}

public RwxCommands CreateRwxCommands()
{
return new RwxCommands(Environment, FileSystem, InfoFixture.CreateEnvironmentInfo());
}

public RwxCommandsFixture WithNoRwxValues()
{
Environment.GetEnvironmentVariable("RWX_VALUES").Returns(null as string);
return this;
}

public RwxCommandsFixture WithNoRwxArtifacts()
{
Environment.GetEnvironmentVariable("RWX_ARTIFACTS").Returns(null as string);
return this;
}

public RwxCommandsFixture WithNoRwxEnv()
{
Environment.GetEnvironmentVariable("RWX_ENV").Returns(null as string);
return this;
}
}
}
34 changes: 34 additions & 0 deletions src/Cake.Common.Tests/Fixtures/Build/RwxFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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 Cake.Common.Build.Rwx;
using Cake.Core;
using Cake.Core.IO;
using NSubstitute;

namespace Cake.Common.Tests.Fixtures.Build
{
internal sealed class RwxFixture
{
public ICakeEnvironment Environment { get; set; }

public IFileSystem FileSystem { get; set; }

public RwxFixture()
{
Environment = Substitute.For<ICakeEnvironment>();
FileSystem = Substitute.For<IFileSystem>();
}

public void IsRunningOnRwx()
{
Environment.GetEnvironmentVariable("RWX").Returns("true");
}

public RwxProvider CreateRwxProvider()
{
return new RwxProvider(Environment, FileSystem);
}
}
}
84 changes: 84 additions & 0 deletions src/Cake.Common.Tests/Fixtures/Build/RwxInfoFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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 Cake.Common.Build.Rwx.Data;
using Cake.Core;
using NSubstitute;

namespace Cake.Common.Tests.Fixtures.Build
{
internal sealed class RwxInfoFixture
{
public ICakeEnvironment Environment { get; set; }

public RwxInfoFixture()
{
Environment = Substitute.For<ICakeEnvironment>();

// RwxEnvironmentInfo
Environment.GetEnvironmentVariable("CI").Returns("true");
Environment.GetEnvironmentVariable("RWX").Returns("true");

// RwxRunInfo
Environment.GetEnvironmentVariable("RWX_RUN_ID").Returns("01J9ABCDEFG");
Environment.GetEnvironmentVariable("RWX_RUN_TITLE").Returns("Build and test");
Environment.GetEnvironmentVariable("RWX_RUN_URL").Returns("https://cloud.rwx.com/runs/01J9ABCDEFG");

// RwxTaskInfo
Environment.GetEnvironmentVariable("RWX_TASK_ID").Returns("01J9TASKABC");
Environment.GetEnvironmentVariable("RWX_TASK_URL").Returns("https://cloud.rwx.com/tasks/01J9TASKABC");
Environment.GetEnvironmentVariable("RWX_TASK_ATTEMPT_NUMBER").Returns("2");

// RwxActorInfo
Environment.GetEnvironmentVariable("RWX_ACTOR_ID").Returns("usr_12345");
Environment.GetEnvironmentVariable("RWX_ACTOR").Returns("octocat");

// RwxGitInfo
Environment.GetEnvironmentVariable("RWX_GIT_REPOSITORY_URL").Returns("https://github.com/cake-build/cake.git");
Environment.GetEnvironmentVariable("RWX_GIT_REPOSITORY_NAME").Returns("cake-build/cake");
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_SHA").Returns("0123456789abcdef0123456789abcdef01234567");
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_MESSAGE").Returns("Add RWX build provider\n\nMore details here.");
Environment.GetEnvironmentVariable("RWX_GIT_COMMIT_SUMMARY").Returns("Add RWX build provider");
Environment.GetEnvironmentVariable("RWX_GIT_COMMITTER_NAME").Returns("Octo Cat");
Environment.GetEnvironmentVariable("RWX_GIT_COMMITTER_EMAIL").Returns("octocat@example.com");
Environment.GetEnvironmentVariable("RWX_GIT_REF").Returns("refs/heads/main");
Environment.GetEnvironmentVariable("RWX_GIT_REF_NAME").Returns("main");

// RwxRuntimeInfo
Environment.GetEnvironmentVariable("RWX_VALUES").Returns("/rwx/values");
Environment.GetEnvironmentVariable("RWX_ARTIFACTS").Returns("/rwx/artifacts");
Environment.GetEnvironmentVariable("RWX_ENV").Returns("/rwx/env");
}

public RwxRunInfo CreateRunInfo()
{
return new RwxRunInfo(Environment);
}

public RwxTaskInfo CreateTaskInfo()
{
return new RwxTaskInfo(Environment);
}

public RwxActorInfo CreateActorInfo()
{
return new RwxActorInfo(Environment);
}

public RwxGitInfo CreateGitInfo()
{
return new RwxGitInfo(Environment);
}

public RwxRuntimeInfo CreateRuntimeInfo()
{
return new RwxRuntimeInfo(Environment);
}

public RwxEnvironmentInfo CreateEnvironmentInfo()
{
return new RwxEnvironmentInfo(Environment);
}
}
}
Loading
Loading