name: Python package

on:
  push:
  pull_request:
  schedule:
    - cron: '0 6 * * *'  # Daily 6AM UTC build

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: [3.7, 3.8, 3.9]
      fail-fast: false

    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        sudo apt install devscripts cython3 bzr python3-paste python3-aiohttp protobuf-compiler libapt-pkg-dev python3-gpg libgpg-error-dev libgpgme-dev python3-sphinx subunit
        python -m pip install --upgrade pip
        pip install -U pip setuptools setuptools-rust flake8 mypy debmutate pyyaml testtools Paste aiohttp mypy-protobuf git+https://salsa.debian.org/apt-team/python-apt cython fastbencode tqdm gpg sphinx_epytext python-subunit
        mkdir $HOME/.config/breezy/plugins -p
        bzr branch lp:brz-debian ~/.config/breezy/plugins/debian
        python setup.py develop
        make
    - name: Style checks
      run: |
        python -m flake8
    - name: Typing checks
      run: |
        python -m pip install mypy types-PyYAML types-protobuf
        python -m mypy janitor
    - name: Test suite run
      run: |
        make test-it-all
      env:
        PYTHONHASHSEED: random
    - name: Config compat test
      run: |
        git clone https://salsa.debian.org/jelmer/janitor.debian.net/ janitor.debian.net
        PYTHONPATH=. python3 -m janitor.config janitor.debian.net/k8s/janitor.conf
