name: cmake-linux-cpp

on: [push, pull_request]

jobs:
  release:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v4

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/build

      - name: Configure CMake
        working-directory: ${{runner.workspace}}/build
        run: cmake $GITHUB_WORKSPACE 

      - name: Build
        working-directory: ${{runner.workspace}}/build
        run: cmake --build . --parallel

      - name: Test
        working-directory: ${{runner.workspace}}/build
        run: ctest --parallel --timeout 300 --output-on-failure

  release_all_tests:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v4

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/build

      - name: Configure CMake All
        working-directory: ${{runner.workspace}}/build
        run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DALL_TESTS=ON

      - name: Build All
        working-directory: ${{runner.workspace}}/build
        run: cmake --build . --parallel 

      - name: Test All
        working-directory: ${{runner.workspace}}/build
        run: ctest --parallel --timeout 300 --output-on-failure 

  debug:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v4

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/build

      - name: Configure CMake
        working-directory: ${{runner.workspace}}/build
        run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug 

      - name: Build
        working-directory: ${{runner.workspace}}/build
        shell: bash
        run: cmake --build . --parallel

      - name: Test
        working-directory: ${{runner.workspace}}/build
        run: ctest --parallel --timeout 300 --output-on-failure 

  debug_all_tests:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v4

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/build

      - name: Configure CMake All
        working-directory: ${{runner.workspace}}/build
        run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DALL_TESTS=ON

      - name: Build All
        working-directory: ${{runner.workspace}}/build
        run: cmake --build . --parallel 

      - name: Test All
        working-directory: ${{runner.workspace}}/build
        run: ctest --parallel --timeout 300 --output-on-failure
