---
name: Build test
'on':
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build-make:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
          os: [ "alpine", "archlinux", "fedora", "ubuntu" ]

    container:
      image: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Dependencies
        run: |
          ./scripts/install-deps.sh

      - name: Build
        run: |
          make

      - name: Run check
        run: |
          make check

  build-meson:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
          os: [ "alpine", "archlinux", "fedora", "ubuntu" ]

    container:
      image: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Dependencies
        run: |
          ./scripts/install-deps.sh

      - name: Setup
        run: meson setup build

      - name: Build
        run: meson compile -C build

      - name: Run check
        run: if ! meson test -C build; then cat build/meson-logs/testlog.txt; false; fi