Skip to content

Commit

Permalink
setup.cfg: Require 100% test coverage
Browse files Browse the repository at this point in the history
Implements pytest, replacing `manage.py test`,
using the standard coala template.

A .nocover.yaml is added to list the areas not
yet fully covered by tests, so that all future
commits are required to maintain code coverage.

Related to #175
  • Loading branch information
jayvdb committed Aug 6, 2018
1 parent 28e9452 commit b62e2e3
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 4 deletions.
1 change: 0 additions & 1 deletion .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ fi
python manage.py fetch_deployed_data _site $ISSUES_JSON --repo-name gh-board

python manage.py migrate
python manage.py test
python manage.py import_contributors_data
python manage.py import_issues_data
python manage.py import_merge_requests_data
Expand Down
3 changes: 2 additions & 1 deletion .coafile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ shell = bash
# Do not allow the word "coala" to ensure the repository can be generalized out
# for use by other organizations.
files = **
ignore += .coafile, *requirements.txt, .travis.yml, LICENSE, .moban.yaml, .moban.dt/community-gitignore.jj2, public/**, _site/**, .ci/check_moban.sh
# .coverage crashes AnnotationBear
ignore += .coafile, *requirements.txt, .travis.yml, LICENSE, .nocover.yaml, .moban.yaml, .moban.dt/community-*.jj2, public/**, _site/**, .ci/check_moban.sh, .coverage
bears = KeywordBear
language = python 3
keywords = coala
Expand Down
3 changes: 3 additions & 0 deletions .moban.dt/community-test-requirements.txt.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coala-bears
git+https://gitlab.com/virresh/coala-antlr.git
{% include 'test-requirements.txt.jj2' %}
20 changes: 19 additions & 1 deletion .moban.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
overrides: coala.yaml
overrides: .nocover.yaml

package_module: community
packages:
- community
- activity
- inactive_issues
- data
- gci
- gsoc
- log
- meta_review
- openhub
- model
- twitter
- unassigned_issues

configuration:
template_dir:
Expand All @@ -9,3 +24,6 @@ configuration:
configuration_dir: ../coala-mobans/
targets:
- .gitignore: community-gitignore.jj2
- setup.cfg: setup.cfg.jj2
- test-requirements.txt: community-test-requirements.txt.jj2
- conftest.py: conftest.py
38 changes: 38 additions & 0 deletions .nocover.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
overrides: coala.yaml

allow_generic_no_cover: true

nocover_file_globs:
# These all need to be covered by tests
- activity/*.py
- community/git.py
- data/*.py
- gci/*.py
- gsoc/*.py
- log/*.py
- meta_review/handler.py
- model/*.py
- openhub/*.py
- twitter/*.py
# Optional coverage. Once off scripts.
- inactive_issues/inactive_issues_scraper.py
- unassigned_issues/unassigned_issues_scraper.py
# The following rules can remain here
# django db
- '*/migrations/*.py'
# django commands and related modules
- '*/management/commands/*.py'
- meta_review/load_from_db.py
- meta_review/dump_to_db.py
# django-distill runs these
- community/urls.py
- '*/views.py'
# tests
- '*/tests/*.py'

nocover_regexes:
# community/config.py
- def get_api_key
# meta_review/models.py
- def clear_score
- def __str__
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ before_install:
script:
- ./.ci/build.sh
- rm -rf private/
- pytest
- coala --non-interactive -V

notifications:
Expand Down
10 changes: 10 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Allow import to fail to avoid annoying developers
try:
from pytest_reqs import check_requirements
except ImportError:
check_requirements = None


if check_requirements:
def pytest_collection_modifyitems(config, session, items):
check_requirements(config, session, items)
112 changes: 112 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[bdist_wheel]
python-tag = py34.py35.py36

[tool:pytest]
minversion = 3.6.1

DJANGO_SETTINGS_MODULE = community.settings

testpaths =
community
activity
inactive_issues
data
gci
gsoc
log
meta_review
openhub
model
twitter
unassigned_issues

python_files = *Test.py
python_classes = *Test

addopts =
-r a
-p no:logging
--color=yes
--doctest-glob=*.rst
--doctest-modules
--doctest-ignore-import-error
--error-for-skips
--cov
--instafail
--profile
--reorder 'requirements.txt' 'test-requirements.txt' '*'

doctest_optionflags =
ELLIPSIS
IGNORE_EXCEPTION_DETAIL

reqsfilenamepatterns =
requirements.txt
test-requirements.txt

reqsignorevcs = True

timeout = 35

[coverage:coverage_env_plugin]
markers = True

[coverage:run]
branch = True
cover_pylib = False

plugins =
coverage_env_plugin
coverage_config_reload_plugin

source =
community
activity
inactive_issues
data
gci
gsoc
log
meta_review
openhub
model
twitter
unassigned_issues

omit =
tests/*
activity/*.py
community/git.py
data/*.py
gci/*.py
gsoc/*.py
log/*.py
meta_review/handler.py
model/*.py
openhub/*.py
twitter/*.py
inactive_issues/inactive_issues_scraper.py
unassigned_issues/unassigned_issues_scraper.py
*/migrations/*.py
*/management/commands/*.py
meta_review/load_from_db.py
meta_review/dump_to_db.py
community/urls.py
*/views.py
*/tests/*.py

[coverage:report]
fail_under = 100
show_missing = True
skip_covered = False
sort = Miss
exclude_lines =
pragma: no ?cover
pragma ${PLATFORM_SYSTEM}: no cover
pragma ${OS_NAME}: no cover
pragma Python [0-9.,]*${PYTHON_VERSION}[0-9.,]*: no cover
def get_api_key
def clear_score
def __str__

[coverage:force_end_of_section]
23 changes: 22 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
coala-bears
moban
git+https://gitlab.com/virresh/coala-antlr.git
coverage~=4.3.4
coverage-env-plugin~=0.1
coverage-config-reload-plugin~=0.2
codecov~=2.0.5
moban~=0.0.9
packaging~=16.8
pytest~=3.6.1
pytest-cov~=2.4
pytest-django~=3.3.3
pytest-env~=0.6.0
pytest-error-for-skips~=1.0
pytest-instafail~=0.3.0
pytest-mock~=1.1
pytest-profiling~=1.3.0
pytest-reorder~=0.1.0
pytest-reqs~=0.0.6
pytest-timeout~=1.3.0
pytest-travis-fold~=1.3.0
pytest-xdist~=1.15
requests-mock~=1.2
pip!=9.0.2, !=10.0.*, !=18.0
wheel~=0.29

0 comments on commit b62e2e3

Please sign in to comment.