Skip to content

Commit 2160156

Browse files
chore: Fail build if code coverage is too low (#153)
1 parent 25c7c3d commit 2160156

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

buildspec.yml

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ batch:
1313
buildspec: codebuild/python3.7.yml
1414
- identifier: python3_8
1515
buildspec: codebuild/python3.8.yml
16+
17+
- identifier: code_coverage
18+
buildspec: codebuild/coverage/coverage.yml

codebuild/coverage/coverage.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
TOXENV: "coverage"
6+
7+
phases:
8+
install:
9+
runtime-versions:
10+
python: latest
11+
build:
12+
commands:
13+
- pip install tox
14+
- tox

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ branch = True
99

1010
[coverage:report]
1111
show_missing = True
12+
fail_under = 90
1213

1314
[mypy]
1415
ignore_missing_imports = True

tox.ini

+9-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ envlist =
3535
# test-release :: Builds dist files and uploads to testpypi pypirc profile.
3636
# release :: Builds dist files and uploads to pypi pypirc profile.
3737

38+
# Reporting environments:
39+
#
40+
# coverage :: Runs code coverage, failing the build if coverage is below the configured threshold
41+
3842
[testenv:base-command]
39-
commands = pytest --basetemp={envtmpdir} -l --cov dynamodb_encryption_sdk {posargs}
43+
commands = pytest --basetemp={envtmpdir} -l {posargs}
4044

4145
[testenv]
4246
passenv =
@@ -86,6 +90,10 @@ commands =
8690
# Only run examples tests
8791
examples: {[testenv:base-command]commands} examples/test/ -m "examples"
8892

93+
# Run code coverage on the unit tests
94+
[testenv:coverage]
95+
commands = {[testenv:base-command]commands} --cov dynamodb_encryption_sdk test/ -m "local and not slow and not veryslow and not nope"
96+
8997
# Verify that local tests work without environment variables present
9098
[testenv:nocmk]
9199
basepython = python3

0 commit comments

Comments
 (0)