name: Test CMake build

on: [push, pull_request]

jobs:
  build:
    name:
      Cmake
    strategy:
      fail-fast: false
      matrix:
        cc:          [gcc, clang]
        cmake_flags: ["",
                      "-DBUILD_EXAMPLES=ON       -DBUILD_TESTS=ON",
                      "-DUSE_DTOA_LIBRARY=ON     -DBUILD_TESTS=ON",
                      "-DUSE_MEM_FILE=ON         -DBUILD_TESTS=ON",
                      "-DUSE_NO_MD5=ON           -DBUILD_TESTS=ON",
                      "-DUSE_OPENSSL_MD5=ON      -DBUILD_TESTS=ON",
                      "-DUSE_STANDARD_TMPFILE=ON -DBUILD_TESTS=ON",
                      "-DUSE_SYSTEM_MINIZIP=ON   -DBUILD_TESTS=ON",
                      "-DUSE_SYSTEM_MINIZIP=ON   -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON"]
    runs-on: ubuntu-latest
    env:
      CC: ${{ matrix.cc }}

    steps:
    - uses: actions/checkout@v2

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install pytest
        sudo apt update
        sudo apt-get -y install zlib1g-dev
        sudo apt-get -y install libminizip-dev
        sudo apt-get -y install libssl-dev

    - name: Configure CMake
      run: |
        mkdir build
        cd build
        cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release

    - name: Build
      run: |
        cd build
        cmake --build . --config Release --parallel

    - name: Test
      run: |
        cd build
        ctest -C Release -V
