Skip to content

Commit

Permalink
chore: Fail build if code coverage is too low (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
farleyb-amazon committed Mar 26, 2021
1 parent 93e4648 commit 7bbfb76
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
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

[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

0 comments on commit 7bbfb76

Please sign in to comment.