Skip to content

Improve coverage checks #466

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

Closed
wants to merge 9 commits into from
Closed

Improve coverage checks #466

wants to merge 9 commits into from

Conversation

l0b0
Copy link
Contributor

@l0b0 l0b0 commented Jun 19, 2021

Related Issue(s): #331

Description: Add tests, exclude some lines from coverage count, include tests in coverage count (highlighting unreached test code), and do some minor code changes to make it more testable.

The first PR already contains a bunch of orthogonal improvements. Let me know if you want to split it up into simpler pieces.

PR Checklist:

  • Code is formatted (run pre-commit run --all-files)
  • Tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

@codecov-commenter
Copy link

codecov-commenter commented Jun 19, 2021

Codecov Report

Merging #466 (daf22a0) into main (d51dd28) will decrease coverage by 2.96%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
- Coverage   91.48%   88.52%   -2.97%     
==========================================
  Files          40       40              
  Lines        5240     5201      -39     
  Branches        0      863     +863     
==========================================
- Hits         4794     4604     -190     
+ Misses        446      418      -28     
- Partials        0      179     +179     
Impacted Files Coverage Δ
pystac/extensions/sar.py 98.96% <ø> (+1.03%) ⬆️
pystac/extensions/view.py 98.38% <ø> (+0.80%) ⬆️
pystac/serialization/common_properties.py 80.35% <0.00%> (-12.50%) ⬇️
pystac/validation/schema_uri_map.py 76.31% <0.00%> (-10.53%) ⬇️
pystac/validation/stac_validator.py 77.01% <0.00%> (-9.20%) ⬇️
pystac/__init__.py 92.68% <0.00%> (-7.32%) ⬇️
pystac/extensions/hooks.py 80.70% <0.00%> (-5.74%) ⬇️
pystac/validation/__init__.py 79.03% <0.00%> (-5.59%) ⬇️
pystac/serialization/migrate.py 81.96% <0.00%> (-5.34%) ⬇️
pystac/collection.py 90.53% <0.00%> (-4.98%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d51dd28...daf22a0. Read the comment docs.

@l0b0 l0b0 marked this pull request as ready for review June 21, 2021 23:38
@l0b0 l0b0 changed the title Bump coverage Improve coverage checks Jun 21, 2021
Copy link
Contributor

@duckontheweb duckontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me aside from using TestCases.get_path in some places.

I'm not sure what is going on with the Codecov.io reports. When I get the coverage report locally I get 93.17% coverage, but the report that's getting posted here shows 88.52% for this PR. I'll look into that separately and see if I can figure out the cause.

l0b0 added 9 commits June 24, 2021 08:09
Based on <https://stackoverflow.com/a/13477954/96588>.

Also add tests to verify the exception being thrown.
By using the current file rather than the root of the project as the
reference, the tests are now runnable for example in an IDE which uses
the "tests" directory as the root.
It's already configured in .coveragerc.
Missing coverage in tests means unreached (and usually unreachable) test
code, often indicating a test bug.
Stricter than statement coverage.
@l0b0 l0b0 force-pushed the bump-coverage branch 2 times, most recently from 3cada57 to f5d9ce7 Compare June 23, 2021 20:26
@duckontheweb
Copy link
Contributor

I'm not sure what is going on with the Codecov.io reports. When I get the coverage report locally I get 93.17% coverage, but the report that's getting posted here shows 88.52% for this PR. I'll look into that separately and see if I can figure out the cause.

@l0b0 In #452 I created a separate coverage CI job for uploading to Codecov.io so that we could get coverage reports even when coverage drops to help us identify gaps (this happened specifically in 71f07d9). I did this by directly using the coverage run... command in the new job, but I'm realizing now that I probably should have updated scripts/test to allow us to override --fail-under instead so that we wouldn't have to update that command in 2 places.

I think the quick fix is to update the coverage CI job with the same changes you made to scripts/test. If you want to also update scripts/test so that we can use it in both cases that's great too 😄 , but I can do that separately.

f"SAR extension does not apply to type {type(obj)}"
f"SAR extension does not apply to type '{type(obj).__name__}'"
Copy link
Contributor

@duckontheweb duckontheweb Jun 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this change could be made for a number of other extensions as well. Is there a reason to only change this for the sar and view extensions, or should we update the ext method for all extensions in this PR?

Copy link
Contributor Author

@l0b0 l0b0 Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, but I'd need to be sure that you're OK with changing all of them so it's not wasted effort. What do you think?

I could also pull these changes into a separate PR if that helps.

@l0b0
Copy link
Contributor Author

l0b0 commented Jun 29, 2021

Closing in favour of smaller PRs.

@l0b0 l0b0 closed this Jun 29, 2021
@l0b0 l0b0 deleted the bump-coverage branch June 29, 2021 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants