diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..5da1987 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,12 @@ +# This is the configuration for code coverage checks +# https://coverage.readthedocs.io/en/latest/config.html + +[run] +source = cisagov_lambda +omit = +branch = true + +[report] +exclude_lines = + if __name__ == "__main__": +show_missing = true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cafa82..9bf02f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -216,6 +216,12 @@ jobs: # is not installed into the local `pip` environment Please see: # https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html#invoking-pytest-versus-python-m-pytest run: python -m pytest + - name: Upload coverage report + run: coveralls + env: + COVERALLS_SERVICE_NAME: github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: success() - name: Setup tmate debug session uses: mxschmitt/action-tmate@v3 if: env.RUN_TMATE diff --git a/.gitignore b/.gitignore index 56911e6..3475637 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,7 @@ lambda_build.zip ## Python ## __pycache__ +.coverage .mypy_cache +.pytest_cache .python-version diff --git a/pytest.ini b/pytest.ini index 45cf99a..1c419f0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] -# Increase verbosity and display extra test summary info for tests that did not pass -addopts = --verbose -ra +# Increase verbosity, display extra test summary info for tests that did not +# pass, and report test coverage information. +addopts = --verbose -ra --cov diff --git a/requirements-test.txt b/requirements-test.txt index 5624133..fd42534 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,15 @@ --requirement requirements.txt +coverage +# coveralls 1.11.0 added a service number for calls from +# GitHub Actions. This caused a regression which resulted in a 422 +# response from the coveralls API with the message: +# Unprocessable Entity for url: https://coveralls.io/api/v1/jobs +# 1.11.1 fixed this issue, but to ensure expected behavior we'll pin +# to never grab the regression version. +coveralls != 1.11.0 +# This is required to install project dependencies so that pytest can be run +# successfully. pipenv pre-commit pytest +pytest-cov