name: tests

on: [push]

jobs:
    test:
        runs-on: ${{ matrix.os }}
        strategy:
            max-parallel: 4
            matrix:
                os: [ubuntu-latest, macos-latest, windows-latest]
                python-version: [3.8, 3.9]
        steps:
            - uses: actions/checkout@v1
            - shell: bash
              run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
              id: extract_branch
            - shell: bash
              run: echo "##[set-output name=py_version;]$(py_ver=${{ matrix.python-version }} && echo ${py_ver//./})"
              id: extract_py_version
            - name: Set up Python ${{ matrix.python-version }}
              uses: actions/setup-python@v1
              with:
                  python-version: ${{ matrix.python-version }}
            - name: Install dependencies
              run: |
                python -m pip install --upgrade pip
                pip install tox tox-gh-actions
            - name: Test
              run: tox
            - name: Upload coverage
              if: matrix.os == 'ubuntu-latest'
              uses: codecov/codecov-action@v1.0.3
              with:
                token: ${{secrets.CODECOV_TOKEN}}
                file: ./.coverage.xml
                flags: ${{ steps.extract_branch.outputs.branch }},py${{ steps.extract_py_version.outputs.py_version }}