mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-08 18:21:20 +00:00
chore: merge pull request #58 from threeal/add-shell-inputs
Add `shell` Action Input
This commit is contained in:
commit
7ef2eb8da6
13
.github/workflows/test.yml
vendored
13
.github/workflows/test.yml
vendored
@ -132,3 +132,16 @@ jobs:
|
|||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
run-test: true
|
run-test: true
|
||||||
test-args: -R test
|
test-args: -R test
|
||||||
|
|
||||||
|
specified-shell:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout the repository
|
||||||
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
|
- name: Use the action with specified shell
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
shell: bash
|
||||||
|
source-dir: test
|
||||||
|
run-build: true
|
||||||
|
@ -22,6 +22,7 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
|
|||||||
|
|
||||||
| Name | Value Type | Description |
|
| Name | Value Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| `shell` | String | The shell to be used to run the commands. It defaults to `pwsh` on Windows and `bash` on Linux and macOS. Refer to [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell) for more information on available shell options. |
|
||||||
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
|
| `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. |
|
| `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. It appends the CMake configuration arguments with `-G [val]`. |
|
| `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |
|
||||||
|
16
action.yml
16
action.yml
@ -5,6 +5,9 @@ branding:
|
|||||||
color: gray-dark
|
color: gray-dark
|
||||||
icon: terminal
|
icon: terminal
|
||||||
inputs:
|
inputs:
|
||||||
|
shell:
|
||||||
|
description: The shell to be used to run the commands
|
||||||
|
required: false
|
||||||
source-dir:
|
source-dir:
|
||||||
description: The source directory of the CMake project
|
description: The source directory of the CMake project
|
||||||
required: false
|
required: false
|
||||||
@ -57,6 +60,13 @@ runs:
|
|||||||
id: process-inputs
|
id: process-inputs
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
if [ -n '${{ inputs.shell }}' ]; then
|
||||||
|
SHELL='${{ inputs.shell }}'
|
||||||
|
else
|
||||||
|
SHELL='${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}'
|
||||||
|
fi
|
||||||
|
echo "shell=$SHELL" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
SOURCE_DIR="."
|
SOURCE_DIR="."
|
||||||
if [ -n '${{ inputs.source-dir }}' ]; then
|
if [ -n '${{ inputs.source-dir }}' ]; then
|
||||||
SOURCE_DIR="${{ inputs.source-dir }}"
|
SOURCE_DIR="${{ inputs.source-dir }}"
|
||||||
@ -121,15 +131,15 @@ runs:
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
- name: Configure the CMake project
|
- name: Configure the CMake project
|
||||||
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
shell: ${{ steps.process-inputs.outputs.shell }}
|
||||||
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: ${{ steps.process-inputs.outputs.shell }}
|
||||||
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: ${{ steps.process-inputs.outputs.shell }}
|
||||||
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