cmake-action/.github/workflows/test.yaml
Alfi Maulana 6f06d655fe
ci: audit test action jobs in Test workflow (#275)
* ci: checkout action to `cmake-action` directory

* ci: simplify steps in `test-action-with-specified-dirs` job

* ci: test action without build by modifying project instead

* ci: modify `test-action-with-custom-tools` job to `test-action-with-custom-generator

* ci: remove `test-action-with-additional-args` job
2024-03-25 15:10:28 +08:00

161 lines
3.6 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.2
- name: Setup Node.js
uses: actions/setup-node@v4.0.2
with:
node-version: latest
- name: Setup Yarn
uses: threeal/setup-yarn-action@v2.0.0
with:
version: stable
- name: Check Format
run: |
yarn format
git diff --exit-code HEAD
- name: Check Lint
run: yarn lint
test-package:
name: Test Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup Node.js
uses: actions/setup-node@v4.0.2
with:
node-version: latest
- name: Setup Yarn
uses: threeal/setup-yarn-action@v2.0.0
with:
version: stable
- name: Test Package
run: yarn test
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.2
with:
path: cmake-action
sparse-checkout: |
action.yml
dist
test
sparse-checkout-cone-mode: false
- name: Move Project
run: mv cmake-action/test/* .
- name: Configure and Build Project
uses: ./cmake-action
- name: Test Project
uses: threeal/ctest-action@v1.0.0
with:
build-config: Debug
tests-regex: hello_world
test-action-with-specified-dirs:
name: Test Action With Specified Directories
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
with:
path: cmake-action
sparse-checkout: |
action.yml
dist
test
sparse-checkout-cone-mode: false
- name: Configure and Build Project
id: cmake-action
uses: ./cmake-action
with:
source-dir: cmake-action/test
build-dir: output
- name: Test Project
uses: threeal/ctest-action@v1.0.0
with:
test-dir: output
tests-regex: hello_world
test-action-without-run-build:
name: Test Action Without Run Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
with:
path: cmake-action
sparse-checkout: |
action.yml
dist
test
sparse-checkout-cone-mode: false
- name: Modify Project
run: echo 'invalid' >> cmake-action/test/hello_world.cpp
- name: Configure Project
id: cmake-action
uses: ./cmake-action
with:
source-dir: cmake-action/test
run-build: false
test-action-with-custom-generator:
name: Test Action With Custom Generator
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
with:
path: cmake-action
sparse-checkout: |
action.yml
dist
test
sparse-checkout-cone-mode: false
- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@v4
- name: Configure Project
id: cmake-action
uses: ./cmake-action
with:
source-dir: cmake-action/test
generator: Ninja
run-build: false
- name: Build Project
run: ninja -C ${{ steps.cmake-action.outputs.build-dir }}