Skip to content

ci: onboard Codecov for unit test coverage tracking#510

Open
ptomanRH wants to merge 1 commit into
guacsec:mainfrom
ptomanRH:codecov-onboarding
Open

ci: onboard Codecov for unit test coverage tracking#510
ptomanRH wants to merge 1 commit into
guacsec:mainfrom
ptomanRH:codecov-onboarding

Conversation

@ptomanRH
Copy link
Copy Markdown

@ptomanRH ptomanRH commented Jun 2, 2026

Summary

  • Add codecov/codecov-action@v5 to the PR workflow with OIDC authentication (use_oidc: true) to upload JaCoCo coverage reports to app.codecov.io
  • Replace the actions/upload-artifact step with the Codecov upload step, keeping the same matrix guard (matrix.java == env.MAIN_JAVA_VER)
  • Add id-token: write permission at job level for OIDC token exchange
  • Add codecov.yml with informational status checks, unit-tests flag with carryforward enabled, and ignore patterns for test/resource/build directories

Details

The existing JaCoCo setup is already complete:

  • Version 0.8.14 declared in pluginManagement
  • prepare-agent and check goals in the main build plugins
  • report goal in the cov profile (activated by -Pcov)
  • Excludes configured for API model, exception, impl, and logging packages

No changes to pom.xml were needed.

Test plan

Ref: COVERPORT-253

Summary by Sourcery

Integrate Codecov into the PR workflow to upload JaCoCo coverage for the main Java version and configure repository-wide coverage reporting behavior.

New Features:

  • Introduce Codecov integration for tracking unit test coverage in the repository.

Enhancements:

  • Add a Codecov configuration file to define informational project and patch status checks, a unit-test coverage flag with carryforward, and directory ignore rules for coverage calculations.

CI:

  • Update the PR GitHub Actions workflow to upload JaCoCo coverage to Codecov using OIDC authentication for the main Java matrix entry.
  • Grant id-token write permission in the PR workflow job to enable OIDC-based authentication for Codecov uploads.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 2, 2026

Reviewer's Guide

Adds Codecov integration to the PR CI workflow to upload JaCoCo coverage via OIDC and configures Codecov behavior through a new codecov.yml file with informational checks and path/ignore settings.

Sequence diagram for CI PR workflow uploading coverage to Codecov

sequenceDiagram
    actor Developer
    participant GitHub_Actions_PR_Workflow as GitHub_Actions_PR_Workflow
    participant Maven_Build as Maven_Build
    participant Codecov_Action as Codecov_Action
    participant Codecov_Service as Codecov_Service

    Developer->>GitHub_Actions_PR_Workflow: pr.yml
    GitHub_Actions_PR_Workflow->>Maven_Build: -Pcov
    Maven_Build-->>GitHub_Actions_PR_Workflow: ./target/site/jacoco/jacoco.xml

    GitHub_Actions_PR_Workflow->>Codecov_Action: Upload_coverage_to_Codecov_step
    Codecov_Action->>Codecov_Service: codecov/codecov-action@v5 use_oidc_true
    Codecov_Service-->>Codecov_Action: informational_status_checks
Loading

File-Level Changes

Change Details Files
Integrate Codecov upload into the PR GitHub Actions workflow using OIDC and replace the previous artifact upload step.
  • Grant id-token: write permission at the job level to allow OIDC token exchange for Codecov
  • Replace the coverage upload step from actions/upload-artifact@v7 to codecov/codecov-action@v5, guarded by the existing matrix.java == env.MAIN_JAVA_VER condition
  • Configure the Codecov action with OIDC authentication, unit-tests flag, JaCoCo XML report path, repository slug, and non-failing behavior on upload errors
.github/workflows/pr.yml
Add a Codecov configuration file to control comment behavior, coverage status checks, flags, and ignored paths.
  • Set Codecov to not require CI to pass before processing and configure PR comments layout and requirements
  • Mark both project and patch coverage statuses as informational so they do not block merges
  • Define a unit-tests flag scoped to src/main/java/ with carryforward enabled for missing reports
  • Configure ignore patterns for test sources, resources, build output, and documentation directories
codecov.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/pr.yml" line_range="77" />
<code_context>
+        use_oidc: true
+        flags: unit-tests
+        files: ./target/site/jacoco/jacoco.xml
+        slug: guacsec/trustify-da-java-client
+        fail_ci_if_error: false
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Hard-coding the Codecov `slug` can cause issues on forks or repo renames; consider relying on Codecov’s auto-detection.

With OIDC enabled, Codecov can derive the repo from `GITHUB_REPOSITORY`. Keeping `slug: guacsec/trustify-da-java-client` hard-coded risks mis-attribution or failures for forks or after org/repo renames. Unless you intentionally need cross-repo uploads, it’s safer to omit `slug` and rely on auto-detection.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/pr.yml
@ptomanRH ptomanRH requested a review from ruromero June 2, 2026 12:06
@ptomanRH ptomanRH self-assigned this Jun 2, 2026
@codecov-commenter
Copy link
Copy Markdown

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 ☂️

- Add Codecov upload step with OIDC auth and unit-tests flag
- Add permissions: id-token: write for OIDC token
- Add codecov.yml with informational status checks and carryforward
- Scope coverage to hand-written source via existing JaCoCo config

Ref: COVERPORT-253

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ptomanRH ptomanRH force-pushed the codecov-onboarding branch from b82f5ac to dd7335f Compare June 3, 2026 10:58
Copy link
Copy Markdown
Collaborator

@ruromero ruromero left a comment

Choose a reason for hiding this comment

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

same changes as for the other PRs

Comment thread .github/workflows/pr.yml
Comment thread codecov.yml
informational: true

flags:
unit-tests:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
unit-tests:
integration-tests:

Copy link
Copy Markdown
Collaborator

@ruromero ruromero left a comment

Choose a reason for hiding this comment

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

I only added comments it was supposed to be a "Request changes"

  • Remove the slug
  • rename to integration-tests

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.

3 participants