name: Ubuntu

on: [push, pull_request]

permissions:
  contents: read

jobs:
  github_20: 
    strategy:
      fail-fast: false
      matrix:
        compiler:
          - g++-12
        build_type: [Debug, Release]

    runs-on: ubuntu-latest

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

    steps:
    - uses: actions/checkout@v6
    - name: cmake
      run: cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DJSONCONS_BUILD_TESTS=On

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  #github_20_no_exceptions: 
  #  strategy:
  #    fail-fast: false
  #    matrix:
  #      compiler:
  #        - g++-12
  #      build_type: [Debug, Release]
  #
  #  runs-on: ubuntu-latest
  #
  #  env:
  #    CXX: ${{ matrix.compiler }}
  #
  #  steps:
  #  - uses: actions/checkout@v6
  #  - name: cmake
  #    run: cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DJSONCONS_BUILD_TESTS=On -DCMAKE_CXX_FLAGS="-fno-exceptions"
  #
  #  - working-directory: build/
  #    run: cmake --build . --config ubuntu-latest
  #
  #  - working-directory: build/
  #    run: ctest -C ubuntu-latest --output-on-failure

  gcc_build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: install_gcc
      run: |
           sudo apt update
           sudo apt install gcc-10 g++-10
      shell: bash
    - name: cmake
      run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
      env:
        CC:   gcc-10
        CXX:  g++-10

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  gcc_build12:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: install_gcc
      run: |
           sudo apt update
           sudo apt install gcc-11 g++-11
      shell: bash
    - name: cmake
      run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
      env:
        CC:   gcc-11
        CXX:  g++-11

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  gcc_build_no_deprecated:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: install_gcc
      run: |
           sudo apt update
           sudo apt install gcc-10 g++-10
      shell: bash
    - name: cmake
      run: cmake -S . -B build -DCXXFLAGS="-DJSONCONS_NO_DEPRECATED" -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
      env:
        CC:   gcc-10
        CXX:  g++-10

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  gcc_build11b:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: install_gcc
      run: |
           sudo apt update
           sudo apt install g++-11
      shell: bash
    - name: cmake
      run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DLLVM_CXX_STD=c++17 -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On
      env:
        CXX:  g++-11

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  #clang_13_build:
  #  runs-on: ubuntu-latest
  #
  #  steps:
  #  - uses: actions/checkout@v6
  #  - name: install_gcc
  #    run: |
  #         sudo apt update
  #         sudo apt install clang-13
  #    shell: bash
  #  - name: cmake
  #    run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On 
  #    env:
  #      CC:   clang-13
  #      CXX:  clang++-13
  #
  #  - working-directory: build/
  #    run: cmake --build . --config ubuntu-latest
  #
  #  - working-directory: build/
  #    run: ctest -C ubuntu-latest --output-on-failure

  clang_14_build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: install_gcc
      run: |
           sudo apt update
           sudo apt install clang-14
      shell: bash
    - name: cmake
      run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On 
      env:
        CC:   clang-14
        CXX:  clang++-14

    - working-directory: build/
      run: cmake --build . --config ubuntu-latest

    - working-directory: build/
      run: ctest -C ubuntu-latest --output-on-failure

  ci_test_compilers_gcc:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['8','9','10','11','12','latest']
    container: gcc:${{ matrix.compiler }}
    steps:
      - uses: actions/checkout@v6
      - name: Get latest CMake and ninja
        uses: lukka/get-cmake@latest
      - name: cmake
        run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On 
      - name: build
        working-directory: build/
        run: cmake --build . 
      - name: test
        working-directory: build/
        run: ctest --output-on-failure

  ci_test_compilers_gcc2:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['12','latest']
    container: gcc:${{ matrix.compiler }}
    steps:
      - uses: actions/checkout@v6
      - name: Get latest CMake and ninja
        uses: lukka/get-cmake@latest
      - name: cmake
        run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On 
      - name: build
        working-directory: build/
        run: cmake --build . 
      - name: test
        working-directory: build/
        run: ctest --output-on-failure

  ci_test_compilers_clang:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['11','12', '13', '14', '15-bullseye']
    container: silkeh/clang:${{ matrix.compiler }}
    steps:
      - name: Install unzip and git
        run: apt-get update ; apt-get install -y unzip git
      - uses: actions/checkout@v6
      - name: Get latest CMake and ninja
        uses: lukka/get-cmake@latest
      - name: cmake
        run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On 
      - name: build
        working-directory: build/
        run: cmake --build . 
      - name: test
        working-directory: build/
        run: ctest --output-on-failure

  ci_test_compilers_clang2:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['13', '15-bullseye']
    container: silkeh/clang:${{ matrix.compiler }}
    steps:
      - name: Install unzip and git
        run: apt-get update ; apt-get install -y unzip git
      - uses: actions/checkout@v6
      - name: Get latest CMake and ninja
        uses: lukka/get-cmake@latest
      - name: cmake
        run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On 
      - name: build
        working-directory: build/
        run: cmake --build . 
      - name: test
        working-directory: build/
        run: ctest --output-on-failure

