feat: add the run-build input

This commit is contained in:
Alfi Maulana
2023-06-29 19:17:47 +07:00
parent be11a3a3dd
commit 3430da8dad
3 changed files with 61 additions and 38 deletions

View File

@@ -4,11 +4,12 @@
[![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
[![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)
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, builds the project using the `cmake --build` command, and optionally tests the project using the `ctest` command.
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.
## Features
- Configures and builds a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
- Configures a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
- Option to build a project using the `cmake --build` command.
- Option to test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
- Auto-detects and installs required dependencies.
- Supports specifying multiple CMake options directly from the Action inputs.
@@ -21,16 +22,17 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
| Name | Value Type | Description |
| --- | --- | --- |
| `source-dir` | Path | Source directory of the CMake project. Defaults to the current directory. |
| `build-dir` | Path | Build directory of the CMake project. Defaults to the `build` directory inside the source directory. |
| `targets` | Multiple strings | List of build targets. |
| `generator` | String | Build system generator for the CMake project. |
| `c-compiler` | String | Preferred executable for compiling C language files. |
| `cxx-compiler` | String | Preferred executable for compiling C++ language files. |
| `source-dir` | Path | The source directory of the CMake project. Defaults to the current directory. |
| `build-dir` | Path | The source directory of the CMake project.. Defaults to the `build` directory inside the source directory. |
| `targets` | Multiple strings | A list of build targets. |
| `generator` | String | The build system generator for the CMake project. |
| `c-compiler` | String | The preferred executable for compiling C language files. |
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. |
| `c-flags` | Multiple strings | Additional flags passed when compiling C language files. |
| `cxx-flags` | Multiple strings | Additional flags passed when compiling C++ language files. |
| `args` | Multiple strings | Additional arguments passed during CMake configuration. |
| `run-test` | `true` or `false` | If enabled, runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
| `args` | Multiple strings | Additional arguments passed during the CMake configuration. |
| `run-build` | `true` or `false` | If enabled, it builds the project using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
| `test-args` | Multiple strings | Additional arguments passed during the CTest run. |
> 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.
@@ -47,10 +49,10 @@ jobs:
build-project:
runs-on: ubuntu-latest
steps:
- name: Check out this repository
- name: Check out the repository
uses: actions/checkout@v3.3.0
- name: Configure and build this project
- name: Configure the project
uses: threeal/cmake-action@latest
```
@@ -59,32 +61,34 @@ jobs:
#### Specify the Source and Build Directories
```yaml
- name: Configure and build this project
- name: Configure the project
uses: threeal/cmake-action@latest
with:
source-dir: submodules
build-dir: submodules/out
```
#### Configure, Build, and Test in the Same Step
```yaml
- name: Configure, build, and test the project
uses: threeal/cmake-action@latest
with:
args: -DBUILD_TESTING=ON
run-build: true
run-test: true
```
#### Specify the Build Targets
```yaml
- name: Configure and build this project
uses: threeal/cmake-action@latest
with:
run-build: true
targets: hello_mars hello_sun
```
#### Run Unit Tests After Build
```yaml
- name: Configure, build, and test this project
uses: threeal/cmake-action@latest
with:
args: -DBUILD_TESTING=ON
run-test: true
```
#### Using Ninja as the Generator and Clang as the Compiler
```yaml