name: Ubuntu

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  ci_test_gcc_release:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: [g++-7, g++-9, g++-11]
    steps:
      - uses: actions/checkout@v2
      - name: Install compiler
        run: |
          echo "deb http://dk.archive.ubuntu.com/ubuntu/ focal main universe" | sudo tee -a /etc/apt/sources.list
          sudo apt-get update
          sudo apt-get install -y ${{ matrix.compiler }}
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Release
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure

  ci_test_gcc_debug:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: [g++-8, g++-10, g++-12]
    steps:
      - uses: actions/checkout@v2
      - name: Install compiler
        run: |
          echo "deb http://dk.archive.ubuntu.com/ubuntu/ focal main universe" | sudo tee -a /etc/apt/sources.list
          sudo apt-get update
          sudo apt-get install -y ${{ matrix.compiler }}
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Debug
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure

  ci_test_clang_release:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ["15", "17"]
    steps:
      - uses: actions/checkout@v2
      - name: Install compiler
        run: |
          wget https://apt.llvm.org/llvm.sh
          chmod +x llvm.sh
          sudo ./llvm.sh ${{ matrix.compiler }}
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=clang++-${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Release
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure

  ci_test_clang_debug:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ["16"]
    steps:
      - uses: actions/checkout@v2
      - name: Install compiler
        run: |
          wget https://apt.llvm.org/llvm.sh
          chmod +x llvm.sh
          sudo ./llvm.sh ${{ matrix.compiler }}
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=clang++-${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Debug
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure

  ci_test_standards:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        standard: [11, 14, 17, 20]
        compiler: [g++-11]
    steps:
      - uses: actions/checkout@v2
      - name: Install compiler
        run: |
          sudo apt-get update
          sudo apt-get install -y ${{ matrix.compiler }}
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DCMAKE_BUILD_TYPE=Debug
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure

  ci_nonstandard_features:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: cmake
        run: cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DAMC_PEDANTIC=ON -DCMAKE_BUILD_TYPE=Debug
      - name: build
        run: cmake --build build --parallel 2
      - name: test
        run: cd build && ctest -j 2 --output-on-failure
