Skip to content

Add Codecov coverage reporting#7

Merged
leppa merged 1 commit intodevfrom
codecov
Mar 28, 2026
Merged

Add Codecov coverage reporting#7
leppa merged 1 commit intodevfrom
codecov

Conversation

@leppa
Copy link
Copy Markdown
Owner

@leppa leppa commented Mar 27, 2026

Description

  • Add a step to upload Codecov reports to the "Build and Test" workflow.
  • Change the default Jest config to only enable lcov and text coverage reporters.
  • Introduce test:ci script with CI-specific Jest config:
    • use the summary reporter instead of the default one;
    • add the github-actions reporter;
    • add the jest-junit reporter with Codecov recommended config;
    • only enable lcov and text-summary coverage reporters.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • New format plugin (adds support for a new CSV format)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Test improvements
  • Chore (project maintenance, build configuration, etc.)
  • Other (please describe):

Checklist

  • I have read the Code of Conduct and agree to abide by it
  • I agree that my contributions will be licensed under the BSD 3-Clause License
  • My code follows the project's coding style and conventions
  • I have added JSDoc documentation for any new functions, classes, or methods
  • I have updated relevant documentation (README, ChangeLog, docs/, etc.)
  • I have written tests for my changes
  • All new code has adequate test coverage
  • All existing tests pass locally
  • My commits have clear and descriptive commit messages
  • My commits are atomic, i.e. complete and self-contained units of change (else, meld the commits before submitting the PR)

By submitting this pull request, I confirm that I have read and understood the contribution guidelines and that my contributions are my own work.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Codecov integration with coverage badge in README
    • Implemented component-level coverage tracking for improved quality insights
    • Enhanced CI test reporting with dedicated test results handling
  • Chores

    • Restructured test artifact output from coverage reports to test results
    • Updated workflow outputs for improved build artifact management
    • Modified ignore files to reflect test-results directory changes

Walkthrough

Renames workflow step IDs/outputs to kebab-case, switches CI test command to test:ci, adds Codecov uploads and codecov.yml, redirects coverage/test artifacts to test-results/, introduces CI-specific Jest config with junit reporter, adds test:ci script and jest-junit devDependency, and updates README and .npmignore.

Changes

Cohort / File(s) Summary
GitHub Actions (build & publish)
.github/workflows/build-and-test.yml
Renamed step create_npm_packagecreate-npm-package and output package_filepackage-file; added outputs tests-ran and tests-passed; replaced test step with npm run -s test:ci (id: run-tests); changed artifact upload to test-results.zip and made upload run on non-cancelled job; added upload-test-results-to-codecov job using OIDC.
SonarQube workflow
.github/workflows/sonarqube-analysis.yml
Changed artifact download from coverage-report.ziptest-results.zip and target path to test-results/.
Jest & CI reporters
jest.config.ci.js, jest.config.js, package.json
Added jest.config.ci.js extending base config with CI reporters (summary, github-actions, jest-junit) and lcov/text-summary coverage reporters; set coverageDirectory to test-results and explicit coverageReporters in jest.config.js; added test:ci npm script and jest-junit devDependency.
Codecov config & README
codecov.yml, README.md
Added codecov.yml with component mappings and coverage thresholds; added Codecov badge and links in README.
Packaging & ignore rules
.npmignore, .gitignore, sonar-project.properties
Added codecov.yml to .npmignore; replaced ignores for coverage/ with test-results/ in .npmignore and .gitignore; updated SonarQube LCOV path to ./test-results/lcov.info.

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions"
  participant Runner as "CI Runner"
  participant Jest as "Jest (CI config)"
  participant Artifact as "Actions Artifact Service"
  participant Publish as "Publish Job"
  participant Codecov as "Codecov"

  GH->>Runner: start build-and-test job
  Runner->>Jest: run `npm run -s test:ci`
  Jest-->>Runner: emit coverage (test-results/lcov.info) and junit XML
  Runner->>Artifact: upload `test-results.zip` (if not cancelled)
  Runner->>Runner: create npm package -> output `package-file`
  Runner-->>GH: set job outputs (`package-file`, `tests-ran`, `tests-passed`)
  GH->>Publish: downstream reads `needs.build-and-test.outputs.package-file`
  GH->>Codecov: download `test-results.zip` (upload test results always if not cancelled)
  GH->>Codecov: upload coverage (only if `tests-passed`) (use_oidc: true)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add Codecov coverage reporting' directly aligns with the primary objective of adding Codecov integration to the CI/CD workflows and Jest configuration.
