Skip to content

Commit 59b65a5

Browse files
authored
chore: merge pull request #49 from threeal/main
Version 1.2.0 Release
2 parents 5be43ab + f1a0479 commit 59b65a5

File tree

6 files changed

+178
-126
lines changed

6 files changed

+178
-126
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ updates:
44
directory: /
55
schedule:
66
interval: daily
7+
commit-message:
8+
prefix: chore

.github/workflows/test.yml

Lines changed: 76 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,131 @@
11
name: test
22
on:
33
workflow_dispatch:
4+
pull_request:
45
push:
6+
branches: [latest, main]
57
jobs:
68
default-usage:
79
runs-on: ${{ matrix.os }}-latest
810
strategy:
11+
fail-fast: false
912
matrix:
1013
os: [windows, ubuntu, macos]
1114
steps:
12-
- name: Check out this repository
13-
uses: actions/checkout@v3.3.0
15+
- name: Checkout the repository
16+
uses: actions/checkout@v3.5.3
1417

15-
- name: Move test project to the working directory
18+
- name: Move the test project to the working directory
1619
run: mv test/* .
1720

18-
- name: Use this action
21+
- name: Use the action
1922
uses: ./
2023

21-
- name: Run the build result
22-
run: ${{ matrix.os == 'windows' && 'build\Debug\hello_world.exe' || 'build/hello_world' }}
24+
- name: Try to test the project
25+
id: failed-step
26+
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+
29+
- name: Check on success
30+
if: steps.failed-step.outcome == 'success'
31+
run: exit 1
32+
33+
- name: Build and test the project
34+
run: |
35+
cmake --build build
36+
ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
2337
2438
specified-dir-usage:
2539
runs-on: ubuntu-latest
2640
steps:
27-
- name: Check out this repository
28-
uses: actions/checkout@v3.3.0
41+
- name: Checkout the repository
42+
uses: actions/checkout@v3.5.3
2943

30-
- name: Use this action with specified directories
44+
- name: Use the action with specified directories
3145
uses: ./
3246
with:
3347
source-dir: test
3448
build-dir: output
35-
run-test: true
36-
test-args: -R hello_world
3749

3850
- name: Check if the default build directory does not exist
39-
run: test ! -d build && test ! -d test/build
51+
shell: bash
52+
run: test ! -e build && test ! -e test/build
53+
54+
- name: Build and test the project
55+
run: |
56+
cmake --build output
57+
ctest --test-dir output --output-on-failure --no-tests=error -R hello_world
58+
59+
run-build-usage:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout the repository
63+
uses: actions/[email protected]
64+
65+
- name: Use the action with run build enabled
66+
uses: ./
67+
with:
68+
source-dir: test
69+
run-build: true
70+
build-args: --target test_c --target test_cpp
71+
72+
- name: Test the project
73+
run: ctest --test-dir test/build --output-on-failure --no-tests=error -R test
74+
75+
run-test-usage:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Checkout the repository
79+
uses: actions/[email protected]
80+
81+
- name: Use the action with run test enabled
82+
uses: ./
83+
with:
84+
source-dir: test
85+
run-test: true
86+
test-args: -R hello_world
4087

4188
additional-flags-usage:
4289
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
4390
strategy:
91+
fail-fast: false
4492
matrix:
4593
compiler: [gcc, msvc]
4694
steps:
47-
- name: Check out this repository
48-
uses: actions/checkout@v3.3.0
95+
- name: Checkout the repository
96+
uses: actions/checkout@v3.5.3
4997

50-
- name: Use this action with additional compiler flags
98+
- name: Use the action with additional compiler flags
5199
uses: ./
52100
with:
53101
source-dir: test
54-
targets: test_c test_cpp
55-
run-test: true
56102
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
57103
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
58-
args: -D CHECK_SURPASS_WARNING=ON
104+
options: CHECK_SURPASS_WARNING=ON
105+
run-build: true
106+
build-args: --target test_c --target test_cpp
107+
run-test: true
59108
test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }}
60109

61-
specified-compiler-usage:
110+
specified-generator-and-compiler-usage:
62111
runs-on: ${{ matrix.os }}-latest
63112
strategy:
113+
fail-fast: false
64114
matrix:
65115
os: [windows, ubuntu, macos]
66116
steps:
67-
- name: Check out this repository
68-
uses: actions/checkout@v3.3.0
117+
- name: Checkout the repository
118+
uses: actions/checkout@v3.5.3
69119

70-
- name: Use this action with specified compilers
120+
- name: Use the action with specified generator and compilers
71121
uses: ./
72122
with:
73123
source-dir: test
74-
targets: test_c test_cpp
75-
run-test: true
76124
generator: Ninja
77125
c-compiler: clang
78126
cxx-compiler: clang++
79-
args: -D CHECK_USING_CLANG=ON
80-
test-args: -R test
81-
82-
specified-generator-usage:
83-
runs-on: ${{ matrix.os }}-latest
84-
strategy:
85-
matrix:
86-
os: [windows, ubuntu, macos]
87-
steps:
88-
- name: Check out this repository
89-
uses: actions/[email protected]
90-
91-
- name: Use this action with a specified generator
92-
uses: ./
93-
with:
94-
source-dir: test
127+
options: CHECK_USING_CLANG=ON
128+
run-build: true
129+
build-args: --target test_c --target test_cpp
95130
run-test: true
96-
generator: Ninja
97-
test-args: -R hello_world
131+
test-args: -R test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
.*
2+
!.git*
3+
14
build

README.md

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,96 @@
11
# CMake Action
22

3-
[![latest version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/)
4-
[![license](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
5-
[![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)
3+
[![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/)
4+
[![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
5+
[![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 a [CMake](https://cmake.org/) project on [GitHub Actions](https://github.com/features/actions).
8-
Use this action to simplify the workflow run of your CMake project.
9-
This action will configure a build environment for your project using the `cmake` command,
10-
then it will build your project by running a `cmake --build` command,
11-
and last it could test your 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 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.
128

139
## Features
1410

15-
- Configure and build a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
16-
- Optionally test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
17-
- Auto-detect and install required dependencies.
18-
- Specify multiple CMake options directly from the Action inputs.
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.
14+
- Auto-detects and installs required dependencies.
15+
- Supports specifying multiple CMake options directly from the Action inputs.
1916

2017
## Usage
2118

22-
For more information, see [action.yml](./action.yml) and [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).
19+
For more information, refer to [action.yml](./action.yml) and the [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).
2320

2421
### Inputs
2522

2623
| Name | Value Type | Description |
2724
| --- | --- | --- |
28-
| `source-dir` | Path | Source directory of the CMake project. Defaults to current directory. |
29-
| `build-dir` | Path | Build directory of the CMake project. Defaults to `build` directory inside the source directory. |
30-
| `targets` | Multiple strings | List of build targets. |
31-
| `run-test` | `true` or `false` | If enabled, run testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
32-
| `generator` | String | Build system generator of the CMake project. |
33-
| `c-compiler` | String | Preferred executable for compiling C language files. |
34-
| `cxx-compiler` | String | Preferred executable for compiling C++ language files. |
35-
| `c-flags` | Multiple strings | Additional flags passed when compiling C language files. |
36-
| `cxx-flags` | Multiple strings | Additional flags passed when compiling C++ language files. |
37-
| `args` | Multiple strings | Additional arguments passed during the CMake configuration. |
38-
| `test-args` | Multiple strings | Additional arguments passed during the CTest run. |
39-
40-
> Note: Multiple strings mean that the input could be specified with more than one value. Separate each value with a space or a new line.
41-
42-
> Note: All inputs are optional.
25+
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
26+
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
27+
| `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |
28+
| `c-compiler` | String | The preferred executable for compiling C language files. It appends the CMake configuration arguments with `-D CMAKE_C_COMPILER=[val]`. |
29+
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. It appends the CMake configuration arguments with `-D CMAKE_CXX_COMPILER=[val]`. |
30+
| `c-flags` | Multiple strings | Additional flags to pass when compiling C language files. It appends the CMake configuration arguments with `-D CMAKE_C_FLAGS=[vals]`. |
31+
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. It appends the CMake configuration arguments with `-D CMAKE_CXX_FLAGS=[vals]`. |
32+
| `options` | Multiple strings | Additional options to pass during the CMake configuration. It appends the CMake configuration arguments with each of `-D [val]`. |
33+
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
34+
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
35+
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
36+
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
37+
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
38+
39+
> **Note**: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
40+
41+
> **Note**: All inputs are optional.
4342
4443
### Examples
4544

4645
```yaml
47-
name: build
46+
name: Build
4847
on:
4948
push:
5049
jobs:
5150
build-project:
5251
runs-on: ubuntu-latest
5352
steps:
54-
- name: Check out this repository
55-
uses: actions/checkout@v3.3.0
53+
- name: Checkout the repository
54+
uses: actions/checkout@v3.5.3
5655

57-
- name: Configure and build this project
58-
uses: threeal/cmake-action@latest
56+
- name: Configure the project
57+
uses: threeal/cmake-action@main
58+
59+
- name: Build the project
60+
runs: cmake --build build
61+
62+
- name: Test the project
63+
runs: ctest --test-dir build
5964
```
6065
61-
> Note: You can replace `@latest` with any version you like. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
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).
6267

63-
#### Specify the Source and the Build Directories
68+
#### Specify the Source and Build Directories
6469

6570
```yaml
66-
- name: Configure and build this project
67-
uses: threeal/cmake-action@latest
71+
- name: Configure the project
72+
uses: threeal/cmake-action@main
6873
with:
6974
source-dir: submodules
7075
build-dir: submodules/out
7176
```
7277

73-
#### Specify the Build Targets
74-
75-
```yaml
76-
- name: Configure and build this project
77-
uses: threeal/cmake-action@latest
78-
with:
79-
targets: hello_mars hello_sun
80-
```
81-
82-
#### Run Unit Tests After Build
78+
#### Configure, Build, and Test in the Same Step
8379

8480
```yaml
85-
- name: Configure, build, and test this project
86-
uses: threeal/cmake-action@latest
81+
- name: Configure, build, and test the project
82+
uses: threeal/cmake-action@main
8783
with:
88-
args: -DBUILD_TESTING=ON
84+
options: BUILD_TESTING=ON
85+
run-build: true
8986
run-test: true
9087
```
9188

9289
#### Using Ninja as the Generator and Clang as the Compiler
9390

9491
```yaml
95-
- name: Configure and build this project
96-
uses: threeal/cmake-action@latest
92+
- name: Configure and build the project
93+
uses: threeal/cmake-action@main
9794
with:
9895
generator: Ninja
9996
c-compiler: clang

0 commit comments

Comments
 (0)