Skip to content

Commit

Permalink
Merge pull request #46 from louisfischer/cake-frosting
Browse files Browse the repository at this point in the history
(GH-43) Add Support for running Cake Frosting Projects
  • Loading branch information
ecampidoglio authored Dec 4, 2024
2 parents e313098 + abbd3d6 commit 1ddb5d1
Show file tree
Hide file tree
Showing 14 changed files with 673 additions and 111 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,58 @@ jobs:
string-parameter: 'value'
numeric-parameter: 3
boolean-parameter: true
test-with-frosting:
name: Test with Cake Frosting
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
env:
project-directory: integrationtests/frosting
steps:
- name: Get the sources
uses: actions/checkout@v1
- name: Install Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install the .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Run a specific Cake Frosting project
uses: ./
with:
project-path: ${{ env.project-directory}}/Build.csproj
- name: Run a specific target
uses: ./
with:
project-path: ${{ env.project-directory}}/Build.csproj
target: Successful-Task
- name: Run with a specific verbosity level
uses: ./
env:
EXPECTED_VERBOSITY: Diagnostic
with:
verbosity: Diagnostic
project-path: ${{ env.project-directory}}/Build.csproj
target: Test-Verbosity
- name: Do a dry run
uses: ./
with:
dry-run: true
project-path: ${{ env.project-directory }}/Build.csproj
target: Test-Dry-Run
- name: Run with custom script parameters
uses: ./
env:
EXPECTED_STRING_ARGUMENT: '''value'''
EXPECTED_NUMERIC_ARGUMENT: '3'
EXPECTED_BOOLEAN_ARGUMENT: 'true'
with:
project-path: ${{ env.project-directory }}/Build.csproj
target: Test-Script-Parameters
arguments: |
string-parameter: 'value'
numeric-parameter: 3
boolean-parameter: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ typings/

# Secret files
.secrets

# bin folder
bin/

