Skip to content

Commit b684818

Browse files
authored
chore: merge pull request #55 from threeal/main
Version 1.3.0 Release
2 parents 59b65a5 + 961184a commit b684818

File tree

3 files changed

+74
-37
lines changed

3 files changed

+74
-37
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ jobs:
1919
run: mv test/* .
2020

2121
- name: Use the action
22+
id: cmake-action
2223
uses: ./
2324

2425
- name: Try to test the project
2526
id: failed-step
2627
continue-on-error: true
27-
run: ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
28+
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
2829

2930
- name: Check on success
3031
if: steps.failed-step.outcome == 'success'
3132
run: exit 1
3233

3334
- name: Build and test the project
3435
run: |
35-
cmake --build build
36-
ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
36+
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
37+
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
3738
3839
specified-dir-usage:
3940
runs-on: ubuntu-latest
@@ -42,6 +43,7 @@ jobs:
4243
uses: actions/[email protected]
4344

4445
- name: Use the action with specified directories
46+
id: cmake-action
4547
uses: ./
4648
with:
4749
source-dir: test
@@ -53,8 +55,8 @@ jobs:
5355

5456
- name: Build and test the project
5557
run: |
56-
cmake --build output
57-
ctest --test-dir output --output-on-failure --no-tests=error -R hello_world
58+
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
59+
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
5860
5961
run-build-usage:
6062
runs-on: ubuntu-latest
@@ -63,14 +65,15 @@ jobs:
6365
uses: actions/[email protected]
6466

6567
- name: Use the action with run build enabled
68+
id: cmake-action
6669
uses: ./
6770
with:
6871
source-dir: test
6972
run-build: true
7073
build-args: --target test_c --target test_cpp
7174

7275
- name: Test the project
73-
run: ctest --test-dir test/build --output-on-failure --no-tests=error -R test
76+
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
7477

7578
run-test-usage:
7679
runs-on: ubuntu-latest
@@ -129,3 +132,16 @@ jobs:
129132
build-args: --target test_c --target test_cpp
130133
run-test: true
131134
test-args: -R test
135+
136+
specified-shell:
137+
runs-on: windows-latest
138+
steps:
139+
- name: Checkout the repository
140+
uses: actions/[email protected]
141+
142+
- name: Use the action with specified shell
143+
uses: ./
144+
with:
145+
shell: bash
146+
source-dir: test
147+
run-build: true

README.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
[![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
55
[![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml)
66

7-
Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for your CMake project. It configures the build environment using the `cmake` command, and optionally builds the project using the `cmake --build` command and tests the project using the `ctest` command.
7+
Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for configuring the build environment of a CMake project. It can also be optionally specified to build a CMake project using the `cmake --build` command and test it using the `ctest` command.
88

99
## Features
1010

11-
- Configures a project using the [`cmake`](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
12-
- Option to build a project using the `cmake --build` command.
13-
- Option to test a project using the [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
11+
- Configures a CMake project using the [`cmake`](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
12+
- Optionally builds a CMake project using the `cmake --build` command.
13+
- Optionally tests a CMake project using the [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
1414
- Auto-detects and installs required dependencies.
15-
- Supports specifying multiple CMake options directly from the Action inputs.
15+
- Supports specifying multiple CMake options directly from the action inputs.
1616

1717
## Usage
1818

@@ -22,6 +22,7 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
2222

2323
| Name | Value Type | Description |
2424
| --- | --- | --- |
25+
| `shell` | String | The shell to be used to run the commands. It defaults to `pwsh` on Windows and `bash` on Linux and macOS. Refer to [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell) for more information on available shell options. |
2526
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
2627
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
2728
| `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |
@@ -40,6 +41,12 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
4041
4142
> **Note**: All inputs are optional.
4243
44+
### Outputs
45+
46+
| Name | Value Type | Description |
47+
| --- | --- | --- |
48+
| `build-dir` | Path | The build directory of the CMake project. |
49+
4350
### Examples
4451

4552
```yaml
@@ -54,7 +61,7 @@ jobs:
5461
uses: actions/[email protected]
5562

5663
- name: Configure the project
57-
uses: threeal/cmake-action@main
64+
uses: threeal/cmake-action@v1.3.0
5865

5966
- name: Build the project
6067
runs: cmake --build build
@@ -63,34 +70,33 @@ jobs:
6370
runs: ctest --test-dir build
6471
```
6572
66-
> **Note**: You can replace `@main` with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
73+
> **Note**: You can replace [`v1.3.0`](https://github.com/threeal/cmake-action/releases/tag/v1.3.0) with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
6774

68-
#### Specify the Source and Build Directories
75+
#### Configure, Build, and Test in the Same Step
6976

7077
```yaml
71-
- name: Configure the project
72-
uses: threeal/cmake-action@main
78+
- name: Configure, build, and test the project
79+
uses: threeal/cmake-action@v1.3.0
7380
with:
74-
source-dir: submodules
75-
build-dir: submodules/out
81+
run-build: true
82+
run-test: true
7683
```
7784

78-
#### Configure, Build, and Test in the Same Step
85+
#### Specify the Source and Build Directories
7986

8087
```yaml
81-
- name: Configure, build, and test the project
82-
uses: threeal/cmake-action@main
88+
- name: Configure the project
89+
uses: threeal/cmake-action@v1.3.0
8390
with:
84-
options: BUILD_TESTING=ON
85-
run-build: true
86-
run-test: true
91+
source-dir: submodules
92+
build-dir: submodules/out
8793
```
8894

8995
#### Using Ninja as the Generator and Clang as the Compiler
9096

9197
```yaml
92-
- name: Configure and build the project
93-
uses: threeal/cmake-action@main
98+
- name: Configure the project
99+
uses: threeal/cmake-action@v1.3.0
94100
with:
95101
generator: Ninja
96102
c-compiler: clang

action.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: CMake Action
2-
description: Configure, build, and test a CMake project
2+
description: Configure, build, and test your CMake project
33
author: Alfi Maulana
44
branding:
55
color: gray-dark
66
icon: terminal
77
inputs:
8+
shell:
9+
description: The shell to be used to run the commands
10+
required: false
811
source-dir:
912
description: The source directory of the CMake project
1013
required: false
@@ -46,13 +49,24 @@ inputs:
4649
test-args:
4750
description: Additional arguments to pass during the CTest run
4851
required: false
52+
outputs:
53+
build-dir:
54+
description: The build directory of the CMake project
55+
value: ${{ steps.process-inputs.outputs.build-dir }}
4956
runs:
5057
using: composite
5158
steps:
5259
- name: Process the inputs
53-
id: process_inputs
60+
id: process-inputs
5461
shell: bash
5562
run: |
63+
if [ -n '${{ inputs.shell }}' ]; then
64+
SHELL='${{ inputs.shell }}'
65+
else
66+
SHELL='${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}'
67+
fi
68+
echo "shell=$SHELL" >> $GITHUB_OUTPUT
69+
5670
SOURCE_DIR="."
5771
if [ -n '${{ inputs.source-dir }}' ]; then
5872
SOURCE_DIR="${{ inputs.source-dir }}"
@@ -64,6 +78,7 @@ runs:
6478
elif [ -n "${{ inputs.source-dir }}" ]; then
6579
BUILD_DIR="${{ inputs.source-dir }}/build"
6680
fi
81+
echo "build-dir=$BUILD_DIR" >> $GITHUB_OUTPUT
6782
6883
ARGS="'$SOURCE_DIR' -B '$BUILD_DIR'"
6984
if [ -n '${{ inputs.generator }}' ]; then
@@ -87,22 +102,22 @@ runs:
87102
if [ -n '${{ inputs.args }}' ]; then
88103
ARGS="$ARGS ${{ inputs.args }}"
89104
fi
90-
echo "cmake_args=${ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
105+
echo "cmake-args=${ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
91106
92107
if [ '${{ inputs.run-build }}' == 'true' ] || [ '${{ inputs.run-test }}' == 'true' ]; then
93108
BUILD_ARGS="--build '$BUILD_DIR'"
94109
if [ -n '${{ inputs.build-args }}' ]; then
95110
BUILD_ARGS="$BUILD_ARGS ${{ inputs.build-args }}"
96111
fi
97-
echo "cmake_build_args=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
112+
echo "cmake-build-args=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
98113
fi
99114
100115
if [ '${{ inputs.run-test }}' == 'true' ]; then
101116
TEST_ARGS="--test-dir '$BUILD_DIR' --output-on-failure --no-tests=error"
102117
if [ -n '${{ inputs.test-args }}' ]; then
103118
TEST_ARGS="$TEST_ARGS ${{ inputs.test-args }}"
104119
fi
105-
echo "cmake_test_args=${TEST_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
120+
echo "cmake-test-args=${TEST_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
106121
fi
107122
108123
- name: Install Ninja
@@ -116,15 +131,15 @@ runs:
116131
esac
117132
118133
- name: Configure the CMake project
119-
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
120-
run: cmake ${{ steps.process_inputs.outputs.cmake_args }}
134+
shell: ${{ steps.process-inputs.outputs.shell }}
135+
run: cmake ${{ steps.process-inputs.outputs.cmake-args }}
121136

122137
- name: Build targets
123138
if: inputs.run-build != 'false' || inputs.run-test != 'false'
124-
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
125-
run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }}
139+
shell: ${{ steps.process-inputs.outputs.shell }}
140+
run: cmake ${{ steps.process-inputs.outputs.cmake-build-args }}
126141

127142
- name: Run tests
128143
if: inputs.run-test != 'false'
129-
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
130-
run: ctest ${{ steps.process_inputs.outputs.cmake_test_args }}
144+
shell: ${{ steps.process-inputs.outputs.shell }}
145+
run: ctest ${{ steps.process-inputs.outputs.cmake-test-args }}

0 commit comments

Comments
 (0)