Skip to content

Commit 646e32e

Browse files
farleyb-amazonrobin-aws
authored andcommitted
chore: Fail build if code coverage is too low (aws#325)
1 parent a7fca20 commit 646e32e

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
@@ -57,3 +57,6 @@ batch:
5757
buildspec: codebuild/py38/awses_2.0.0.yml
5858
- identifier: py38_awses_latest
5959
buildspec: codebuild/py38/awses_latest.yml
60+
61+
- identifier: code_coverage
62+
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 = 95
1213

1314
[tool:pytest]
1415
log_level = DEBUG

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 aws_encryption_sdk {posargs}
43+
commands = pytest --basetemp={envtmpdir} -l {posargs}
4044

4145
[testenv]
4246
passenv =
@@ -62,6 +66,10 @@ commands =
6266
all: {[testenv:base-command]commands} test/ examples/test/
6367
manual: {[testenv:base-command]commands}
6468

69+
# Run code coverage on the unit tests
70+
[testenv:coverage]
71+
commands = {[testenv:base-command]commands} --cov aws_encryption_sdk test/ -m local
72+
6573
# Verify that local tests work without environment variables present
6674
[testenv:nocmk]
6775
basepython = python3

0 commit comments

Comments
 (0)