Skip to content

Commit 8bb0187

Browse files
author
Lukas Puehringer
committed
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>
1 parent 32452c4 commit 8bb0187

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ jobs:
2222
os: ubuntu-latest
2323
toxenv: lint
2424

25+
env:
26+
# Set TOXENV env var to tell tox which testenv (see tox.ini) to use
27+
# NOTE: The Python 2.7 runner has two Python versions on the path (see
28+
# setup-python below), so we tell tox explicitly to use the 'py27'
29+
# testenv. For all other runners the toxenv configured above suffices.
30+
TOXENV: ${{ matrix.python-version == '2.7' && 'py27' || matrix.toxenv }}
31+
2532
runs-on: ${{ matrix.os }}
2633

2734
steps:
@@ -33,6 +40,12 @@ jobs:
3340
with:
3441
python-version: ${{ matrix.python-version }}
3542

43+
- name: Set up service Python 3.x (on 2.7 only)
44+
uses: actions/setup-python@v2
45+
if: ${{ matrix.python-version == 2.7 }}
46+
with:
47+
python-version: 3.x
48+
3649
- name: Find pip cache dir
3750
id: pip-cache
3851
run: echo "::set-output name=dir::$(pip cache dir)"
@@ -52,8 +65,9 @@ jobs:
5265
python -m pip install --upgrade pip
5366
pip install --upgrade tox coveralls
5467
55-
- name: Run tox
56-
run: tox -e ${{ matrix.toxenv }}
68+
- name: Run tox (${{ env.TOXENV }})
69+
# See TOXENV environment variable for the testenv to be executed here
70+
run: tox
5771

5872
- name: Publish on coveralls.io
5973
# TODO: Maybe make 'lint' a separate job instead of case handling here

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ skipsdist = true
1414
changedir = tests
1515

1616
commands =
17+
python --version
1718
coverage run aggregate_tests.py
1819
coverage report -m --fail-under 97
1920

0 commit comments

Comments
 (0)