Conversation
25adb30 to
0ab8eae
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive code coverage tracking to the CI workflow to support OpenSSF Silver Badge requirements. It instruments both unit and integration tests to collect coverage data, merges the profiles, and generates coverage reports that are displayed in GitHub's step summary.
Changes:
- Modified integration tests to collect coverage data with
-covermode=atomic -coverpkg=./...flags - Modified unit tests to collect coverage data, excluding the
/testdirectory packages - Added new
coverage-reportjob that merges all coverage profiles and generates summary reports
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | ||
| with: | ||
| name: coverage-unit | ||
| path: coverage | ||
|
|
||
| - name: Download integration coverage artifacts | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 |
There was a problem hiding this comment.
Missing version comment for the download-artifact action. All other action uses in this workflow include version comments (e.g., # v6.0.0). Please add a version comment to maintain consistency with the established convention in this file.
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| name: coverage-unit | |
| path: coverage | |
| - name: Download integration coverage artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # download-artifact pinned SHA | |
| with: | |
| name: coverage-unit | |
| path: coverage | |
| - name: Download integration coverage artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # download-artifact pinned SHA |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | ||
| with: | ||
| name: coverage-unit | ||
| path: coverage | ||
|
|
||
| - name: Download integration coverage artifacts | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 |
There was a problem hiding this comment.
Missing version comment for the download-artifact action. All other action uses in this workflow include version comments (e.g., # v6.0.0). Please add a version comment to maintain consistency with the established convention in this file.
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| name: coverage-unit | |
| path: coverage | |
| - name: Download integration coverage artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.1.8 | |
| with: | |
| name: coverage-unit | |
| path: coverage | |
| - name: Download integration coverage artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.1.8 |
| runs-on: ubuntu-22.04 | ||
| needs: | ||
| - unit | ||
| - integration |
There was a problem hiding this comment.
The coverage-report job will not run if either the unit or integration jobs fail, even though those jobs use if: always() to upload coverage artifacts on failure. This means coverage reports won't be generated when tests fail. Consider adding if: always() to the coverage-report job (or using a more specific condition like if: success() || failure()) to ensure coverage reports are generated even when tests fail, which would be valuable for understanding coverage gaps in failing test scenarios.
| - integration | |
| - integration | |
| if: ${{ always() }} |
.github/workflows/ci.yml
Outdated
| exit 1 | ||
| fi | ||
|
|
||
| "$(go env GOPATH)/bin/gocovmerge" coverage/unit.out ${integration_profiles} > coverage/all.out |
There was a problem hiding this comment.
The unquoted variable expansion ${integration_profiles} could potentially cause issues with shell word splitting if any filenames contain spaces or special characters. While the current suite names don't contain spaces, it's a best practice to use an array or quote the variable to make the script more robust. Consider using a bash array: integration_profiles=($(find...)) and then "${integration_profiles[@]}" in the gocovmerge command.
0ab8eae to
853ecfb
Compare
| fi | ||
| go test -timeout=59m -v -json ${run} ${skip} ./test | go run ./cmd/test2json2gha --slow 120s --logdir /tmp/testlogs | ||
|
|
||
| go test -timeout=59m -v -json \ |
There was a problem hiding this comment.
Isn't this reporting coverage of what get called on the client side but not the actual frontend?
We would need to build the frontend with coverage instrumentation, and then extract the data out of it (maybe if coverage is enabled we can inject the metadata into the result object and extract it in the test client invocation?).
b07535b to
edde69b
Compare
This PR adds end-to-end Go code coverage reporting to the existing CI pipeline. Fixes: project-dalec#889 Signed-off-by: Kartik Joshi <karikjoshi21@gmail.com>
edde69b to
f93ab8e
Compare
Add CI coverage reporting (unit + integration)
This PR adds Go coverage tracking to the existing CI
Fixes: #889