mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-21 19:11:21 +00:00
* ci: remove `specified-shell` job in the Test workflow * feat: remove `shell` action input
165 lines
4.7 KiB
YAML
165 lines
4.7 KiB
YAML
name: test
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches: [latest, main]
|
|
jobs:
|
|
test-package:
|
|
name: Test Package
|
|
runs-on: ${{ matrix.os }}-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [windows, ubuntu, macos]
|
|
env:
|
|
NODE_OPTIONS: --experimental-vm-modules
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4.1.1
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4.0.0
|
|
with:
|
|
node-version: latest
|
|
|
|
- name: Cache deps
|
|
uses: actions/cache@v3.3.2
|
|
with:
|
|
path: .yarn
|
|
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
|
|
|
|
- name: Install deps
|
|
run: corepack enable && yarn install
|
|
|
|
- name: Test lib
|
|
run: yarn test
|
|
|
|
default-usage:
|
|
runs-on: ${{ matrix.os }}-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [windows, ubuntu, macos]
|
|
steps:
|
|
- name: Checkout the repository
|
|
uses: actions/checkout@v4.1.1
|
|
|
|
- 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@v4.1.1
|
|
|
|
- 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@v4.1.1
|
|
|
|
- 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@v4.1.1
|
|
|
|
- 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@v4.1.1
|
|
|
|
- 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@v4.1.1
|
|
|
|
- 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
|