name: Run tests
on:
  push:
  pull_request:
  schedule:
    - cron: '3 20 * * SUN'
jobs:
  test-autoconf:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        cc: [gcc, clang]
        posix: ['', -D_POSIX_C_SOURCE=200112L]
    name: Autotools build on ${{matrix.os}} using ${{matrix.cc}} ${{matrix.posix}}
    runs-on: ${{ matrix.os }}
    env:
      CC: ${{ matrix.cc }}
      VERBOSE: 1
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
          persist-credentials: false
      - run: sudo apt install libipc-run3-perl
        if: ${{ matrix.os == 'ubuntu-latest' }}
      - run: brew install autoconf automake libtool
        if: ${{ matrix.os == 'macos-latest' }}
      - run: ./bootstrap
      - run: ./configure
        env:
          CFLAGS: -std=c99 -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-parameter ${{ matrix.posix }}
      - run: make
      - run: make check

  test-cmake:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    name: CMake build on ${{matrix.os}}
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
          persist-credentials: false
      - run: cmake -DBUILD_TESTING=ON .
      - run: cmake --build .
      - run: ctest -V . -C Debug
