Test CMake projects using CTest on GitHub Actions.
This action wraps the ctest
command for testing CMake projects.
It provides a better syntax for specifying test options compared to calling the ctest
command directly.
By default, this action invokes ctest
with the --output-on-failure
and --no-tests=error
options set. These options are configured to display the output only in case of failure and to prevent this action from testing a project that lacks any tests.
Name | Type | Description |
---|---|---|
test-dir |
Path | Specifies the directory in which to look for tests. It defaults to the build directory. |
build-config |
String | Chooses the configuration to test. |
tests-regex |
Regex pattern | Runs tests matching the regular expression. |
verbose |
true or false |
Enable verbose output from tests. |
args |
Multiple strings | Additional arguments to pass during the CTest run. |
This example demonstrates how to use this action to test a CMake project in a GitHub Actions workflow:
name: Test
on:
push:
jobs:
test-project:
name: Test Project
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Build Project
uses: threeal/cmake-action@v2.1.0
- name: Test Project
uses: threeal/ctest-action@v1.1.0
By default, this action runs tests in the build
directory. To run tests in a different directory, set the test-dir
input:
- name: Test Project
uses: threeal/ctest-action@v1.1.0
with:
test-dir: sample/build
Some projects may require a build configuration to be specified to run tests. To specify the build configuration, set the build-config
input:
- name: Test Project
uses: threeal/ctest-action@v1.1.0
with:
build-config: Debug
A regular expression pattern can be provided by specifying the tests-regex
input to run only specific tests that match the given pattern:
- name: Test Project
uses: threeal/ctest-action@v1.1.0
with:
tests-regex: ^test sample
This project is licensed under the terms of the MIT License.
Copyright © 2023-2024 Alfi Maulana