From 8bb0187a690d8ecb8d86ee57ea48c6472b72b2db Mon Sep 17 00:00:00 2001 From: Lukas Puehringer Date: Wed, 13 Jan 2021 13:38:29 +0100 Subject: [PATCH] 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 --- .github/workflows/ci.yml | 18 ++++++++++++++++-- tox.ini | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dcc911f..688f105b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/tox.ini b/tox.ini index a86fba4f..acf80441 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ skipsdist = true changedir = tests commands = + python --version coverage run aggregate_tests.py coverage report -m --fail-under 97