name: CI/CD

on:
  push:
    branches:
      - 'master*'
  pull_request:
  # Run daily at 0:01 UTC
  schedule:
  - cron:  '1 0 * * *'

jobs:
  linter:
    runs-on: ubuntu-latest
    name: pre-commit (linter)

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
    - uses: pre-commit/action@v2.0.0

  test:
    name: "🐍 ${{ matrix.python-version }} • ${{ matrix.runs-on }}"
    runs-on: ${{ matrix.runs-on }}
    strategy:
      matrix:
        runs-on: [ubuntu-latest, macOS-latest]
        python-version: [3.6, 3.7, 3.8]

    steps:
    - uses: actions/checkout@master

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

    - name: Install core fonts
      if: runner.os == 'Linux'
      run: |
        echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
        sudo apt-get install ttf-mscorefonts-installer

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip setuptools wheel pytest-github-actions-annotate-failures
        python -m pip install -q --no-cache-dir -e .[all]
        python -m pip list

    - name: Test with pytest
      run: |
        python -m pytest -r sx --mpl
