name: Code quality

on:
  push:
  pull_request:
  schedule:
  # Run every Friday at 18:02 UTC
  # https://crontab.guru/#2_18_*_*_5
  - cron: 2 18 * * 5

jobs:
  linters:
    name: 🤖
    runs-on: ${{ matrix.os }}
    strategy:
      # max-parallel: 5
      matrix:
        os:
        - ubuntu-18.04
        - windows-latest
        - macos-latest
        env:
        - TOXENV: docs
        - TOXENV: lint
    steps:
    - uses: actions/checkout@master
    - name: Set up Python ${{ matrix.env.PYTHON_VERSION || 3.8 }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.env.PYTHON_VERSION || 3.8 }}
    - name: set PY
      run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)"
    - uses: actions/cache@v1
      with:
        path: ~/.cache/pre-commit
        key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
    - name: Pre-configure global Git settings
      run: |
        git config --global user.email "pypa-dev@googlegroups.com"
        git config --global user.name "pip"
    - name: Update setuptools and tox dependencies
      run: |
        python -m pip install --upgrade setuptools
        python -m pip install --upgrade tox tox-venv
        python -m pip freeze --all
    - name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}'
      run: >-
        python -m tox --notest --skip-missing-interpreters false
      env: ${{ matrix.env }}
    - name: Test with tox
      run: >-
        python -m tox
      env: ${{ matrix.env }}
