-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Set up code coverage reports on GitHub Actions #350
Comments
In the “easy to integrate, easy to move on from” category, I can say my codecov action has been good enough for me so far (and obviously improvements are welcome!). https://github.com/mattpolzin/swift-codecov-action here it is in action; it currently just prints a coverage table, optionally fails if coverage standards are not met, and results in a CI checkmark on PRs. |
Lovely! I wonder how hard it would be to modify it to post coverage results as comments? We previously had some success in creating GitHub releases from shell scripts directly using |
One option would be to “fix” the current limitations in what my action outputs and pair it with other GitHub actions (I’m sure there’s one out there that does nothing but post a comment). |
(I’m not opposed to adding features like that to my action, I just generally find GitHub actions to be so conveniently composable) |
Is it possible to put it in the diff like the linter comments? That way it doesn't clutter the discussion. |
Definitely (assuming I catch your drift). Creating a file and committing it is not so different effort-wise to creating a new PR comment from a GitHub action. |
Our SwiftLint warnings are attached in diffs to specific lines, while code coverage percentage is global per project. I like the idea of committing that percentage as a file though, that way it's simpler to compare coverage of a PR branch with coverage in the main branch. We wouldn't have to run tests again to calculate the value for the main branch then. We could just check out the main branch in the job and load the value from the file for comparison. |
Bummer, using |
We already work around that by building just the test product with Tokamak/.github/workflows/ci.yml Line 29 in b55f703
|
Right, but that It would not be so terrible to pull the |
On Ubuntu you'd do essentially the same thing, build just the tests with |
The test bundle path would be the same I guess, |
Oh, that’s cool. TIL! |
I wonder if it’s possible to generate the test coverage file this way though. Worth exploring. (Referring to the file created by |
Got that figured out; building with the right flags and telling Proof of concept with a rudimentary comment here: mattpolzin#2 / https://github.com/mattpolzin/Tokamak/pull/2/checks?check_run_id=1724996327 Requires an access token to be added to this repository before it will work (for the commenting). |
Perfect! 👏 |
Closes #350. Adds simple code coverage analysis. Until the GitHub token is set up in this repo, you can see the results including a comment on the PR here: mattpolzin#2 * Adding codecov CI workflow. * doh. forgot to skip build. * drop unneeded llvm env var from build invocation. make comment always run. * try a way to update a previous comment * try to get comments to run on failure. * use bug fix to codecov action. * fix comment search string and drop min coverage * use replace on comment updates * attempt at diffing coverage from main branch * comment out tests to affect test coverage * try method for multiline outputs * do i need to put it in its own script file * right, switch coverage gen order to have branch checked out second. * attempt to get code quotation around diff output. * switch to git diff * add note about the new script. * try echoing a warning. * post warning on success and error on failure. * uncomment tests
I think stability of our existing code should be of higher priority. We need to be diligent about keeping test coverage high and not reducing it significantly (ideally increasing it, as it's probably already too low) in any PRs. GitHub Actions job that runs in a PR and posts current coverage as a comment would be super helpful.
After that is done we can set up more complex workflows that compute coverage deltas. I know that proprietary solutions like Codecov can already do this, but I'm wary of relying on them as they tend to shut down free access for open-source projects after some period of initial unsustainable growth. GitHub Actions seems to be a more reliable tool for this long term.
The text was updated successfully, but these errors were encountered: