# taken from https://github.com/onqtam/doctest/blob/master/.github/workflows/main.yml

name: C/C++ CI
on: push

jobs:
  build:
    strategy:
      matrix:
        include: [
          { system: MacOS,          runner: macos-latest },
          { system: Ubuntu-20,      runner: ubuntu-20.04 },
          { system: Ubuntu-latest,  runner: ubuntu-latest },
        ]
    name: ${{ matrix.system }} Build
    runs-on: ${{ matrix.runner }}
    steps:
    - uses: actions/checkout@v3
    - name: cmake
      run: cmake ..
      working-directory: build
    - name: build
      run: make
      working-directory: build

  test:
    strategy:
      matrix:
        include: [
          { system: MacOS,          runner: macos-latest },
          { system: Ubuntu-latest,  runner: ubuntu-latest },
        ]
    name: ${{ matrix.system }} Test
    runs-on: ${{ matrix.runner }}
    steps:
    - uses: actions/checkout@v3
    - name: cmake
      run: cmake -DOJPH_BUILD_TESTS=yes ..
      working-directory: build
    - name: build
      run: make
      working-directory: build
    - name: test
      run: ctest --output-on-failure
      working-directory: build
      
  test_windows:
    strategy:
      matrix:
        include: [
          { system: Windows,  runner: windows-latest },
        ]
    name: ${{ matrix.system }} Test
    runs-on: ${{ matrix.runner }}
    steps:
    - uses: actions/checkout@v3
    - name: cmake
      run: cmake -G "Visual Studio 17 2022" -A x64 -DOJPH_ENABLE_TIFF_SUPPORT=off -DOJPH_BUILD_TESTS=yes ..
      working-directory: build
    - name: build
      run: cmake --build . --config Release
      working-directory: build
    - name: test
      run: ctest --output-on-failure -C Release
      working-directory: build

#jobs:
#  ci:
#    name: ${{ matrix.name }}
#    runs-on: ${{ matrix.os }}
#
#    strategy:
#      fail-fast: false
#      matrix:
#        # Github Actions requires a single row to be added to the build matrix.
#        # See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
#        name: [
#          ubuntu-18.04-gcc-4.8,
#          ubuntu-18.04-gcc-4.9,
#          ubuntu-18.04-gcc-5,
#          ubuntu-18.04-gcc-6,
#          ubuntu-18.04-gcc-7,
#          ubuntu-18.04-gcc-8,
#          ubuntu-18.04-gcc-9,
#          ubuntu-18.04-clang-3.5,
#          ubuntu-18.04-clang-3.6,
#          ubuntu-18.04-clang-3.7,
#          ubuntu-18.04-clang-3.8,
#          ubuntu-18.04-clang-3.9,
#          ubuntu-18.04-clang-4.0,
#          ubuntu-18.04-clang-5.0,
#          ubuntu-18.04-clang-6.0,
#          ubuntu-18.04-clang-7,
#          ubuntu-18.04-clang-8,
#          ubuntu-18.04-clang-9,
#          macOS-10.14-xcode-9.4.1,
#          macOS-10.14-xcode-10.0,
#          macOS-10.14-xcode-10.1,
#          macOS-10.14-xcode-10.2,
#          macOS-10.14-xcode-10.2.1,
#          macOS-10.14-xcode-10.3,
#          macOS-10.14-gcc-7,
#          macOS-10.14-gcc-8,
#          macOS-10.14-gcc-9,
#        ]
#
#        include:
#          - name: ubuntu-18.04-gcc-4.8
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "4.8"
#
#          - name: ubuntu-18.04-gcc-4.9
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "4.9"
#
#          - name: ubuntu-18.04-gcc-5
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "5"
#
#          - name: ubuntu-18.04-gcc-6
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "6"
#
#          - name: ubuntu-18.04-gcc-7
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "7"
#
#          - name: ubuntu-18.04-gcc-8
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "8"
#
#          - name: ubuntu-18.04-gcc-9
#            os: ubuntu-18.04
#            compiler: gcc
#            version: "9"
#
#          - name: ubuntu-18.04-clang-3.5
#            os: ubuntu-18.04
#            compiler: clang
#            version: "3.5"
#
#          - name: ubuntu-18.04-clang-3.6
#            os: ubuntu-18.04
#            compiler: clang
#            version: "3.6"
#
#          - name: ubuntu-18.04-clang-3.7
#            os: ubuntu-18.04
#            compiler: clang
#            version: "3.7"
#
#          - name: ubuntu-18.04-clang-3.8
#            os: ubuntu-18.04
#            compiler: clang
#            version: "3.8"
#
#          - name: ubuntu-18.04-clang-3.9
#            os: ubuntu-18.04
#            compiler: clang
#            version: "3.9"
#
#          - name: ubuntu-18.04-clang-4.0
#            os: ubuntu-18.04
#            compiler: clang
#            version: "4.0"
#
#          - name: ubuntu-18.04-clang-5.0
#            os: ubuntu-18.04
#            compiler: clang
#            version: "5.0"
#
#          - name: ubuntu-18.04-clang-6.0
#            os: ubuntu-18.04
#            compiler: clang
#            version: "6.0"
#
#          - name: ubuntu-18.04-clang-7
#            os: ubuntu-18.04
#            compiler: clang
#            version: "7"
#
#          - name: ubuntu-18.04-clang-8
#            os: ubuntu-18.04
#            compiler: clang
#            version: "8"
#
#          - name: ubuntu-18.04-clang-9
#            os: ubuntu-18.04
#            compiler: clang
#            version: "9"
#
#          - name: macOS-10.14-xcode-9.4.1
#            os: macOS-10.14
#            compiler: xcode
#            version: "9.4.1"
#
#          - name: macOS-10.14-xcode-10.0
#            os: macOS-10.14
#            compiler: xcode
#            version: "10"
#
#          - name: macOS-10.14-xcode-10.1
#            os: macOS-10.14
#            compiler: xcode
#            version: "10.1"
#
#          - name: macOS-10.14-Xcode-10.2
#            os: macOS-10.14
#            compiler: xcode
#            version: "10.2"
#
#          - name: macOS-10.14-xcode-10.2.1
#            os: macOS-10.14
#            compiler: xcode
#            version: "10.2.1"
#
#          - name: macOS-10.14-xcode-10.3
#            os: macOS-10.14
#            compiler: xcode
#            version: "10.3"
#
#          - name: macOS-10.14-gcc-7
#            os: macOS-10.14
#            compiler: gcc
#            version: "7"
#
#          - name: macOS-10.14-gcc-8
#            os: macOS-10.14
#            compiler: gcc
#            version: "8"
#
#          - name: macOS-10.14-gcc-9
#            os: macOS-10.14
#            compiler: gcc
#            version: "9"
#
#    steps:
#    - uses: actions/checkout@v2
#    - name: cmake
#      run: cmake ..
#      working-directory: build
#    - name: build
#      run: make
#      working-directory: build



#  build1:
#    name: main build for Unix-like
#    runs-on: ${{ matrix.os }}
#    strategy:
#      matrix:
#        os: [macos-10.14, macos-latest, ubuntu-16.04, ubuntu-latest]
#        node: [8]
#    steps:
#    - uses: actions/checkout@v2
#    - name: cmake
#      run: cmake ..
#      working-directory: build
#    - name: build
#      run: make
#      working-directory: build
#
#  build2:
#    name: main build for Windows
#    runs-on: ${{ matrix.os }}
#    strategy:
#      matrix:
#        os: [windows-latest]
#        node: [8]
#    steps:
#    - uses: actions/checkout@v2
#    - name: install visual studio
#      run: python install.py --clang-completer --ts-completer --msvc=14
#    - name: cmake
#      run: cmake -G "Visual Studio 14 2015 Win64" ..
#      working-directory: build
#    - name: build
#      run: cmake --build .
#      working-directory: build
#
#  build3:
#    name: main build for Windows
#    runs-on: ${{ matrix.os }}
#    strategy:
#      matrix:
#        os: [windows-latest]
#        node: [8]
#    steps:
#    - uses: actions/checkout@v2
#    - name: install visual studio
#      run: python install.py --clang-completer --ts-completer --msvc=14
#    - name: cmake
#      run: cmake -G "Visual Studio 15 2017 Win64" ..
#      working-directory: build
#    - name: build
#      run: cmake --build .
#      working-directory: build
