Skip to content

Commit

Permalink
docs: audit readme for release (#33)
Browse files Browse the repository at this point in the history
* docs(readme): shift usage section

* docs(readme): improve the project description

* docs(readme): improve the available inputs section

* docs(readme): improve example usages
  • Loading branch information
threeal authored Mar 21, 2024
1 parent d256434 commit ebd1f46
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 24 deletions.
71 changes: 50 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,77 @@
# CTest Action

Test your [CMake](https://cmake.org/) project with [CTest](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Testing%20With%20CMake%20and%20CTest.html) using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for testing a CMake project.
Test [CMake](https://cmake.org/) projects using [CTest](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Testing%20With%20CMake%20and%20CTest.html) on [GitHub Actions](https://github.com/features/actions).

## Features
This action wraps the [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command for testing CMake projects.
It provides a better syntax for specifying test options compared to calling the `ctest` command directly.

- Tests a CMake project with the [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
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.

## Usage
## Available Inputs

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).

### Inputs

| Name | Value Type | Description |
| Name | Type | Description |
| --- | --- | --- |
| `test-dir` | path | Specifies the directory in which to look for tests. It defaults to the `build` directory. |
| `build-config` | string | Choose the configuration to test. |
| `tests-regex` | Regex pattern | Run tests matching regular expression. |
| `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. |
| `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.
> **Note**: All inputs are optional.
## Example Usages

### Examples
This example demonstrates how to use this action to test a CMake project in a GitHub Actions workflow:

```yaml
name: Test
on:
push:
jobs:
test-project:
name: Test Project
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
- name: Checkout
uses: actions/checkout@v4.1.2

- name: Configure and build the project
uses: threeal/cmake-action@v1.2.0
- name: Configure and Build Project
uses: threeal/cmake-action@v1.3.0
with:
run-build: true

- name: Test the project
uses: threeal/ctest-action@main
- name: Test Project
uses: threeal/ctest-action@v1.0.0
```
### Testing in a Different Directory
By default, this action runs tests in the `build` directory. To run tests in a different directory, set the `test-dir` input:

```yaml
- name: Test Project
uses: threeal/ctest-action@v1.0.0
with:
test-dir: sample/build
```

### Testing a Specific Build Configuration

Some projects may require a build configuration to be specified to run tests. To specify the build configuration, set the `build-config` input:

```yaml
- name: Test Project
uses: threeal/ctest-action@v1.0.0
with:
build-config: Debug
```

### Testing Specific Tests

A regular expression pattern can be provided by specifying the `tests-regex` input to run only specific tests that match the given pattern:

```yaml
- name: Test Project
uses: threeal/ctest-action@v1.0.0
with:
tests-regex: ^test sample
```

## License
Expand Down
6 changes: 3 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CTest Action
author: Alfi Maulana
description: Test your CMake project with CTest
description: Test CMake projects using CTest
branding:
icon: terminal
color: gray-dark
Expand All @@ -9,9 +9,9 @@ inputs:
description: Specifies the directory in which to look for tests
default: build
build-config:
description: Choose the configuration to test
description: Chooses the configuration to test
tests-regex:
description: Run tests matching regular expression
description: Runs tests matching the regular expression
args:
description: Additional arguments to pass during the CTest run
runs:
Expand Down

0 comments on commit ebd1f46

Please # to comment.