name: Test

on: [push, pull_request]

permissions:
  contents: read

jobs:

  test-posix:
    name: Build and test on POSIX systems
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]
    steps:
      - name: Checkout the repository
        uses: actions/checkout@master
      - name: Compile the project
        run: make clean && make
      - name: Test the project
        run: make test

  test-windows:
    name: Build and test on Windows
    runs-on: windows-latest
    steps:
      - name: Checkout the repository
        uses: actions/checkout@master
      - name: Setup MSVC
        uses: ilammy/msvc-dev-cmd@v1
      - name: Build the project
        shell: cmd
        run: build_win
      - name: Test the project
        shell: cmd
        run: build_win test

  test-mingw:
    name: Build on Windows with Mingw (no test yet)
    runs-on: windows-latest
    defaults:
      run:
        shell: msys2 {0}
    steps:
      - name: Checkout the repository
        uses: actions/checkout@master
      - name: Setup Mingw
        uses: msys2/setup-msys2@v2
        with:
          msystem: UCRT64
          update: true
          install: >-
            base-devel
            git
            gcc
      - name: Build the project
        shell: cmd
        run: make -j CC=gcc