name: CI

# see https://github.community/t5/GitHub-Actions/How-to-trigger-an-action-on-push-or-pull-request-but-not-both/m-p/35805
on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master
  schedule:
    # Run workflow every morning (* needs quotes).
    - cron: '0 4 * * *'


jobs:
  run-tests:

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

    strategy:
      matrix:
        os: [ubuntu-22.04, ubuntu-24.04]

    steps:
    - uses: actions/checkout@v4

    - name: Show environment
      run: |
        python --version
        python3 --version
        python3 -c "import multiprocessing as m; print('CPUs:', m.cpu_count())"

    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get -y install -qq gettext gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-gtk-3.0 gir1.2-gtksource-4 gir1.2-pango-1.0 gir1.2-webkit2-4.1 python3 python3-enchant python3-gi python3-setuptools python3-yaml tox

    - name: Check style
      if: matrix.os == 'ubuntu-24.04'
      run: |
        tox -v -e style

    - name: Run tests
      if: matrix.os == 'ubuntu-24.04'
      run: |
        python3 -c "import gi"
        tox -v -e py
        python3 -m venv --system-site-packages .venv
        ./.venv/bin/pip install .
