name: tests

on: [push]

jobs:
    test:
        runs-on: ubuntu-latest
        strategy:
            max-parallel: 4
            matrix:
                python-version: [3.6, 3.7]
        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
              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 }}