Use py3 coveralls to publish coverage on py2

Prior to this commit our GitHub workflow would set up one Python
version only for each build, which means that the commands to run
the tests and publish coverage (tox and coveralls) were run with
the same Python version as tox runs the tests in.

Given that the coveralls CLI tool dropped py2 a couple of releases
ago, this commit sets up an additional service py3 to run coveralls
(and tox) on when building for py2.

To prevent tox from using the wrong Python version to run the tests
on, this commit changes the toxenv value from the generic 'py'
(uses default python on path) to 'py27'.

For convenience and readability we use the environment variable
TOXENV instead of the tox -e option.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This commit is contained in:
Lukas Puehringer 2021-01-13 13:38:29 +01:00
parent 32452c4142
commit 8bb0187a69
2 changed files with 17 additions and 2 deletions

View file

@ -22,6 +22,13 @@ jobs:
os: ubuntu-latest
toxenv: lint
env:
# Set TOXENV env var to tell tox which testenv (see tox.ini) to use
# NOTE: The Python 2.7 runner has two Python versions on the path (see
# setup-python below), so we tell tox explicitly to use the 'py27'
# testenv. For all other runners the toxenv configured above suffices.
TOXENV: ${{ matrix.python-version == '2.7' && 'py27' || matrix.toxenv }}
runs-on: ${{ matrix.os }}
steps:
@ -33,6 +40,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Set up service Python 3.x (on 2.7 only)
uses: actions/setup-python@v2
if: ${{ matrix.python-version == 2.7 }}
with:
python-version: 3.x
- name: Find pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
@ -52,8 +65,9 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade tox coveralls
- name: Run tox
run: tox -e ${{ matrix.toxenv }}
- name: Run tox (${{ env.TOXENV }})
# See TOXENV environment variable for the testenv to be executed here
run: tox
- name: Publish on coveralls.io
# TODO: Maybe make 'lint' a separate job instead of case handling here

View file

@ -14,6 +14,7 @@ skipsdist = true
changedir = tests
commands =
python --version
coverage run aggregate_tests.py
coverage report -m --fail-under 97