mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-08 10:11:21 +00:00
feat: set run-build
input default to true
(#260)
This commit is contained in:
parent
422c660659
commit
7619e111ea
84
.github/workflows/test.yaml
vendored
84
.github/workflows/test.yaml
vendored
@ -70,56 +70,16 @@ jobs:
|
|||||||
- name: Move Project
|
- name: Move Project
|
||||||
run: mv test/* .
|
run: mv test/* .
|
||||||
|
|
||||||
- name: Configure Project
|
- name: Configure and Build Project
|
||||||
id: cmake-action
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
- name: Try to Test Project
|
- name: Test Project
|
||||||
id: failed-step
|
|
||||||
continue-on-error: true
|
|
||||||
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
|
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
|
||||||
|
|
||||||
- name: Previous Step Should Failed
|
|
||||||
if: steps.failed-step.outcome == 'success'
|
|
||||||
run: exit 1
|
|
||||||
|
|
||||||
- name: Build and Test Project
|
|
||||||
run: |
|
|
||||||
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
|
|
||||||
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
|
|
||||||
|
|
||||||
test-action-with-specified-dirs:
|
test-action-with-specified-dirs:
|
||||||
name: Test Action With Specified Directories
|
name: Test Action With Specified Directories
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4.1.2
|
|
||||||
with:
|
|
||||||
sparse-checkout: |
|
|
||||||
action.yml
|
|
||||||
dist
|
|
||||||
test
|
|
||||||
sparse-checkout-cone-mode: false
|
|
||||||
|
|
||||||
- name: Configure Project
|
|
||||||
id: cmake-action
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
source-dir: test
|
|
||||||
build-dir: output
|
|
||||||
|
|
||||||
- name: Default Build Directory Should Not Exist
|
|
||||||
shell: bash
|
|
||||||
run: test ! -e build && test ! -e test/build
|
|
||||||
|
|
||||||
- name: Build and Test Project
|
|
||||||
run: |
|
|
||||||
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
|
|
||||||
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
|
|
||||||
|
|
||||||
test-action-with-run-build:
|
|
||||||
name: Test Action With Run Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.2
|
uses: actions/checkout@v4.1.2
|
||||||
@ -135,11 +95,43 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source-dir: test
|
source-dir: test
|
||||||
run-build: true
|
build-dir: output
|
||||||
build-args: --target test_c --target test_cpp
|
|
||||||
|
- name: Default Build Directory Should Not Exist
|
||||||
|
shell: bash
|
||||||
|
run: test ! -e build && test ! -e test/build
|
||||||
|
|
||||||
- name: Test Project
|
- name: Test Project
|
||||||
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
|
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
|
||||||
|
|
||||||
|
test-action-without-run-build:
|
||||||
|
name: Test Action Without Run Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4.1.2
|
||||||
|
with:
|
||||||
|
sparse-checkout: |
|
||||||
|
action.yml
|
||||||
|
dist
|
||||||
|
test
|
||||||
|
sparse-checkout-cone-mode: false
|
||||||
|
|
||||||
|
- name: Configure Project
|
||||||
|
id: cmake-action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
source-dir: test
|
||||||
|
run-build: false
|
||||||
|
|
||||||
|
- name: Try to Test Project
|
||||||
|
id: failed-step
|
||||||
|
continue-on-error: true
|
||||||
|
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
|
||||||
|
|
||||||
|
- name: Previous Step Should Failed
|
||||||
|
if: steps.failed-step.outcome == 'success'
|
||||||
|
run: exit 1
|
||||||
|
|
||||||
test-action-with-additional-args:
|
test-action-with-additional-args:
|
||||||
name: Test Action With Additional Arguments
|
name: Test Action With Additional Arguments
|
||||||
@ -165,7 +157,6 @@ jobs:
|
|||||||
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
||||||
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
||||||
options: CHECK_SURPASS_WARNING=ON
|
options: CHECK_SURPASS_WARNING=ON
|
||||||
run-build: true
|
|
||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
|
|
||||||
test-action-with-custom-tools:
|
test-action-with-custom-tools:
|
||||||
@ -196,5 +187,4 @@ jobs:
|
|||||||
c-compiler: clang
|
c-compiler: clang
|
||||||
cxx-compiler: clang++
|
cxx-compiler: clang++
|
||||||
options: CHECK_USING_CLANG=ON
|
options: CHECK_USING_CLANG=ON
|
||||||
run-build: true
|
|
||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
|
27
README.md
27
README.md
@ -25,7 +25,7 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
|
|||||||
| `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]`. |
|
| `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]`. |
|
||||||
| `options` | Multiple strings | Additional options to pass during the CMake configuration. It appends the CMake configuration arguments with each of `-D [val]`. |
|
| `options` | Multiple strings | Additional options to pass during the CMake configuration. It appends the CMake configuration arguments with each of `-D [val]`. |
|
||||||
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
|
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
|
||||||
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
|
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `true`. |
|
||||||
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
|
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
|
||||||
|
|
||||||
> **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**: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
|
||||||
@ -52,29 +52,26 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.2
|
uses: actions/checkout@v4.1.2
|
||||||
|
|
||||||
- name: Configure Project
|
- name: Configure and Build Project
|
||||||
uses: threeal/cmake-action@v1.3.0
|
uses: threeal/cmake-action@main
|
||||||
|
|
||||||
- name: Build Project
|
|
||||||
runs: cmake --build build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: You can replace [`v1.3.0`](https://github.com/threeal/cmake-action/releases/tag/v1.3.0) with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
|
> **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).
|
||||||
|
|
||||||
#### Configure and Build in the Same Step
|
#### Configure Project Without Building
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure and Build Project
|
- name: Configure Project
|
||||||
uses: threeal/cmake-action@v1.3.0
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
run-build: true
|
run-build: false
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Specify the Source and Build Directories
|
#### Specify the Source and Build Directories
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure Project
|
- name: Configure and Build Project
|
||||||
uses: threeal/cmake-action@v1.3.0
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
source-dir: submodules
|
source-dir: submodules
|
||||||
build-dir: submodules/out
|
build-dir: submodules/out
|
||||||
@ -86,8 +83,8 @@ jobs:
|
|||||||
- name: Setup Ninja
|
- name: Setup Ninja
|
||||||
uses: seanmiddleditch/gha-setup-ninja@v4
|
uses: seanmiddleditch/gha-setup-ninja@v4
|
||||||
|
|
||||||
- name: Configure Project
|
- name: Configure and Build Project
|
||||||
uses: threeal/cmake-action@v1.3.0
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
generator: Ninja
|
generator: Ninja
|
||||||
c-compiler: clang
|
c-compiler: clang
|
||||||
|
@ -25,7 +25,7 @@ inputs:
|
|||||||
description: Additional arguments to pass during the CMake configuration
|
description: Additional arguments to pass during the CMake configuration
|
||||||
run-build:
|
run-build:
|
||||||
description: If enabled, it builds the project using CMake (true/false)
|
description: If enabled, it builds the project using CMake (true/false)
|
||||||
default: false
|
default: true
|
||||||
build-args:
|
build-args:
|
||||||
description: Additional arguments to pass during the CMake build
|
description: Additional arguments to pass during the CMake build
|
||||||
outputs:
|
outputs:
|
||||||
|
Loading…
Reference in New Issue
Block a user