meta: Add code coverage metrics for node/ and sdk/#4654
meta: Add code coverage metrics for node/ and sdk/#4654johnsaigle merged 8 commits intowormhole-foundation:mainfrom
Conversation
e128227 to
a7330f7
Compare
djb15
left a comment
There was a problem hiding this comment.
Approving as these changes are not intrusive (from a security point of view) and at a high level the approach is what we discussed. I'd be keen to get this into CI and see what it's like to use, we can always respond to feedback.
Awesome work getting this written so quickly!
|
Thanks! I actually asked around and found this project: https://github.com/gwatts/go-coverage-action I think it could potentially be simpler. I'm going to try it out and based on the results I'll update this PR |
fad687d to
27d6e17
Compare
pleasew8t
left a comment
There was a problem hiding this comment.
I ran through the different make targets, and they seem fine.
040f41f to
fcf18a4
Compare
fcf18a4 to
5260af6
Compare
5260af6 to
376d793
Compare
|
@pleasew8t @djb15 would you mind re-reviewing? the recent commits separate the jobs and fix some annoyances with using the tool, but no major changes were made. |
1aebc72 to
6a9bf9f
Compare
fix cosmwasm flag; add auto-update mode spelling use -race when checking code coverage to match CI update codeowners add build step to update update coverage baseline add -race for sdk add comment to sync CI with code coverage version
6a9bf9f to
ceecc2a
Compare
|
Waiting on @evan-gray's feedback on #4653 before merging. |
This PR introduces a method to measure unit test coverage in the Guardian, specificially in the
node/andsdk/directories.Overview
The PR uses Go's native code coverage metric tools to generate a percentage-based coverage of all of the files. After the tests finish running, a simple Go program evaluates the result against the previous run of the tool (which is checked in to the repo). If the numbers decrease, the tool exits and shows the offending file.
The idea is to integrate this new script into our existing unit test job in CI. If a new PR removes tests or adds new, untested code, CI will cause it to fail.
Demonstration
#4653 is a dummy PR that deliberately reduces test coverage. Its
node-testsjob fails as a result.Development Story
Case 1: Insufficient Tests
Case 2: Test coverage remains the same
Case 3: Test coverage increases
If a developer forgets to generate and check-in the new coverage report, the build still fails. The idea here is to cause any increase in coverage to ratchet forward and prevent any regressions once we hit a new target. (Otherwise, we may go from a baseline of 50% to 55% and then back down to 50% if the new coverage report does not get checked-in. It's hard to remember to do this automatically, so CI can check for us. This is somewhat intrusive but we also fail builds on spelling errors and new linting rules, so this approach is consistent with the rest of CI and existing dev expectations.)
There is a slight tolerance for some drift in coverage as certain factors may cause tiny divergences in tests (e.g. Concurrency based tests via
race; differences in the runner vs. a dev's machine).Motivation
Why not use
tool Xinstead of writing something new?I took this approach because:
Alternatives Considered
Operation
We could configure the new job to not block merge. This allows us to track code coverage without it being a strict bottleneck.