name: CI
on:
  push:
  pull_request:
  schedule:
    - cron:  '0 3 * * *'
jobs:
  #clang-format:
  #  runs-on: ubuntu-latest
  #  steps:
  #  - uses: actions/checkout@v2
  #  - uses: DoozyX/clang-format-lint-action@v0.12
  #    with:
  #      exclude: './thirdparty'
  #      clangFormatVersion: 12
        
  build-ubuntu:
    runs-on: ubuntu-latest
    env:
      dashboard_model: Experimental
      build_type: ${{ matrix.build_type }}
      NUMBER_OF_PROCESSORS: 2
      CXX: ${{ matrix.cxx }}
    strategy:
      fail-fast: false
      matrix:
        build_type: [Debug, Release]
        cxx: [g++-9, g++-10, g++-11, clang++-10, clang++-11, clang++-12, icpc]
        include:
          - cxx: g++-11
            INSTALL_EXTRA: g++-11
          - cxx: clang++-11
            INSTALL_EXTRA: clang-11
          - cxx: clang++-12
            INSTALL_EXTRA: clang-12
          - cxx: icpc
            INSTALL_ONEAPI: true
        exclude:
          # icpc in debug mode runs out of memory in CI
          - cxx: icpc
            build_type: Debug
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: install OneAPI
        if: ${{ matrix.INSTALL_ONEAPI }}
        run: |
          wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
          sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
          sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
          sudo apt update
          sudo apt install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
      - name: install extras
        if: ${{ matrix.INSTALL_EXTRA }}
        run: |
          sudo apt update
          sudo apt install ${{ matrix.INSTALL_EXTRA }}
      - name: ctest
        run: |
          if [ ${{ matrix.INSTALL_ONEAPI }} ]
          then
            source /opt/intel/oneapi/setvars.sh
            export LC_ALL=en_US.utf8
          fi
          $CXX --version
          ctest -VV -S test.cmake

  build-windows:
    runs-on: ${{ matrix.os }}
    env:
      build_type: ${{ matrix.build_type }}
    strategy:
      fail-fast: false
      matrix:
        build_type: [Debug, Release]
        os: [windows-2019]
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true
    - uses: egor-tensin/vs-shell@v2
    - name: ctest
      run: |
        ctest -VV -S test.cmake
