name: build-test-linux-on-push

on: [push, pull_request]

jobs:
  python:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.8', '3.9', '3.10', '3.11']
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install flake8

      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

  build-cmake:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4

      - name: Build C/C++ with CMake
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
          sudo apt-get -qq update
          sudo apt-get -yqq build-dep mlt
          sudo apt-get -yqq install qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
          sudo apt-get -yqq install cmake ninja-build kwalify
          cmake -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=ON -D SWIG_PYTHON=ON -S . -B build -G Ninja
          cmake --build build
          sudo cmake --install build

      - name: Run tests
        env:
          DEBIAN_FRONTEND: noninteractive
          LD_LIBRARY_PATH: /usr/local/lib
        run: |
          sudo locale-gen de_DE.UTF-8
          cd build && ctest --output-on-failure
