Skip to content

Add codecov config#4568

Open
Zeta201 wants to merge 1 commit intowso2:4.12.xfrom
Zeta201:add-codecov
Open

Add codecov config#4568
Zeta201 wants to merge 1 commit intowso2:4.12.xfrom
Zeta201:add-codecov

Conversation

@Zeta201
Copy link
Copy Markdown

@Zeta201 Zeta201 commented Apr 6, 2026

Purpose

This PR integrates Codecov with JaCoCo to enable automated code coverage tracking on pull requests and scheduled checks.

Summary

  • Integrate Codecov into the PR builder workflow to track unit test coverage on every pull request.
  • Configure JaCoCo (v0.8.12) in the root pom.xml to instrument tests and generate XML reports.
  • Add codecov.yml to define coverage rules — patch coverage target of 80% for the unit flag with carryforward enabled.
  • Add a coverage-generator.yml workflow for scheduled (daily) upload of OIDC conformance, FAPI conformance, and integration test coverage reports from product-is runs.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

Add code coverage reporting infrastructure by introducing a new workflow that collects JaCoCo reports from OIDC conformance, FAPI conformance, and integration tests, uploads them to Codecov, and modifies the PR builder workflow with a new Codecov configuration file.

Changes

Cohort / File(s) Summary
CI/CD Workflow Enhancements
.github/workflows/coverage-generator.yml, .github/workflows/pr-builder.yml
New coverage-generator workflow runs daily and on manual dispatch to aggregate JaCoCo reports from multiple test suites (OIDC conformance, FAPI conformance, integration tests) via GitHub API and Jenkins; uploads reports to Codecov with distinct flags. PR builder workflow enhanced with SNAPSHOT artifact cleanup and JaCoCo coverage upload steps.
Codecov Configuration
codecov.yml
New Codecov configuration file establishes CI gating requirements, notification behavior, and coverage status reporting rules. Configures a unit flag with project-level auto-target and patch-level checks requiring 80% coverage with 40% threshold.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is partially complete with Purpose and Summary sections filled in, but most required sections lack substantive content or remain as template placeholders. Complete the following sections: Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests details, Security checks (all three items), Samples, Related PRs, Migrations, Test environment, and Learning. Provide substantive answers rather than leaving template placeholders.
Title check ❓ Inconclusive The title 'Add codecov config' is vague and doesn't clearly convey the main changes: adding coverage workflows and configuration for Codecov integration. Consider a more descriptive title like 'Add Codecov configuration and coverage reporting workflows' to better reflect the scope of changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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: 4

🧹 Nitpick comments (1)
.github/workflows/coverage-generator.yml (1)

10-31: Replace workspace cache pattern with upload-artifact/download-artifact for job handoff.

The report jobs only download external jacoco.xml files and upload them to Codecov—they don't use the built source code. Using actions/cache with path: . creates unnecessary overhead: the build dependency, large cache storage, and cache restoration steps add complexity without providing value. Use actions/upload-artifact in build-source to save artifacts, and actions/download-artifact in the report jobs if needed, or remove the dependency entirely since these jobs only fetch external coverage files.

