Skip to content

Add Codecov integration for unit test coverage#84

Open
deekay2310 wants to merge 2 commits intomainfrom
enable-codecov
Open

Add Codecov integration for unit test coverage#84
deekay2310 wants to merge 2 commits intomainfrom
enable-codecov

Conversation

@deekay2310
Copy link
Copy Markdown

@deekay2310 deekay2310 commented Apr 2, 2026

Purpose of this PR

Add Codecov integration to track unit test code coverage for the Spark Operator.

Proposed changes:

  • Added .codecov.yml configuration with project/patch coverage status checks, unit flag (with e2e flag scaffolded for future use), and PR comment layout.
  • Added a Codecov upload step to the unit-test job in .github/workflows/integration.yaml using codecov/codecov-action@v5.
  • Added codecov badge to README.

Change Category

  • Bugfix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that could affect existing functionality)
  • Documentation update

Rationale

Enables visibility into unit test coverage trends across PRs, helping maintainers identify untested code paths and prevent coverage regressions. The e2e coverage flag is scaffolded for future enablement.

Checklist

  • I have conducted a self-review of my own code.
  • I have updated documentation accordingly.
  • I have added tests that prove my changes are effective or that my feature works.
  • Existing unit tests pass locally with my changes.

Additional Notes

  • No new tests added as this is CI infrastructure, not application logic. Coverage will be validated once the PR's CI run uploads to Codecov.
  • E2E coverage reporting is commented out in .codecov.yml and can be enabled if required and once e2e tests produce a coverage profile.
  • codecov needs a baseline to compare test coverage against, which will be generated once this PR is merged to main.

Summary by CodeRabbit

  • Chores
    • Integrated Codecov for automated code coverage tracking and reporting in the CI/CD pipeline.
    • Added coverage status badge to the project documentation.
    • Configured coverage collection and upload during automated builds.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

The pull request introduces Codecov integration to the project. A .codecov.yml configuration file specifies coverage targets and PR comment behavior, a unit flag is defined for coverage tracking, and scaffolding for an e2e flag is included. The GitHub Actions workflow now uploads Go unit test coverage to Codecov after running tests, authenticating with a token secret. The Makefile's unit-test target writes coverage output to cover-unit.out instead of cover.out. A Codecov badge links to the main branch coverage graph in the README.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


Security Observations

Token Handling: The workflow correctly uses secrets.CODECOV_TOKEN rather than hardcoding credentials. Verify that CODECOV_TOKEN is configured in repository secrets and not exposed in logs or artifacts.

Action Source: Confirm codecov/codecov-action@v5 is the official Codecov action and pinned to a specific commit hash if risk appetite permits (e.g., codecov/codecov-action@v5 could be replaced with a full SHA for supply-chain assurance).

No other security findings in these configuration and CI/CD additions.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: adding Codecov integration for unit test coverage tracking, which is the core objective across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Signed-off-by: Dev Kumar <dkuma@redhat.com>
@deekay2310 deekay2310 marked this pull request as ready for review April 2, 2026 14:58
@deekay2310 deekay2310 requested a review from a team as a code owner April 2, 2026 14:58
Copy link
Copy Markdown

@shruthis4 shruthis4 left a comment

Choose a reason for hiding this comment

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

Hi Dev,
I think overall we want the report to be hosted for our midstream repo so we know what the coverage is. I would also want to know the coverage we get from examples/openshift/tests . If possible each in separate buckets.

- name: Run go unit tests
run: make unit-test

- name: Upload unit test coverage to Codecov
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is an upstream workflow, and adding it here would lead to merge conflicts and we do not want to propagate this change to upstream as the repo does not have the codecov app setup.

Copy link
Copy Markdown
Author

@deekay2310 deekay2310 Apr 2, 2026

Choose a reason for hiding this comment

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

Great, thanks for the additional context, let me make new changes around this. The workaround will be to create a separate codecov workflow which will rerun the unit tests in order to upload them.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

There is possibility of making this more efficient, but that will require changes to integration workflow where we store the cover.out file as artifact or cache to persist it.

Makefile Outdated
@echo "Running unit tests..."
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)"
go test $(shell go list ./... | grep -v /e2e) -coverprofile cover.out
go test $(shell go list ./... | grep -v /e2e) -coverprofile cover-unit.out
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same comment here, this Makefile comes from upstream

README.md Outdated
# Kubeflow Spark Operator

[![GitHub release](https://img.shields.io/github/v/release/kubeflow/spark-operator)](https://github.com/kubeflow/spark-operator/releases)
[![codecov](https://codecov.io/gh/kubeflow/spark-operator/branch/main/graph/badge.svg)](https://codecov.io/gh/kubeflow/spark-operator)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shouldnt the report be hosted for opendatahub-io/spark-operator fork? Also this README.md is upstream file we inherit, so we should keep this clean and mergable

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/integration.yaml:
- Around line 119-124: The workflow step named "Upload unit test coverage to
Codecov" currently uses a mutable tag reference `codecov/codecov-action@v5`;
replace that with the action pinned to the full 40-character commit SHA for the
v5 tag (resolve `v5` to its commit SHA via the GitHub API and substitute
`codecov/codecov-action@<40-char-sha>`). Keep the step name, files, flags, and
token unchanged (files: cover-unit.out, flags: unit, token: ${{
secrets.CODECOV_TOKEN }}) and commit the updated immutable `uses:` string.

In `@Makefile`:
- Around line 165-167: Makefile was changed to produce and read cover-unit.out
(and generates cover.html) but .gitignore still only ignores cover.out; update
.gitignore to ignore the new artifacts by adding cover-unit.out and cover.html
(or replace the single cover.out entry with a more general pattern like
cover*.out and cover*.html) so local coverage files from the Makefile targets
are not shown in git status or accidentally committed; look for entries related
to cover.out and update them accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 490e5928-f258-4f75-9d23-caca60872735

📥 Commits

Reviewing files that changed from the base of the PR and between 28e9e4f and bdc77af.

📒 Files selected for processing (4)
  • .codecov.yml
  • .github/workflows/integration.yaml
  • Makefile
  • README.md

…nd e2e-kustomize coverage, addressing PR review feedback

Signed-off-by: Dev Kumar <dkuma@redhat.com>
@deekay2310 deekay2310 requested a review from shruthis4 April 2, 2026 20:15
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.

2 participants