Skip to content

Commit

Permalink
chore: Fail build if code coverage is too low (aws#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
farleyb-amazon authored Mar 26, 2021
1 parent 25c7c3d commit 2160156
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 @@ -13,3 +13,6 @@ batch:
buildspec: codebuild/python3.7.yml
- identifier: python3_8
buildspec: codebuild/python3.8.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 = 90

[mypy]
ignore_missing_imports = True
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 dynamodb_encryption_sdk {posargs}
commands = pytest --basetemp={envtmpdir} -l {posargs}

[testenv]
passenv =
Expand Down Expand Up @@ -86,6 +90,10 @@ commands =
# Only run examples tests
examples: {[testenv:base-command]commands} examples/test/ -m "examples"

# Run code coverage on the unit tests
[testenv:coverage]
commands = {[testenv:base-command]commands} --cov dynamodb_encryption_sdk test/ -m "local and not slow and not veryslow and not nope"

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

0 comments on commit 2160156

Please sign in to comment.