Description check ✅ Passed The description clearly outlines the changes being made: adding Codecov step, updating Jest config, and introducing test:ci script, all of which match the actual changeset.
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.


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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 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 ☂️

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 852a6a99-d4d5-4b8d-8106-0e9e8b4af039

📥 Commits

Reviewing files that changed from the base of the PR and between a32d70f and 89058c8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .github/workflows/build-and-test.yml
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json

Comment thread .github/workflows/build-and-test.yml Outdated
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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1bb2b54b-c4d7-4920-952d-5146517f1d2c

📥 Commits

Reviewing files that changed from the base of the PR and between 89058c8 and 5ae308e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .github/workflows/build-and-test.yml
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json
✅ Files skipped from review due to trivial changes (4)
  • .npmignore
  • jest.config.js
  • codecov.yml
  • jest.config.ci.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • package.json

Comment thread .github/workflows/build-and-test.yml
Comment thread .github/workflows/build-and-test.yml Outdated
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.

🧹 Nitpick comments (1)
.github/workflows/build-and-test.yml (1)

78-90: Specify coverage and test result file paths explicitly for Codecov uploads.

The Codecov action steps rely on file discovery. Since the CI configuration writes fixed outputs, passing explicit files parameters would make uploads deterministic and prevent silent no-ops if the pinned action version does not discover these files.

Suggested change
      - name: Upload coverage report to Codecov
        #     codecov/codecov-action@v6.0.0
        uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
        with:
+          files: coverage/lcov.info
           use_oidc: true

      - name: Upload test results to Codecov
         if: ${{ !cancelled() }}
         #     codecov/codecov-action@v6.0.0
         uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
         with:
+          files: coverage/junit.xml
           use_oidc: true
           report_type: test_results

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c63a1b79-662b-42d8-a965-a48952ef68de

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae308e and 8dd4642.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .github/workflows/build-and-test.yml
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json
✅ Files skipped from review due to trivial changes (5)
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.js
  • jest.config.ci.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

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

♻️ Duplicate comments (1)
.github/workflows/build-and-test.yml (1)

66-73: ⚠️ Potential issue | 🟠 Major

Propagate run-tests state through the new artifact/Codecov flow.

Line 68 only uploads test-results/ when run-tests itself failed, while Line 139 starts the downstream job on any non-cancelled build-and-test failure. That combination creates three bad paths: post-test failures skip the artifact even though the reports exist, pre-test failures turn download-artifact into a second job failure, and Line 152 uploads coverage after failed tests.

Use steps.run-tests.outcome for the artifact step, export explicit tests-ran / tests-passed outputs from build-and-test, gate the downstream job on tests-ran, and gate Line 152 on tests-passed.

One way to wire the states explicitly
     outputs:
       package-file: ${{ steps.create-npm-package.outputs.package-file }}
+      tests-ran: ${{ steps.run-tests.outcome == 'success' || steps.run-tests.outcome == 'failure' }}
+      tests-passed: ${{ steps.run-tests.outcome == 'success' }}
@@
       - name: Upload tests results artifact
-        if: ${{ success() || (failure() && steps.run-tests.outcome == 'failure') }}
+        if: ${{ !cancelled() && (steps.run-tests.outcome == 'success' || steps.run-tests.outcome == 'failure') }}
         uses: actions/upload-artifact@v7
@@
   upload-test-results-to-codecov:
-    if: ${{ !cancelled() }}
+    if: ${{ !cancelled() && needs.build-and-test.outputs.tests-ran == 'true' }}
@@
       - name: Upload coverage report to Codecov
