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.0 with: node-version: 20 - name: Install Dependencies uses: threeal/yarn-install-action@v1.0.0 - name: Check Yarn Version run: | corepack yarn set version stable git diff --exit-code HEAD - name: Check Format run: | corepack yarn format git diff --exit-code HEAD - name: Check Lint run: corepack yarn lint test-package: name: Test Package runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4.1.1 - name: Setup Node.js uses: actions/setup-node@v4.0.0 with: node-version: 20 - name: Install Dependencies uses: threeal/yarn-install-action@v1.0.0 - name: Test Package run: corepack yarn test env: NODE_OPTIONS: --experimental-vm-modules 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