This pattern repeats at lines 38-44, 98-104, and 158-164.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/coverage-generator.yml around lines 10 - 31, The workflow
currently uses an actions/cache step with path: . inside the build-source job
which unnecessarily caches the whole repository; replace that actions/cache
usage with actions/upload-artifact from the build-source job (e.g., upload an
artifact named like "source-artifact" or skip entirely if downstream report jobs
don't need source), and update any report jobs that currently rely on that cache
to either remove the dependency or use actions/download-artifact to retrieve the
uploaded artifact; specifically modify the build-source job's step that
references actions/cache to use actions/upload-artifact (or delete it) and
update the corresponding report job steps that mirror this pattern (the repeated
occurrences of actions/cache in other jobs) to use actions/download-artifact or
be removed if not needed.
🤖 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/coverage-generator.yml:
- Line 73: Replace the deprecated echo "::set-output
name=artifact-url::$ARTIFACT_URL" usage with the new $GITHUB_OUTPUT method:
instead of using ::set-output, append "artifact-url=$ARTIFACT_URL" to the file
referenced by $GITHUB_OUTPUT (same change for the other occurrence around the
second set-output), ensuring the variable name matches "artifact-url" so
downstream steps read it the same way; update both occurrences in the workflow
where ::set-output is used.
- Around line 46-56: Update the GitHub API queries and Jenkins artifact lookup
to pin artifacts to the branch being reported: in the job step named "Get the
latest Jacoco report URL" (id: get-artifact-url-oidc) and the other GitHub API
call used later (the second workflow run fetch), append the head_branch query
parameter (e.g., &head_branch=main or the appropriate branch variable) to the
runs API URL so the call only returns runs for that branch; for the Jenkins
artifact fetch that currently uses lastSuccessfulBuild, replace it with a
branch-specific build endpoint (or parameterize the job name/build selector for
the target branch) so artifacts are obtained from the exact branch instead of
the last successful build across branches.
- Around line 3-7: The scheduled cron trigger (the schedule: and cron: '00 22 *
* *' entries) will only run on the repository's default branch (master), so
either move this workflow file to the default branch or remove the schedule
block from this branch; update the workflow by deleting the schedule: section
(and its cron entry) if you intend to keep it in the 4.12.x branch, or relocate
the entire workflow file to master so the cron will execute.

In @.github/workflows/pr-builder.yml:
- Around line 48-53: The Codecov upload step ("Upload coverage reports to
Codecov") using codecov/codecov-action@v4 currently relies on the files input
but still auto-discovers other JaCoCo reports; add the input disable_search:
true to that action invocation to force upload only of the specified files
pattern ("**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml") and
prevent merging other reports into the unit flag.

---

Nitpick comments:
In @.github/workflows/coverage-generator.yml:
- Around line 10-31: The workflow currently uses an actions/cache step with
path: . inside the build-source job which unnecessarily caches the whole
repository; replace that actions/cache usage with actions/upload-artifact from
the build-source job (e.g., upload an artifact named like "source-artifact" or
skip entirely if downstream report jobs don't need source), and update any
report jobs that currently rely on that cache to either remove the dependency or
use actions/download-artifact to retrieve the uploaded artifact; specifically
modify the build-source job's step that references actions/cache to use
actions/upload-artifact (or delete it) and update the corresponding report job
steps that mirror this pattern (the repeated occurrences of actions/cache in
other jobs) to use actions/download-artifact or be removed if not needed.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 8149e444-2b92-4f3b-8492-470c60c15c55

📥 Commits

Reviewing files that changed from the base of the PR and between 2f0962d and 4ae8a94.

📒 Files selected for processing (3)
  • .github/workflows/coverage-generator.yml
  • .github/workflows/pr-builder.yml
  • codecov.yml

Comment on lines +3 to +7
on:
workflow_dispatch:
schedule:
# Daily 22:00 UTC (3.30 AM SL time).
- cron: '00 22 * * *'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
curl -s "https://api.github.com/repos/wso2/carbon-kernel" | jq -r '.default_branch'

Repository: wso2/carbon-kernel

Length of output: 66


🏁 Script executed:

#!/bin/bash
# Get full API response to diagnose the null result
curl -s "https://api.github.com/repos/wso2/carbon-kernel" | head -100

Repository: wso2/carbon-kernel

Length of output: 341


🏁 Script executed:

#!/bin/bash
# Check if the repository exists by testing different API endpoints
curl -s -w "\nHTTP Status: %{http_code}\n" "https://api.github.com/repos/wso2/carbon-kernel" | head -50

Repository: wso2/carbon-kernel

Length of output: 359


🏁 Script executed:

#!/bin/bash
# Try alternative approach: check git remote if this is a cloned repo
# and look for any branch/default-branch related files
git ls-files | grep -E "(branch|default)" || echo "No branch-related files found"
git config --get-all | grep -i branch || echo "No git config branch settings"

Repository: wso2/carbon-kernel

Length of output: 2541


🏁 Script executed:

#!/bin/bash
# Check current git branch
git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD || echo "Unable to determine branch"

Repository: wso2/carbon-kernel

Length of output: 66


🏁 Script executed:

#!/bin/bash
# Check git remote URL and look for any branch/PR information
git remote -v
echo "---"
git branch -a | head -20

Repository: wso2/carbon-kernel

Length of output: 294


🏁 Script executed:

#!/bin/bash
# Check if there are any other workflow files that might hint at branch strategy
find .github/workflows -name "*.yml" -o -name "*.yaml" | head -10 | xargs grep -l "branches:" 2>/dev/null || echo "No branch filters found in workflows"

Repository: wso2/carbon-kernel

Length of output: 94


Scheduled workflows only run on the default branch (master).

If this change is intended for the 4.12.x branch, the cron trigger on line 7 will never execute. Move this workflow to the default branch or remove the schedule trigger from non-default branches.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/coverage-generator.yml around lines 3 - 7, The scheduled
cron trigger (the schedule: and cron: '00 22 * * *' entries) will only run on
the repository's default branch (master), so either move this workflow file to
the default branch or remove the schedule block from this branch; update the
workflow by deleting the schedule: section (and its cron entry) if you intend to
keep it in the 4.12.x branch, or relocate the entire workflow file to master so
the cron will execute.

Comment on lines +46 to +56
- name: Get the latest Jacoco report URL
id: get-artifact-url-oidc
run: |
GITHUB_API_URL="https://api.github.com"
OWNER="wso2"
REPO="product-is"
WORKFLOW_ID="oidc-conformance-test.yml"
GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}"

# Get the latest successful workflow run
WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs?status=success&per_page=1")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
curl -s "https://api.github.com/repos/wso2/product-is/actions/workflows/oidc-conformance-test.yml/runs?status=success&per_page=5" \
  | jq -r '.workflow_runs[] | [.id, .head_branch, .head_sha, .created_at] | `@tsv`'

curl -s "https://api.github.com/repos/wso2/product-is/actions/workflows/fapi-oidc-conformance-test.yml/runs?status=success&per_page=5" \
  | jq -r '.workflow_runs[] | [.id, .head_branch, .head_sha, .created_at] | `@tsv`'

Repository: wso2/carbon-kernel

Length of output: 541


🏁 Script executed:

cat -n .github/workflows/coverage-generator.yml | head -180

Repository: wso2/carbon-kernel

Length of output: 7172


Pin external coverage artifacts to the branch being reported.

The GitHub API calls at lines 56 and 116 fetch the latest successful workflow run across all branches, and line 169 uses Jenkins lastSuccessfulBuild without branch restriction. This means coverage artifacts from a different branch or commit than the sources Codecov is indexing can be published together.

To fix, add branch filtering to the GitHub API queries:

  • Line 56: Add &head_branch=main (or appropriate branch name) to the API query
  • Line 116: Add &head_branch=main to the API query
  • Line 169: Specify a branch-specific Jenkins build URL instead of lastSuccessfulBuild
🧰 Tools
🪛 actionlint (1.7.12)

[error] 48-48: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/coverage-generator.yml around lines 46 - 56, Update the
GitHub API queries and Jenkins artifact lookup to pin artifacts to the branch
being reported: in the job step named "Get the latest Jacoco report URL" (id:
get-artifact-url-oidc) and the other GitHub API call used later (the second
workflow run fetch), append the head_branch query parameter (e.g.,
&head_branch=main or the appropriate branch variable) to the runs API URL so the
call only returns runs for that branch; for the Jenkins artifact fetch that
currently uses lastSuccessfulBuild, replace it with a branch-specific build
endpoint (or parameterize the job name/build selector for the target branch) so
artifacts are obtained from the exact branch instead of the last successful
build across branches.

exit 1
fi

echo "::set-output name=artifact-url::$ARTIFACT_URL"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n '::set-output' .github/workflows

Repository: wso2/carbon-kernel

Length of output: 276


🏁 Script executed:

cat -n .github/workflows/coverage-generator.yml | sed -n '65,80p'

Repository: wso2/carbon-kernel

Length of output: 851


🏁 Script executed:

cat -n .github/workflows/coverage-generator.yml | sed -n '125,140p'

Repository: wso2/carbon-kernel

Length of output: 855


Replace deprecated ::set-output with $GITHUB_OUTPUT environment variable.

Lines 73 and 133 use the deprecated ::set-output syntax which has been replaced by GitHub Actions. Migrate to the $GITHUB_OUTPUT environment variable to ensure long-term compatibility.

Proposed fix
-          echo "::set-output name=artifact-url::$ARTIFACT_URL"
+          echo "artifact-url=$ARTIFACT_URL" >> "$GITHUB_OUTPUT"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "::set-output name=artifact-url::$ARTIFACT_URL"
echo "artifact-url=$ARTIFACT_URL" >> "$GITHUB_OUTPUT"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/coverage-generator.yml at line 73, Replace the deprecated
echo "::set-output name=artifact-url::$ARTIFACT_URL" usage with the new
$GITHUB_OUTPUT method: instead of using ::set-output, append
"artifact-url=$ARTIFACT_URL" to the file referenced by $GITHUB_OUTPUT (same
change for the other occurrence around the second set-output), ensuring the
variable name matches "artifact-url" so downstream steps read it the same way;
update both occurrences in the workflow where ::set-output is used.

Comment on lines +48 to +53
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml"
flags: unit
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does codecov/codecov-action@v4 still auto-discover coverage files when the filesinput is set, and isdisable_search: true required to limit the upload to only the provided JaCoCo XML file(s)?

💡 Result:

No, codecov/codecov-action@v4 does not stop auto-discovering coverage files when the files input is set; the specified files are added to those found by the default search. Yes, disable_search: true is required to limit the upload to only the provided JaCoCo XML file(s), disabling the automatic search.

Citations:


Add disable_search: true to restrict Codecov upload to the specified file only.

The codecov/codecov-action@v4 automatically discovers coverage files regardless of the files input. Without disable_search: true, this step will merge any other JaCoCo reports from the Maven build into the unit flag, defeating the purpose of uploading only the aggregate report on line 52.

Proposed fix
       - name: Upload coverage reports to Codecov
         uses: codecov/codecov-action@v4
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: "**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml"
           flags: unit
+          disable_search: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml"
flags: unit
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml"
flags: unit
disable_search: true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-builder.yml around lines 48 - 53, The Codecov upload
step ("Upload coverage reports to Codecov") using codecov/codecov-action@v4
currently relies on the files input but still auto-discovers other JaCoCo
reports; add the input disable_search: true to that action invocation to force
upload only of the specified files pattern
("**/target/coverage-reports/site/jacoco-aggregate/jacoco.xml") and prevent
merging other reports into the unit flag.

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

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