Skip to content

Commit

Permalink
Update configuration to include test coverage
Browse files Browse the repository at this point in the history
This includes adding necessary pip requirements, adding a `.coveragerc`
file, updating the pytest configuration, and updating the `test` job in
the `build` workflow for GitHub Actions.
  • Loading branch information
mcdonnnj committed May 13, 2024
1 parent fc8a5be commit fe33e94
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ lambda_build.zip

## Python ##
__pycache__
.coverage
.mypy_cache
.pytest_cache
.python-version
5 changes: 3 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fe33e94

Please sign in to comment.