name: cmake-windows-cpp

on: [push, pull_request]

jobs:
  release:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

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

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

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

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

  release_all_tests:
    runs-on: windows-2022

    steps:
      - uses: actions/checkout@v4

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

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

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

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

  debug:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

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

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

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

      - name: Test
        working-directory: ${{runner.workspace}}/build
        shell: bash
        run: ctest  --output-on-failure -C Debug 
  
  debug_all_tests:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

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

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

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

      - name: Test
        working-directory: ${{runner.workspace}}/build
        shell: bash
        run: ctest  --output-on-failure -C Debug