+        if: ${{ needs.build-and-test.outputs.tests-passed == 'true' }}
         #     codecov/codecov-action@v6.0.0
         uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2

Based on learnings: Codecov coverage uploads in this repo should stay success-only; only the report_type: test_results upload should run under !cancelled().

Also applies to: 134-164


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d50e22b4-94f3-4c9a-89fc-820a31453abd

📥 Commits

Reviewing files that changed from the base of the PR and between 8dd4642 and db31033.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • .github/workflows/build-and-test.yml
  • .github/workflows/sonarqube-analysis.yml
  • .gitignore
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json
  • sonar-project.properties
✅ Files skipped from review due to trivial changes (5)
  • sonar-project.properties
  • .gitignore
  • README.md
  • .npmignore
  • codecov.yml
🚧 Files skipped from review as they are similar to previous changes (3)
  • jest.config.js
  • jest.config.ci.js
  • package.json

Comment thread .github/workflows/build-and-test.yml Outdated
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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d04ea937-9ebd-405c-81b1-398a8bb7e874

📥 Commits

Reviewing files that changed from the base of the PR and between db31033 and 9397f64.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • .github/workflows/build-and-test.yml
  • .github/workflows/sonarqube-analysis.yml
  • .gitignore
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json
  • sonar-project.properties
✅ Files skipped from review due to trivial changes (7)
  • .gitignore
  • sonar-project.properties
  • .npmignore
  • jest.config.js
  • README.md
  • codecov.yml
  • jest.config.ci.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/sonarqube-analysis.yml
  • package.json

Comment thread .github/workflows/build-and-test.yml
- Try to upload test results artifact even when "Run tests" step fails.
- Add a job to upload Codecov reports to the "Build and Test" workflow.
- Change the default Jest config to enable only `lcov` and `text`
  coverage reporters.
- Change the default Jest config to store output in the `test-results`
  folder instead of the `coverage` one.
- Introduce `test:ci` script with CI-specific Jest config:
  - use the `summary` reporter instead of the `default` one;
  - add the `github-actions` reporter;
  - add the `jest-junit` reporter with Codecov recommended config;
  - enable only `lcov` and `text-summary` coverage reporters.
@sonarqubecloud
Copy link
Copy Markdown

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.

🧹 Nitpick comments (1)
.github/workflows/build-and-test.yml (1)

156-170: Consider specifying explicit files paths for clarity and reliability.

While Codecov's auto-discovery should find the coverage and test result files, explicitly specifying paths prevents potential discovery issues and makes the configuration self-documenting.

♻️ Optional: Explicit file paths
       - name: Upload coverage report to Codecov
         # Only upload coverage report when tests pass as it may be incomplete otherwise
         if: ${{ needs.build-and-test.outputs.tests-passed == 'true' }}
         #     codecov/codecov-action@v6.0.0
         uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
         with:
           use_oidc: true
+          files: test-results/lcov.info

       - name: Upload test results to Codecov
         if: ${{ !cancelled() }}
         #     codecov/codecov-action@v6.0.0
         uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
         with:
           use_oidc: true
           report_type: test_results
+          files: test-results/junit.xml

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2431149f-76ce-432c-b1fd-4cbfaf6ed3ae

📥 Commits

Reviewing files that changed from the base of the PR and between db31033 and f39f5ca.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • .github/workflows/build-and-test.yml
  • .github/workflows/sonarqube-analysis.yml
  • .gitignore
  • .npmignore
  • README.md
  • codecov.yml
  • jest.config.ci.js
  • jest.config.js
  • package.json
  • sonar-project.properties
✅ Files skipped from review due to trivial changes (7)
  • .npmignore
  • jest.config.js
  • .gitignore
  • .github/workflows/sonarqube-analysis.yml
  • README.md
  • codecov.yml
  • sonar-project.properties
🚧 Files skipped from review as they are similar to previous changes (1)
  • jest.config.ci.js

@leppa leppa added the chore Chores and maintenance label Mar 28, 2026
@leppa leppa merged commit 1557844 into dev Mar 28, 2026
15 checks passed
@leppa leppa deleted the codecov branch March 28, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Chores and maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant