-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge pull request #47 from
threeal/default-to-no-build
Default to No Build
- Loading branch information
Showing
3 changed files
with
137 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,92 +8,124 @@ jobs: | |
default-usage: | ||
runs-on: ${{ matrix.os }}-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows, ubuntu, macos] | ||
steps: | ||
- name: Check out this repository | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Move test project to the working directory | ||
- name: Move the test project to the working directory | ||
run: mv test/* . | ||
|
||
- name: Use this action | ||
- name: Use the action | ||
uses: ./ | ||
|
||
- name: Run the build result | ||
run: ${{ matrix.os == 'windows' && 'build\Debug\hello_world.exe' || 'build/hello_world' }} | ||
- name: Try to test the project | ||
id: failed-step | ||
continue-on-error: true | ||
run: ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }} | ||
|
||
- name: Check on success | ||
if: steps.failed-step.outcome == 'success' | ||
run: exit 1 | ||
|
||
- name: Build and test the project | ||
run: | | ||
cmake --build build | ||
ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }} | ||
specified-dir-usage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out this repository | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use this action with specified directories | ||
- name: Use the action with specified directories | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
build-dir: output | ||
run-test: true | ||
test-args: -R hello_world | ||
|
||
- name: Check if the default build directory does not exist | ||
run: test ! -d build && test ! -d test/build | ||
shell: bash | ||
run: test ! -e build && test ! -e test/build | ||
|
||
- name: Build and test the project | ||
run: | | ||
cmake --build output | ||
ctest --test-dir output --output-on-failure --no-tests=error -R hello_world | ||
run-build-usage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use the action with run build enabled | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
run-build: true | ||
build-args: --target test_c --target test_cpp | ||
|
||
- name: Test the project | ||
run: ctest --test-dir test/build --output-on-failure --no-tests=error -R test | ||
|
||
run-test-usage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use the action with run test enabled | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
run-test: true | ||
test-args: -R hello_world | ||
|
||
additional-flags-usage: | ||
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
compiler: [gcc, msvc] | ||
steps: | ||
- name: Check out this repository | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use this action with additional compiler flags | ||
- name: Use the action with additional compiler flags | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
targets: test_c test_cpp | ||
run-test: true | ||
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }} | ||
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }} | ||
args: -D CHECK_SURPASS_WARNING=ON | ||
run-build: true | ||
build-args: --target test_c --target test_cpp | ||
run-test: true | ||
test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }} | ||
|
||
specified-compiler-usage: | ||
specified-generator-and-compiler-usage: | ||
runs-on: ${{ matrix.os }}-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows, ubuntu, macos] | ||
steps: | ||
- name: Check out this repository | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use this action with specified compilers | ||
- name: Use the action with specified generator and compilers | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
targets: test_c test_cpp | ||
run-test: true | ||
generator: Ninja | ||
c-compiler: clang | ||
cxx-compiler: clang++ | ||
args: -D CHECK_USING_CLANG=ON | ||
test-args: -R test | ||
|
||
specified-generator-usage: | ||
runs-on: ${{ matrix.os }}-latest | ||
strategy: | ||
matrix: | ||
os: [windows, ubuntu, macos] | ||
steps: | ||
- name: Check out this repository | ||
uses: actions/[email protected] | ||
|
||
- name: Use this action with a specified generator | ||
uses: ./ | ||
with: | ||
source-dir: test | ||
run-build: true | ||
build-args: --target test_c --target test_cpp | ||
run-test: true | ||
generator: Ninja | ||
test-args: -R hello_world | ||
test-args: -R test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,13 @@ | |
[![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:/threeal/cmake-action/actions/workflows/test.yml) | ||
|
||
Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https:/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:/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. | ||
- Option to test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.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,17 +22,18 @@ 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. | | ||
| `run-test` | `true` or `false` | If enabled, runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. | | ||
| `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. | | ||
| `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. | | ||
| `test-args` | Multiple strings | Additional arguments passed during the CTest run. | | ||
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. | | ||
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. | | ||
| `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 to pass when compiling C language files. | | ||
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. | | ||
| `args` | Multiple strings | Additional arguments to pass 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). It defaults to `false`. | | ||
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. | | ||
| `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`. | | ||
| `test-args` | Multiple strings | Additional arguments to pass 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,48 +49,46 @@ jobs: | |
build-project: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out this repository | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Configure and build this project | ||
- name: Configure the project | ||
uses: threeal/cmake-action@latest | ||
|
||
- name: Build the project | ||
runs: cmake --build build | ||
|
||
- name: Test the project | ||
runs: ctest --test-dir build | ||
``` | ||
> Note: You can replace `@latest` with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses). | ||
|
||
#### 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 | ||
``` | ||
|
||
#### Specify the Build Targets | ||
|
||
```yaml | ||
- name: Configure and build this project | ||
uses: threeal/cmake-action@latest | ||
with: | ||
targets: hello_mars hello_sun | ||
``` | ||
|
||
#### Run Unit Tests After Build | ||
#### Configure, Build, and Test in the Same Step | ||
|
||
```yaml | ||
- name: Configure, build, and test this project | ||
- name: Configure, build, and test the project | ||
uses: threeal/cmake-action@latest | ||
with: | ||
args: -DBUILD_TESTING=ON | ||
run-build: true | ||
run-test: true | ||
``` | ||
|
||
#### Using Ninja as the Generator and Clang as the Compiler | ||
|
||
```yaml | ||
- name: Configure and build this project | ||
- name: Configure and build the project | ||
uses: threeal/cmake-action@latest | ||
with: | ||
generator: Ninja | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters