mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-20 10:41:21 +00:00
chore: merge pull request #53 from threeal/add-build-dir-output
Add `build-dir` Action Output
This commit is contained in:
commit
19d48ebea6
15
.github/workflows/test.yml
vendored
15
.github/workflows/test.yml
vendored
@ -19,12 +19,13 @@ jobs:
|
|||||||
run: mv test/* .
|
run: mv test/* .
|
||||||
|
|
||||||
- name: Use the action
|
- name: Use the action
|
||||||
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
- name: Try to test the project
|
- name: Try to test the project
|
||||||
id: failed-step
|
id: failed-step
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: ctest --test-dir build --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: Check on success
|
- name: Check on success
|
||||||
if: steps.failed-step.outcome == 'success'
|
if: steps.failed-step.outcome == 'success'
|
||||||
@ -32,8 +33,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and test the project
|
- name: Build and test the project
|
||||||
run: |
|
run: |
|
||||||
cmake --build build
|
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
|
||||||
ctest --test-dir build --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
|
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
|
||||||
|
|
||||||
specified-dir-usage:
|
specified-dir-usage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -42,6 +43,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3.5.3
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
- name: Use the action with specified directories
|
- name: Use the action with specified directories
|
||||||
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source-dir: test
|
source-dir: test
|
||||||
@ -53,8 +55,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and test the project
|
- name: Build and test the project
|
||||||
run: |
|
run: |
|
||||||
cmake --build output
|
cmake --build ${{ steps.cmake-action.outputs.build-dir }}
|
||||||
ctest --test-dir output --output-on-failure --no-tests=error -R hello_world
|
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
|
||||||
|
|
||||||
run-build-usage:
|
run-build-usage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -63,6 +65,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3.5.3
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
- name: Use the action with run build enabled
|
- name: Use the action with run build enabled
|
||||||
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source-dir: test
|
source-dir: test
|
||||||
@ -70,7 +73,7 @@ jobs:
|
|||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
|
|
||||||
- name: Test the project
|
- name: Test the project
|
||||||
run: ctest --test-dir test/build --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 test
|
||||||
|
|
||||||
run-test-usage:
|
run-test-usage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -40,6 +40,12 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
|
|||||||
|
|
||||||
> **Note**: All inputs are optional.
|
> **Note**: All inputs are optional.
|
||||||
|
|
||||||
|
### Outputs
|
||||||
|
|
||||||
|
| Name | Value Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `build-dir` | Path | The build directory of the CMake project. |
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
19
action.yml
19
action.yml
@ -46,11 +46,15 @@ inputs:
|
|||||||
test-args:
|
test-args:
|
||||||
description: Additional arguments to pass during the CTest run
|
description: Additional arguments to pass during the CTest run
|
||||||
required: false
|
required: false
|
||||||
|
outputs:
|
||||||
|
build-dir:
|
||||||
|
description: The build directory of the CMake project
|
||||||
|
value: ${{ steps.process-inputs.outputs.build-dir }}
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Process the inputs
|
- name: Process the inputs
|
||||||
id: process_inputs
|
id: process-inputs
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
SOURCE_DIR="."
|
SOURCE_DIR="."
|
||||||
@ -64,6 +68,7 @@ runs:
|
|||||||
elif [ -n "${{ inputs.source-dir }}" ]; then
|
elif [ -n "${{ inputs.source-dir }}" ]; then
|
||||||
BUILD_DIR="${{ inputs.source-dir }}/build"
|
BUILD_DIR="${{ inputs.source-dir }}/build"
|
||||||
fi
|
fi
|
||||||
|
echo "build-dir=$BUILD_DIR" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
ARGS="'$SOURCE_DIR' -B '$BUILD_DIR'"
|
ARGS="'$SOURCE_DIR' -B '$BUILD_DIR'"
|
||||||
if [ -n '${{ inputs.generator }}' ]; then
|
if [ -n '${{ inputs.generator }}' ]; then
|
||||||
@ -87,14 +92,14 @@ runs:
|
|||||||
if [ -n '${{ inputs.args }}' ]; then
|
if [ -n '${{ inputs.args }}' ]; then
|
||||||
ARGS="$ARGS ${{ inputs.args }}"
|
ARGS="$ARGS ${{ inputs.args }}"
|
||||||
fi
|
fi
|
||||||
echo "cmake_args=${ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
echo "cmake-args=${ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
if [ '${{ inputs.run-build }}' == 'true' ] || [ '${{ inputs.run-test }}' == 'true' ]; then
|
if [ '${{ inputs.run-build }}' == 'true' ] || [ '${{ inputs.run-test }}' == 'true' ]; then
|
||||||
BUILD_ARGS="--build '$BUILD_DIR'"
|
BUILD_ARGS="--build '$BUILD_DIR'"
|
||||||
if [ -n '${{ inputs.build-args }}' ]; then
|
if [ -n '${{ inputs.build-args }}' ]; then
|
||||||
BUILD_ARGS="$BUILD_ARGS ${{ inputs.build-args }}"
|
BUILD_ARGS="$BUILD_ARGS ${{ inputs.build-args }}"
|
||||||
fi
|
fi
|
||||||
echo "cmake_build_args=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
echo "cmake-build-args=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ '${{ inputs.run-test }}' == 'true' ]; then
|
if [ '${{ inputs.run-test }}' == 'true' ]; then
|
||||||
@ -102,7 +107,7 @@ runs:
|
|||||||
if [ -n '${{ inputs.test-args }}' ]; then
|
if [ -n '${{ inputs.test-args }}' ]; then
|
||||||
TEST_ARGS="$TEST_ARGS ${{ inputs.test-args }}"
|
TEST_ARGS="$TEST_ARGS ${{ inputs.test-args }}"
|
||||||
fi
|
fi
|
||||||
echo "cmake_test_args=${TEST_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
echo "cmake-test-args=${TEST_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Install Ninja
|
- name: Install Ninja
|
||||||
@ -117,14 +122,14 @@ runs:
|
|||||||
|
|
||||||
- name: Configure the CMake project
|
- name: Configure the CMake project
|
||||||
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
||||||
run: cmake ${{ steps.process_inputs.outputs.cmake_args }}
|
run: cmake ${{ steps.process-inputs.outputs.cmake-args }}
|
||||||
|
|
||||||
- name: Build targets
|
- name: Build targets
|
||||||
if: inputs.run-build != 'false' || inputs.run-test != 'false'
|
if: inputs.run-build != 'false' || inputs.run-test != 'false'
|
||||||
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
||||||
run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }}
|
run: cmake ${{ steps.process-inputs.outputs.cmake-build-args }}
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
if: inputs.run-test != 'false'
|
if: inputs.run-test != 'false'
|
||||||
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
||||||
run: ctest ${{ steps.process_inputs.outputs.cmake_test_args }}
|
run: ctest ${{ steps.process-inputs.outputs.cmake-test-args }}
|
||||||
|
Loading…
Reference in New Issue
Block a user