name: Test

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install system dependencies
        run: |
          sudo apt-get update -q
          sudo apt-get install -y \
            libgtk-3-dev \
            libgstreamer1.0-dev \
            libgstreamer-plugins-base1.0-dev \
            libgstreamer-plugins-bad1.0-dev \
            gstreamer1.0-plugins-good \
            libpam0g-dev \
            ninja-build \
            meson \
            libglib2.0-dev \
            xvfb

      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable

      - name: Run Rust tests
        run: xvfb-run cargo test

      - name: Meson build
        run: |
          meson setup builddir
          meson compile -C builddir

      - name: Meson tests
        run: xvfb-run meson test -C builddir --verbose
