name: "Verify build"

on:
  push:
  pull_request:
  schedule:
    - cron: '0 6 * * 1'

jobs:
  build:
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            cc: gcc
            cxx: g++

          - os: ubuntu-latest
            cc: clang
            cxx: clang++

          - os: macos-latest
            cc: clang
            cxx: clang++

          - os: windows-latest
            cc: gcc
            cxx: g++

    runs-on: ${{ matrix.os }}

    defaults:
      run:
        shell: bash

    steps:
      - name: Install dependencies
        if: ${{ runner.os == 'Linux' }}
        run: |
          sudo apt update
          sudo apt install -y libbz2-dev libcurl4-openssl-dev libfribidi-dev libgtk-3-dev libjpeg-dev libxml2-dev

      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          # We must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head.
          fetch-depth: 2

      # If this run was triggered by a pull request event, then checkout
      # the head of the pull request instead of the merge commit.
      - run: git checkout HEAD^2
        if: ${{ github.event_name == 'pull_request' }}
      
      - name: Build
        env:
          CC: ${{ matrix.cc }}
          CXX: ${{ matrix.cxx }}
        run: |
          make -j$(nproc)
