-
Notifications
You must be signed in to change notification settings - Fork 2
Setup infrastructure for coverage based testing and linting with black #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
In `tests.yml`, there is also now a commented job step to push coverage to codecov. The base coverage right now as of generating this commit is 54% overall, missing 300 branches and partially covering 20 other branches
Readme file says python 3.9, so testing on the reported version makes more sense than testing on an older version
- Tests badge in README.md - Minor cleanups to tests - Rebuild poetry lock file
These were created separately to make sure that if adding coverage broke tests (or formatting), it would be easier to determine the cause
cd315db to
f2cb605
Compare
|
A few things to note that I didn't put in the pr description - If you do want to use a 3rd party provider for code coverage reporting, I'm not familiar with doing it in org owned repos, so I can't help there very much. But, this should give a pretty reasonable code formatting standard, and base coverage testing setup, and I'm happy to make any changes you think should be made, and/or remove any changes you think are not worth it. |
report failures, not just xpasses and xfails
5d27a03 to
5e18acf
Compare
Adds
pytest-covas a dev dependency to enable simple coverage generation from pytest.Coverage is automatically calculated and emitted to the terminal output when running
poetry run pytest. Actions Workflow now generates acoverage.xmlfile, which can be pushed to a coverage reporting provider of choice, if any, and runs on python 3.9 since thats the version specified in the readme file, and python 3.8 is EOL in just over a year. On top of standard line coverage, branch coverage is also enabled to check if all paths of conditionals are considered.I also updated the tests to properly use the xfail setup for excluding files, to see which tests xfailed/xpassed add
-rxXto your pytest invocation (see how tests are run in the GHA workflow for an example)Since I was adding a new depenency for
pytest-covandblack, I updatedpyproject.tomlto use the new dev dependency format, treating it like an extras group - instead of being under the[tool.poetry.dev-dependencies]table, they now reside under the[tool.poetry.group.dev.dependencies](where poetry addedpytest-covwhen I ranpoetry add pytest-cov -G dev).While I know you said that you weren't keen on adding pre-commit to here in #39, its the easiest way to add black here for people, so they don't have to remember to run it locally, or setup their editor to auto format code, which is editor dependent. Its a super simple config, just to run black and some other formatting things. I can remove it if you want, I specifically made sure not to add it as a dependency to the project, so its completely optional.
Black ignores any files in the test problems subdirectories to not cause false test failures, and has a line length limit overridden to 100 instead of its default of 88 (My personal opinion is PEP8's line length limit is too low, so I always increase black's default). I also have it set to require the same major version as I set it up with, as every comes a new set of formatting from it, and its not nice to have black suddenly start failing every January when the first new release of every comes out.
Mostly Resolves #39, though it doesn't add linting to md files here. If wanted, I'll setup a PR to the instructor datascience bank as an example to add prettier to lint markdown files there, with pre-commit and/or gh actions, where formatting markdown files is more important.
Sidenote, due to adding in black, you may want to consider a
.git-blame-ignore-revsfile with the following content to remove commits from black formatting from screwing up and git blames: