From a227bd30a1543de59cbdc970a9194a0cb805ac18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiziano=20M=C3=BCller?= Date: Mon, 9 Dec 2019 15:48:24 +0100 Subject: [PATCH 1/3] (re-)implement coverage reports via codecov.io fixes #3602 --- .github/workflows/ci.yml | 9 +++++++++ .github/workflows/tests.sh | 8 ++++++++ docs/requirements_for_rtd.txt | 1 + setup.json | 1 + 4 files changed, 19 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ffd8c5940..4b881a08e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,6 +138,15 @@ jobs: run: .github/workflows/tests.sh + - name: Upload coverage report + uses: codecov/codecov-action@v1.0.5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + name: aiida-unittests-${{ matrix.backend }} + flags: ${{ matrix.backend }} + file: ./coverage.xml + fail_ci_if_error: true + verdi: runs-on: ubuntu-latest diff --git a/.github/workflows/tests.sh b/.github/workflows/tests.sh index 3d639e8f88..ce4bf6a46b 100755 --- a/.github/workflows/tests.sh +++ b/.github/workflows/tests.sh @@ -10,6 +10,14 @@ verdi daemon start 4 verdi -p test_${AIIDA_TEST_BACKEND} run .ci/test_daemon.py verdi daemon stop +# Make sure +# - omissions are taken from the top-level .coveragerc +# - coverage is reported as XML and in terminal including +# the numbers/ranges of lines which are not covered, +# - coverage results of multiple tests are collected, +# - the base directory for files to consider is aiida/ +export PYTEST_ADDOPTS="--cov-config=.coveragerc --cov-report xml --cov-report term-missing --cov-append --cov=aiida" + AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest tests AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest .ci/pytest pytest --noconftest .ci/test_test_manager.py diff --git a/docs/requirements_for_rtd.txt b/docs/requirements_for_rtd.txt index 6ac780528c..733dcd1a00 100644 --- a/docs/requirements_for_rtd.txt +++ b/docs/requirements_for_rtd.txt @@ -31,6 +31,7 @@ pygments~=2.5 pymatgen>=2019.7.2 pymysql~=0.9.3 pyparsing~=2.4 +pytest-cov~=2.7 pytest-timeout~=1.3 pytest~=5.3 python-dateutil~=2.8 diff --git a/setup.json b/setup.json index 9b1eecbebb..e07f10610f 100644 --- a/setup.json +++ b/setup.json @@ -92,6 +92,7 @@ "pgtest~=1.3,>=1.3.1", "pytest~=5.3", "pytest-timeout~=1.3", + "pytest-cov~=2.7", "sqlalchemy-diff~=0.1.3" ], "dev_precommit": [ From 588211275d8a9284a47a439a426a00dd68a3e407 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Mon, 9 Dec 2019 18:18:06 +0100 Subject: [PATCH 2/3] Update README coverage badge Only upload coverage for Py3.5 --- .github/workflows/ci.yml | 5 +++-- .github/workflows/tests.sh | 2 +- README.md | 2 +- docs/requirements_for_rtd.txt | 1 + setup.json | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b881a08e8..82ab4a0fff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,13 +139,14 @@ jobs: .github/workflows/tests.sh - name: Upload coverage report + if: matrix.python-version == 3.5 uses: codecov/codecov-action@v1.0.5 with: token: ${{ secrets.CODECOV_TOKEN }} - name: aiida-unittests-${{ matrix.backend }} + name: aiida-pytests-py3.5-${{ matrix.backend }} flags: ${{ matrix.backend }} file: ./coverage.xml - fail_ci_if_error: true + fail_ci_if_error: false verdi: diff --git a/.github/workflows/tests.sh b/.github/workflows/tests.sh index ce4bf6a46b..74d3906b7f 100755 --- a/.github/workflows/tests.sh +++ b/.github/workflows/tests.sh @@ -16,7 +16,7 @@ verdi daemon stop # the numbers/ranges of lines which are not covered, # - coverage results of multiple tests are collected, # - the base directory for files to consider is aiida/ -export PYTEST_ADDOPTS="--cov-config=.coveragerc --cov-report xml --cov-report term-missing --cov-append --cov=aiida" +export PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov-config=.coveragerc --cov-report xml --cov-report term-missing --cov-append --cov=aiida" AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest tests AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest .ci/pytest diff --git a/README.md b/README.md index 41aa785a5c..a3d1cf98ad 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ AiiDA (www.aiida.net) is a workflow manager for computational science with a str |-----|----------------------------------------------------------------------------| |Latest release| [![PyPI version](https://badge.fury.io/py/aiida-core.svg)](https://badge.fury.io/py/aiida-core) [![conda-forge](https://img.shields.io/conda/vn/conda-forge/aiida-core.svg?style=flat)](https://anaconda.org/conda-forge/aiida-core) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/aiida-core.svg)](https://pypi.python.org/pypi/aiida-core/) | |Getting help| [![Docs status](https://readthedocs.org/projects/aiida-core/badge)](http://aiida-core.readthedocs.io/) [![Google Group](https://img.shields.io/badge/-Google%20Group-lightgrey.svg)](https://groups.google.com/forum/#!forum/aiidausers) -|Build status| [![Build Status](https://travis-ci.org/aiidateam/aiida-core.svg?branch=develop)](https://travis-ci.org/aiidateam/aiida-core) [![Coverage Status](https://coveralls.io/repos/github/aiidateam/aiida-core/badge.svg?branch=develop)](https://coveralls.io/github/aiidateam/aiida-core?branch=develop) | +|Build status| [![Build Status](https://travis-ci.org/aiidateam/aiida-core.svg?branch=develop)](https://travis-ci.org/aiidateam/aiida-core) [![Coverage Status](https://codecov.io/gh/aiidateam/aiida-core/branch/develop/graph/badge.svg)](https://codecov.io/gh/aiidateam/aiida-core) | |Activity| [![PyPI-downloads](https://img.shields.io/pypi/dm/aiida-core.svg?style=flat)](https://pypistats.org/packages/aiida-core) [![Commit Activity](https://img.shields.io/github/commit-activity/m/aiidateam/aiida-core.svg)](https://github.com/aiidateam/aiida-core/pulse) |Community| [![Affiliated with NumFOCUS](https://img.shields.io/badge/NumFOCUS-affiliated%20project-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org/sponsored-projects/affiliated-projects) [![Twitter](https://img.shields.io/twitter/follow/aiidateam.svg?style=social&label=Follow)](https://twitter.com/aiidateam) diff --git a/docs/requirements_for_rtd.txt b/docs/requirements_for_rtd.txt index 733dcd1a00..e245911c86 100644 --- a/docs/requirements_for_rtd.txt +++ b/docs/requirements_for_rtd.txt @@ -8,6 +8,7 @@ click-completion~=0.5.1 click-config-file~=0.5.0 click-spinner~=0.1.8 click~=7.0 +coverage<5.0 django~=2.2 docutils==0.15.2 ete3~=3.1 diff --git a/setup.json b/setup.json index e07f10610f..26460a9e6a 100644 --- a/setup.json +++ b/setup.json @@ -93,6 +93,7 @@ "pytest~=5.3", "pytest-timeout~=1.3", "pytest-cov~=2.7", + "coverage<5.0", "sqlalchemy-diff~=0.1.3" ], "dev_precommit": [ From 42d0cd56a58ce243384bcdd29dd2b982c8f052b6 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Tue, 3 Mar 2020 12:03:32 +0100 Subject: [PATCH 3/3] Remove omissions from coveragerc and reorder tests --- .coveragerc | 1 - .github/workflows/tests.sh | 28 +++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.coveragerc b/.coveragerc index a90fc09bc8..b27dfc7b30 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,5 @@ [run] source = aiida -omit = aiida/test*.py,aiida/*/test*.py,aiida/*/*/test*.py,aiida/*/*/*/test*.py,aiida/*/*/*/*/test*.py,aiida/*/*/*/*/*/test*.py,aiida/*/migrations/*.py,aiida/*/migrations/versions/*.py [html] directory = .ci/coverage/html diff --git a/.github/workflows/tests.sh b/.github/workflows/tests.sh index 74d3906b7f..169ca71525 100755 --- a/.github/workflows/tests.sh +++ b/.github/workflows/tests.sh @@ -3,24 +3,26 @@ set -ev # Make sure the folder containing the workchains is in the python path before the daemon is started export PYTHONPATH="${PYTHONPATH}:${GITHUB_WORKSPACE}/.ci" -# show timings of tests -export PYTEST_ADDOPTS=" --durations=0" +# pytest options: +# - report timings of tests +# - pytest-cov configuration taken from top-level .coveragerc +# - coverage is reported as XML and in terminal, +# including the numbers/ranges of lines which are not covered +# - coverage results of multiple tests are collected +# - coverage is reported on files in aiida/ +export PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --durations=0 --cov-config=.coveragerc --cov-report xml --cov-report term-missing --cov-append --cov=aiida" + +# daemon tests verdi daemon start 4 verdi -p test_${AIIDA_TEST_BACKEND} run .ci/test_daemon.py verdi daemon stop -# Make sure -# - omissions are taken from the top-level .coveragerc -# - coverage is reported as XML and in terminal including -# the numbers/ranges of lines which are not covered, -# - coverage results of multiple tests are collected, -# - the base directory for files to consider is aiida/ -export PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov-config=.coveragerc --cov-report xml --cov-report term-missing --cov-append --cov=aiida" - -AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest tests -AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest .ci/pytest +# tests for the testing infrastructure pytest --noconftest .ci/test_test_manager.py pytest --noconftest .ci/test_profile_manager.py +python .ci/test_plugin_testcase.py # uses custom unittest test runner +AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest .ci/pytest -python .ci/test_plugin_testcase.py +# main aiida-core tests +AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest tests