name: Linux

on:
  push:
    paths-ignore:
      - 'README.md'
      - 'doc/**'
  pull_request:
    paths-ignore:
      - 'README.md'
      - 'doc/**'

jobs:
  linux:
    strategy:
      fail-fast: false
      matrix:
        compiler:
          - g++-9
          - g++-10
          #- g++-11
          - clang++-10
          - clang++-11
          - clang++-12
        build_type: [Debug, Release]

    runs-on: ubuntu-latest

    env:
      CXX: ${{ matrix.compiler }}

    steps:
    - uses: actions/checkout@v2

    - run: cmake -E make_directory build

    - working-directory: build/
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

    - working-directory: build/
      run: cmake --build .

    - working-directory: build/
      run: ctest --output-on-failure

  linux-old:
    strategy:
      fail-fast: false
      matrix:
        compiler:
          - g++-7
          - g++-8
          - clang++-6.0
          - clang++-7
          - clang++-8
          - clang++-9
        build_type: [Debug, Release]

    runs-on: ubuntu-latest

    env:
      CXX: ${{ matrix.compiler }}

    steps:
    - uses: actions/checkout@v2

    - run: sudo apt-get update -yq

    - run: sudo apt-get install -yq ${{ matrix.compiler }}

    - run: cmake -E make_directory build

    - working-directory: build/
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

    - working-directory: build/
      run: cmake --build .

    - working-directory: build/
      run: ctest --output-on-failure

  linux-gcc-extra:
    strategy:
      fail-fast: false
      matrix:
        flags: ["-fno-rtti"]
        build_type: [Debug, Release]

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - run: cmake -E make_directory build

    - working-directory: build/
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="${{ matrix.flags }}"

    - working-directory: build/
      run: cmake --build .

    - working-directory: build/
      run: ctest --output-on-failure

  linux-clang-extra:
    strategy:
      fail-fast: false
      matrix:
        flags: ["-fno-rtti", "-fms-extensions"]
        build_type: [Debug, Release]

    runs-on: ubuntu-latest

    env:
      CXX: clang++

    steps:
    - uses: actions/checkout@v2

    - run: cmake -E make_directory build

    - working-directory: build/
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="${{ matrix.flags }}"

    - working-directory: build/
      run: cmake --build .

    - working-directory: build/
      run: ctest --output-on-failure
