Skip to content

Add code coverage#961

Open
kartikjoshi21 wants to merge 1 commit intoproject-dalec:mainfrom
kartikjoshi21:kartikjoshi21/code-coverage
Open

Add code coverage#961
kartikjoshi21 wants to merge 1 commit intoproject-dalec:mainfrom
kartikjoshi21:kartikjoshi21/code-coverage

Conversation

@kartikjoshi21
Copy link
Member

@kartikjoshi21 kartikjoshi21 commented Feb 5, 2026

Add CI coverage reporting (unit + integration)

This PR adds Go coverage tracking to the existing CI

  1. Integration matrix now runs go test ./test with coverage (-covermode=atomic -coverpkg=./...) and uploads per-suite profiles (coverage-integration-*).
  2. Unit job now generates coverage/unit.out and uploads it (coverage-unit).
  3. New coverage-report job downloads artifacts, merges profiles, generates summary.txt + index.html, and posts total coverage in the GitHub Step Summary (also uploads coverage-report artifact).

Fixes: #889

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/code-coverage branch 3 times, most recently from 25adb30 to 0ab8eae Compare February 6, 2026 10:03
@kartikjoshi21 kartikjoshi21 marked this pull request as ready for review February 6, 2026 10:05
Copilot AI review requested due to automatic review settings February 6, 2026 10:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 /test directory packages
  • Added new coverage-report job that merges all coverage profiles and generates summary reports

Comment on lines +501 to +507
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: coverage-unit
path: coverage

- name: Download integration coverage artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +501 to +507
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: coverage-unit
path: coverage

- name: Download integration coverage artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
runs-on: ubuntu-22.04
needs:
- unit
- integration
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- integration
- integration
if: ${{ always() }}

Copilot uses AI. Check for mistakes.
exit 1
fi

"$(go env GOPATH)/bin/gocovmerge" coverage/unit.out ${integration_profiles} > coverage/all.out
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/code-coverage branch from 0ab8eae to 853ecfb Compare February 9, 2026 09:32
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 \
Copy link
Collaborator

Choose a reason for hiding this comment

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

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?).

https://go.dev/doc/build-cover

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/code-coverage branch 4 times, most recently from b07535b to edde69b Compare February 25, 2026 17:46
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>
@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/code-coverage branch from edde69b to f93ab8e Compare February 26, 2026 09:48
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.

[REQ] Add code coverage testing

4 participants