name: Meson

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "Ubuntu",
            os: ubuntu-latest,
            tests: "true",
            gtk_tsm: "true"
          }
        - {
            name: "macOS",
            os: macos-latest,
            tests: "true",
            gtk_tsm: "false"
          }

    steps:
    - uses: actions/checkout@v3
    - name: Print env
      run: |
        echo github.event.action: ${{ github.event.action }}
        echo github.event_name: ${{ github.event_name }}

    - name: Install dependencies on Ubuntu
      if: startsWith(matrix.config.name, 'Ubuntu')
      run: sudo apt-get update && sudo apt-get install -y meson check valgrind libgtk-3-dev libpango1.0-dev pkg-config

    - name: Install dependencies on macOS
      if: startsWith(matrix.config.name, 'macOS')
      run: brew install check meson ninja

    - name: Configure Meson
      run: meson setup -Dtests=${{matrix.config.tests}} -Dgtktsm=${{matrix.config.gtk_tsm}} -Dextra_debug=true build

    - name: Build
      working-directory: ./build
      run: meson compile

    - name: Test
      working-directory: ./build
      run: meson test

