name: Linux / MacOS - c++

on:
  push:
    branches: [ master ]
  pull_request:

  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-20.04, macos-10.15]
        build_type: [Debug, Release]
        row_major: [ON, OFF]
        basic_logging: [ON, OFF]
        exclude:
          - os: macos-10.15
            row_major: ON
          - os: macos-10.15
            basic_logging: ON
          - build_type: Release
            row_major: ON
          - build_type: Release
            basic_logging: ON
          - build_type: Debug
            row_major: ON
            basic_logging: ON
      fail-fast: false
    env:
      BUILD_TYPE: ${{ matrix.build_type }}
      ROW_MAJOR_DEFAULT: ${{ matrix.row_major }}
      USE_BASIC_LOGGING: ${{ matrix.basic_logging }}


    steps:
      - uses: actions/checkout@v2

      - name: Format
        uses: DoozyX/clang-format-lint-action@v0.12
        with:
          source: '.'
          extensions: 'hpp,cpp'
          exclude: './sympy ./doxyrest_b'
          clangFormatVersion: 9
        if: matrix.os == 'ubuntu-20.04'

      - name: ccache
        uses: hendrikmuhs/ccache-action@v1

      - name: Install dependencies (Linux)
        run: ./scripts/install_linux_deps.sh
        if: matrix.os == 'ubuntu-20.04'

      - name: Install fmt dependency (Linux)
        run: ./scripts/install_linux_fmt_deps.sh
        if: matrix.os == 'ubuntu-20.04' && matrix.basic_logging == 'OFF'

      - name: Install dependencies (Mac OS)
        run: ./scripts/install_osx_deps.sh
        if: matrix.os == 'macos-10.15'

      - name: Run tests
        run: ./scripts/run_cpp_tests.sh