# obj folder
obj/
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![GitHub Marketplace](https://img.shields.io/github/v/release/cake-build/cake-action?label=Marketplace&sort=semver)](https://github.com/marketplace/actions/cake-action) [![GitHub Actions Build](https://github.com/cake-build/cake-action/workflows/Build/badge.svg)](https://github.com/cake-build/cake-action/actions?workflow=Build) [![GitHub Actions Tests](https://github.com/cake-build/cake-action/workflows/Tests/badge.svg)](https://github.com/cake-build/cake-action/actions?workflow=Tests) [![Coveralls](https://coveralls.io/repos/github/cake-build/cake-action/badge.svg?branch=master)](https://coveralls.io/github/cake-build/cake-action?branch=master)

This action allows you to run a Cake script from your GitHub Actions workflow without having to use a [bootstrapper](https://github.com/cake-build/resources).
This action allows you to run a Cake script or Cake Frosting project from your GitHub Actions workflow without having to use a [bootstrapper](https://github.com/cake-build/resources).

## Usage

Expand All @@ -14,13 +14,15 @@ steps:
uses: cake-build/cake-action@v2
```
The Cake action will look for a script named `build.cake` in your repository's root directory and run it for you using the [Cake Tool](https://www.nuget.org/packages/Cake.Tool/). All output from the Cake script will be automatically redirected to the build log for inspection.
The Cake action will look for a script named `build.cake` in your repository's root directory and run it for you using the [Cake Tool](https://www.nuget.org/packages/Cake.Tool/). You can also specify the path to your Cake script using the `script-path` option. If you are using a [Cake Frosting](https://cakebuild.net/docs/running-builds/runners/cake-frosting) project instead, you must specify the path to your `.csproj` file with the `project-path` parameter.

All output from the Cake script or Cake Frosting project is automatically redirected to the build log for inspection.

## Inputs

### `script-path`

If your script is in another location, you can specify the path with the `script-path` [input parameter](https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith):
If your Cake script is located somewhere other than the root directory of your project, you can specify its path using the `script-path` [input parameter](https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith):

```yml
steps:
Expand All @@ -30,9 +32,21 @@ steps:
script-path: path/to/script.cake
```

### `project-path`

If you are using [Cake Frosting](https://cakebuild.net/docs/running-builds/runners/cake-frosting), you must specify the path to the project file with the `project-path` [input parameter](https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith):

```yml
steps:
- name: Run Cake Frosting
uses: cake-build/cake-action@v2
with:
project-path: path/to/build.csproj
```

### `target`

You'll likely want to specify which task to run out of the ones defined in the Cake script. For that, you can use the `target` parameter:
You'll likely want to specify which task to run out of the ones defined in the Cake script or Cake Frosting project. For that, you can use the `target` parameter:

```yml
steps:
Expand Down Expand Up @@ -88,7 +102,9 @@ The arguments are defined in a [multi-line string literal](https://yaml.org/spec

### `cake-version`

By default, the Cake action will run your script using the latest _stable_ version of the [Cake .NET Core Global tool](https://www.nuget.org/packages/Cake.Tool/). However, if for some reason you want to [use a specific version of Cake](https://cakebuild.net/docs/tutorials/pinning-cake-version) (for compatibility with older third-party addins, for example), you can do so by specifying the version number in the `cake-version` parameter:
By default, the Cake action runs your script using the latest _stable_ version of the [Cake .NET Core Global tool](https://www.nuget.org/packages/Cake.Tool/).

If you need to [use a specific version of Cake](https://cakebuild.net/docs/tutorials/pinning-cake-version) (e.g. for compatibility with older addins), you can specify it with the `cake-version` parameter:

```yml
steps:
Expand All @@ -98,7 +114,7 @@ steps:
cake-version: 0.30.0
```

If you're pinning your Cake version using a [tool manifest file](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#install-a-local-tool), then you can have the action restore any local tools, including Cake, by specifying `tool-manifest` as the argument for `cake-version`:
If you're pinning your Cake version using a [tool manifest file](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#install-a-local-tool), you can have the action restore any local tools, including Cake, by specifying `tool-manifest` as the argument for `cake-version`:

```yml
steps:
Expand All @@ -108,11 +124,13 @@ steps:
cake-version: tool-manifest
```

> :information_source: This option is ignored when [using Cake Frosting projects](#project-path).

### `cake-bootstrap`

As of [Cake 1.0.0](https://github.com/cake-build/cake/releases/tag/v1.0.0), any [custom modules](https://cakebuild.net/docs/fundamentals/modules) that you reference in your script are [bootstrapped automatically](https://github.com/cake-build/cake/issues/2833) upon running it.

If you're using an older version of Cake, however, you need to explicitly [bootstrap](https://cakebuild.net/docs/fundamentals/preprocessor-directives#module-directive) them before running the script. The Cake action can take care of this extra step for you by setting the `cake-bootstrap` parameter to `explicit`:
For older versions of Cake, you need to explicitly [bootstrap](https://cakebuild.net/docs/fundamentals/preprocessor-directives#module-directive) any referenced modules before running the script. The Cake action can handle this extra step for you by setting the `cake-bootstrap` parameter to `explicit`:

```yml
steps:
Expand All @@ -123,7 +141,7 @@ steps:
cake-version: 0.38.5
```

If you're using Cake 1.0.0 or later and wish to opt out of the automatic bootstrapping of modules, you can do so by setting the `cake-bootstrap` parameter to `skip`:
If you're using Cake 1.0.0 or later and wish to opt out of the automatic bootstrapping of modules, you can set the `cake-bootstrap` parameter to `skip`:

```yml
steps:
Expand All @@ -133,11 +151,13 @@ steps:
cake-bootstrap: skip
```

The default value is `auto`, which means that the modules will be automatically bootstrapped on Cake 1.0.0 or later.
The default value is `auto`, which means modules will be automatically bootstrapped on Cake 1.0.0 or later.

> :information_source: This option is ignored when [using Cake Frosting projects](#script-path).

## Cross-platform

Since the [Cake Tool](https://www.nuget.org/packages/Cake.Tool/) is built on .NET Core, the Cake action will run on any of the [virtual environments](https://help.github.com/en/github/automating-your-workflow-with-github-actions/software-in-virtual-environments-for-github-actions) supported by GitHub Actions, namely Linux, Windows and macOS.
Since the [Cake Tool](https://www.nuget.org/packages/Cake.Tool/) and [Cake Frosting](https://www.nuget.org/packages/Cake.Frosting) are built on .NET Core, the Cake action will run on any of the [virtual environments](https://help.github.com/en/github/automating-your-workflow-with-github-actions/software-in-virtual-environments-for-github-actions) supported by GitHub Actions, namely Linux, Windows and macOS.

This allows you to define your build step exactly _once_ and run it on multiple operating systems _in parallel_ by defining a [build matrix](https://help.github.com/en/github/automating-your-workflow-with-github-actions/configuring-a-workflow#configuring-a-build-matrix):

Expand Down
Loading

0 comments on commit 1ddb5d1

Please sign in to comment.