cmake-action/.github/workflows/test.yml
2023-07-02 19:21:30 +07:00

135 lines
4.0 KiB
YAML

name: test
on:
workflow_dispatch:
pull_request:
push:
branches: [latest, main]
jobs:
default-usage:
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Move the test project to the working directory
run: mv test/* .
- name: Use the action
id: cmake-action
uses: ./
- name: Try to test the 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' || '' }}
- name: Check on success
if: steps.failed-step.outcome == 'success'
run: exit 1
- name: Build and test the 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' || '' }}
specified-dir-usage:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Use the action with specified directories
id: cmake-action
uses: ./
with:
source-dir: test
build-dir: output
- name: Check if the default build directory does not exist
shell: bash
run: test ! -e build && test ! -e test/build
- name: Build and test the 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
run-build-usage:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Use the action with run build enabled
id: cmake-action
uses: ./
with:
source-dir: test
run-build: true
build-args: --target test_c --target test_cpp
- name: Test the project
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
run-test-usage:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Use the action with run test enabled
uses: ./
with:
source-dir: test
run-test: true
test-args: -R hello_world
additional-flags-usage:
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, msvc]
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Use the action with additional compiler flags
uses: ./
with:
source-dir: test
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
options: CHECK_SURPASS_WARNING=ON
run-build: true
build-args: --target test_c --target test_cpp
run-test: true
test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }}
specified-generator-and-compiler-usage:
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout the repository
uses: actions/checkout@v3.5.3
- name: Use the action with specified generator and compilers
uses: ./
with:
source-dir: test
generator: Ninja
c-compiler: clang
cxx-compiler: clang++
options: CHECK_USING_CLANG=ON
run-build: true
build-args: --target test_c --target test_cpp
run-test: true
test-args: -R test