Skip to content

Commit

Permalink
Made coverage reporting fit for GitHub Actions
Browse files Browse the repository at this point in the history
Details:

* Increased minimum version of 'coverage' to 5.0 in order to be able
  to specify 'relative_files=True" in the 'coveragerc' config file,
  which causes the file paths in the .coverage data file to be relative.
  This was originally needed to use a github app for reporting to
  coveralls (which is no longer used), but it seems like a good idea
  in general.

* Because coverage 5.0 does not support Python 3.4, disabled generating
  and reporting coverage data in the makefile, test.yml workflow file,
  and when installing dependent packages in the requirements and constraint
  files.

* Migrated from 'python-coveralls' to 'coveralls' because the former
  does not support GitHub Actions in parallel mode (it picks the run
  ID that is used by coveralls.io to combine the reports automatically
  from Travis and does neither allow specifying it from the outside,
  nor does it support other CI systems than Travis). Also,
  python-coveralls does not seem to be maintained anymore and its last
  officially supported Python version is 3.6.

* Since 'coveralls' 2.x only supports Python 3.5 and upwards, and
  'coveralls' 1.x is incompatible with the run ID, a fork of
  'coveralls' 2.x with Python 2.7 backport support is used on
  Python 2.7.

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
  • Loading branch information
andy-maier committed Nov 16, 2020
1 parent 32df150 commit 5c559bf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# TODO: Once statement coverage gets better, enable branch coverage.
branch = False

# If True, stores relative file paths in data file (needed for Github Actions).
# Using this parameter requires coverage>=5.0
relative_files = True

# The following files are omitted in the coverage.
# omit =

Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: "${{ matrix.os }},${{ matrix.python-version }},${{ matrix.package_level }}"
run: |
if ! [[ ${{ matrix.python-version }} =~ (2.7|3.4) ]]; then coveralls; fi
if ! [[ ${{ matrix.python-version }} =~ (3.4) ]]; then coveralls; fi
- name: Run installtest
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
Expand All @@ -134,23 +134,14 @@ jobs:
run: |
make testdict
finish:
test_finish:
needs: test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Development setup
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
- name: Install coveralls
run: |
make develop
echo "Installed Python packages:"
pip list
pip3 install --upgrade coveralls
- name: Send coverage finish to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ else
pytest_warning_opts := -W default -W ignore::PendingDeprecationWarning
endif

ifeq ($(python_mn_version),py34)
pytest_cov_opts :=
else
pytest_cov_opts := --cov $(package_name) $(coverage_report) --cov-config .coveragerc
endif

# Files to be put into distribution archive.
# This is also used for 'include' statements in MANIFEST.in.
# Wildcards can be used directly (i.e. without wildcard function).
Expand Down Expand Up @@ -568,7 +574,7 @@ endif
.PHONY: test
test: $(test_deps)
@echo "Makefile: Running unit tests"
py.test --color=yes --cov $(package_name) $(coverage_report) --cov-config .coveragerc $(pytest_warning_opts) $(pytest_opts) $(test_dir)/unittest -s
py.test --color=yes $(pytest_cov_opts) $(pytest_warning_opts) $(pytest_opts) $(test_dir)/unittest -s
@echo "Makefile: Done running unit tests"

.PHONY: testdict
Expand Down
10 changes: 6 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# Direct dependencies:

# Coverage reporting (no imports, invoked via coveralls script):
# We exclude Python 3.4 from coverage testing and reporting.
# coverage 5.0 has removed support for py34
coverage>=4.5.2,<5.0
# python-coveralls 2.9.2 no longer has requirement coverage==4.0.3.
python-coveralls>=2.9.2
pytest-cov>=2.7.0
coverage>=5.0; python_version == '2.7' or python_version >= '3.5'
pytest-cov>=2.7.0; python_version == '2.7' or python_version >= '3.5'
# coveralls 2.0 has removed support for Python 2.7 and 3.4
git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7'
coveralls>=2.1.2; python_version >= '3.5'

# Safety CI by pyup.io
# safety 1.9.0 removed support for Python 2.7 and 3.4 (and now also enforces that)
Expand Down
8 changes: 5 additions & 3 deletions minimum-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ pathlib2==2.3.3; python_version < '3.4' and sys_platform != 'win32'
# Direct dependencies for development (must be consistent with dev-requirements.txt)

# Coverage reporting (no imports, invoked via coveralls script):
coverage==4.5.2
python-coveralls==2.9.2
pytest-cov==2.7.0
# We exclude Python 3.4 from coverage testing and reporting.
coverage==5.0; python_version == '2.7' or python_version >= '3.5'
pytest-cov==2.7.0; python_version == '2.7' or python_version >= '3.5'
git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7'
coveralls==2.1.2; python_version >= '3.5'

# Safety CI by pyup.io
safety==1.8.7; python_version <= '3.4'
Expand Down

0 comments on commit 5c559bf

Please sign in to comment.