Skip to content

chore: Fail build if code coverage is too low #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ batch:
buildspec: codebuild/py38/awses_2.0.0.yml
- identifier: py38_awses_latest
buildspec: codebuild/py38/awses_latest.yml

- identifier: code_coverage
buildspec: codebuild/coverage/coverage.yml
14 changes: 14 additions & 0 deletions codebuild/coverage/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 0.2

env:
variables:
TOXENV: "coverage"

phases:
install:
runtime-versions:
python: latest
build:
commands:
- pip install tox
- tox
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ branch = True

[coverage:report]
show_missing = True
fail_under = 95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record I think 95% is almost a bit too high - I like to aim for 90% so we don't hit diminishing returns, given code coverage is just an imprecise measurement. But given we're already this high I'm willing to see whether we can keep it up without feeling like we're writing a lot of low-value tests.


[tool:pytest]
log_level = DEBUG
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ envlist =
# test-release :: Builds dist files and uploads to testpypi pypirc profile.
# release :: Builds dist files and uploads to pypi pypirc profile.

# Reporting environments:
#
# coverage :: Runs code coverage, failing the build if coverage is below the configured threshold

[testenv:base-command]
commands = pytest --basetemp={envtmpdir} -l --cov aws_encryption_sdk {posargs}
commands = pytest --basetemp={envtmpdir} -l {posargs}

[testenv]
passenv =
Expand All @@ -62,6 +66,10 @@ commands =
all: {[testenv:base-command]commands} test/ examples/test/
manual: {[testenv:base-command]commands}

# Run code coverage on the unit tests
[testenv:coverage]
commands = {[testenv:base-command]commands} --cov aws_encryption_sdk test/ -m local

# Verify that local tests work without environment variables present
[testenv:nocmk]
basepython = python3
Expand Down