cmake-action/.github/workflows/test.yaml
dependabot[bot] 4623ac26b9
chore: bump threeal/yarn-install-action from 1.0.0 to 2.0.0 (#211)
Bumps [threeal/yarn-install-action](https://github.com/threeal/yarn-install-action) from 1.0.0 to 2.0.0.
- [Release notes](https://github.com/threeal/yarn-install-action/releases)
- [Commits](https://github.com/threeal/yarn-install-action/compare/v1.0.0...v2.0.0)

---
updated-dependencies:
- dependency-name: threeal/yarn-install-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-02 20:30:46 +07:00

200 lines
5.4 KiB
YAML

name: Test
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
jobs:
check-package:
name: Check Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Setup Node.js
uses: actions/setup-node@v4.0.2
with:
node-version: latest
- name: Install Dependencies
uses: threeal/yarn-install-action@v2.0.0
- name: Check Format
run: |
corepack yarn format
git diff --exit-code HEAD
- name: Check Lint
run: corepack yarn lint
test-action:
name: Test Action
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
dist
test
sparse-checkout-cone-mode: false
- name: Move Project
run: mv test/* .
- name: Configure Project
id: cmake-action
uses: ./
- 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 ${{ 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:
name: Test Action With Specified Directories
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
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:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
dist
test
sparse-checkout-cone-mode: false
- name: Configure and Build Project
id: cmake-action
uses: ./
with:
source-dir: test
run-build: true
build-args: --target test_c --target test_cpp
- name: Test Project
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
test-action-with-run-test:
name: Test Action With Run Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
dist
test
sparse-checkout-cone-mode: false
- name: Configure, Build, and Test Project
uses: ./
with:
source-dir: test
run-test: true
test-args: -R hello_world
test-action-with-additional-args:
name: Test Action With Additional Arguments
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, msvc]
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
dist
test
sparse-checkout-cone-mode: false
- name: Configure, Build, and Test Project
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' || '' }}
test-action-with-custom-tools:
name: Test Action With Custom Tools
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
sparse-checkout: |
action.yaml
dist
test
sparse-checkout-cone-mode: false
- name: Configure, Build, and Test Project
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