Skip to content

ci: connect features folder to SonarCloud coverage#14908

Merged
lewisd5 merged 1 commit intodevelopfrom
chore/connect-features-sonarcloud
Mar 3, 2026
Merged

ci: connect features folder to SonarCloud coverage#14908
lewisd5 merged 1 commit intodevelopfrom
chore/connect-features-sonarcloud

Conversation

@mcayuelas-ledger
Copy link
Contributor

@mcayuelas-ledger mcayuelas-ledger commented Mar 2, 2026

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests. CI/infrastructure changes — verified locally that jest-sonar generates the expected sonar-executionTests-report.xml and lcov.info files.
  • Impact of the changes:
    • SonarCloud coverage reporting for the features/ folder
    • CI workflows: new test-features job in PR pipeline
    • Scheduled SonarCloud scan now includes features coverage

📝 Description

The features/ folder at the root of the monorepo was not connected to SonarCloud. Code in features/market-banner (and any future feature packages) was invisible to coverage analysis and quality gates.

This PR wires the features/ folder into the SonarCloud pipeline by:

  • Adding features to sonar.sources and sonar.typescript.tsconfigPaths in sonar-project.properties
  • Adding jest-sonar reporter to features/market-banner/jest.config.js to generate sonar-executionTests-report.xml
  • Creating a new reusable CI workflow test-features-reusable.yml (following the same pattern as test-libs-reusable.yml)
  • Wiring the new test-features job into the PR workflow (build-and-test-pr.yml), the sonar scan reusable workflow (scan-sonar-reusable.yml), and the scheduled scan (sonar.yml)

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@live-github-bot live-github-bot bot added the automation CI/CD stuff label Mar 2, 2026
@mcayuelas-ledger mcayuelas-ledger marked this pull request as ready for review March 2, 2026 10:23
@mcayuelas-ledger mcayuelas-ledger requested a review from a team as a code owner March 2, 2026 10:23
Copilot AI review requested due to automatic review settings March 2, 2026 10:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

❌ Action Required: Monitored Files Changed

The following files in monitored folders have been modified:

  • .github/workflows/build-and-test-pr.yml
  • .github/workflows/scan-sonar-reusable.yml
  • .github/workflows/sonar.yml
  • .github/workflows/test-features-reusable.yml

Action Required: Please rebase your branch against develop to ensure consistency:

git rebase origin/develop

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

Connects the root-level features/ workspace packages to the existing SonarCloud coverage + test execution reporting pipeline, aligning them with how apps/ and libs/ are already handled.

Changes:

  • Extend Sonar configuration to include features/ sources and TS config paths.
  • Add jest-sonar reporting for @features/market-banner and aggregate feature coverage artifacts in CI.
  • Introduce and wire a new reusable workflow/job (test-features) into PR and scheduled Sonar scan flows.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sonar-project.properties Adds features/ to Sonar sources, test exclusions, and TS config discovery.
features/market-banner/jest.config.js Generates Sonar test execution XML via jest-sonar.
.github/workflows/test-features-reusable.yml New reusable workflow to run feature coverage and upload aggregated artifacts.
.github/workflows/sonar.yml Scheduled scan now installs feature deps and merges feature coverage into the scan inputs.
.github/workflows/scan-sonar-reusable.yml Optionally downloads/merges features coverage artifacts for PR sonar scans.
.github/workflows/build-and-test-pr.yml Adds test-features job and feeds its coverage into the Sonar scan workflow.
.changeset/wild-moose-buy.md Adds a changeset entry related to the features Sonar coverage wiring.

description: |
If you run this manually, and want to run on a PR, the correct ref should be refs/pull/{PR_NUMBER}/merge to
have the "normal" scenario involving checking out a merge commit between your branch and the base branch.
If you want to run only on a branch or specific commit, you can use either the sha or the branch name instead (prefer the first verion for PRs).
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

Typo in the workflow_dispatch ref input description: “verion” should be “version” (helps avoid copying this typo into other workflow files).

Suggested change
If you want to run only on a branch or specific commit, you can use either the sha or the branch name instead (prefer the first verion for PRs).
If you want to run only on a branch or specific commit, you can use either the sha or the branch name instead (prefer the first version for PRs).

Copilot uses AI. Check for mistakes.
LucasWerey
LucasWerey previously approved these changes Mar 2, 2026
@mcayuelas-ledger mcayuelas-ledger force-pushed the chore/connect-features-sonarcloud branch from b6f4cf4 to ea1388a Compare March 3, 2026 10:21
Copilot AI review requested due to automatic review settings March 3, 2026 13:02
@mcayuelas-ledger mcayuelas-ledger force-pushed the chore/connect-features-sonarcloud branch from ea1388a to 7e244cd Compare March 3, 2026 13:02
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment on lines +98 to +102
if [ -d ./coverage-features ]; then
echo "Merging features coverage files"
cat ./coverage-features/lcov.info >> ./lcov.info
cat ./coverage-features/sonar-executionTests-report.xml >> ./sonar-executionTests-report.xml
fi
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

In the Sonar scan reusable workflow, the merge step appends the features sonar-executionTests-report.xml into a single file via cat >>. If that XML file already contains its own <testExecutions> root (common for Jest Sonar reporters), appending multiple reports will make the combined file non-well-formed XML and may break Sonar test execution import. Consider switching to a merge strategy that preserves a single root element, or pass multiple report paths to Sonar.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +52
test-features:
name: "Test Features"
uses: LedgerHQ/ledger-live/.github/workflows/test-features-reusable.yml@develop
secrets: inherit

Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

This workflow adds a test-features job, but the final ok job (used as the single required check) does not include test-features in its needs. That means the required OK check can succeed even if test-features fails, and it may also complete before test-features finishes. Add test-features to the ok.needs list (and ensure failures are reflected).

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +72
mkdir -p ${{ github.workspace }}/coverage
touch ${{ github.workspace }}/coverage/lcov.info
touch ${{ github.workspace }}/coverage/sonar-executionTests-report.xml

pnpm turbo run coverage --api="http://127.0.0.1:${{ steps.setup-caches.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" --filter="./features/**" --concurrency=4 -- --runInBand=1

- name: Process coverage files
id: process-coverage
run: |
for package_json in $(find ./features -name "package.json" -not -path "*/node_modules/*"); do
pkg=$(dirname "$package_json")
echo "Processing feature at path: $pkg"
if [ -f "$package_json" ] && jq -e '.scripts.coverage' "$package_json" > /dev/null 2>&1; then
if [ -f "$pkg/coverage/lcov.info" ] && [ -f "$pkg/coverage/sonar-executionTests-report.xml" ]; then
echo "Appending coverage files for $pkg"
cat "$pkg/coverage/lcov.info" >> ${{ github.workspace }}/coverage/lcov.info
cat "$pkg/coverage/sonar-executionTests-report.xml" >> ${{ github.workspace }}/coverage/sonar-executionTests-report.xml
fi
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The feature coverage aggregation builds sonar-executionTests-report.xml by concatenating per-package XML files. If more than one feature package produces a Jest Sonar report, this will typically result in an invalid XML document (multiple <testExecutions> roots), which can break Sonar test execution parsing. Consider merging only the inner <file> nodes under a single root, or avoid merging and instead pass multiple report paths to Sonar.

Copilot uses AI. Check for mistakes.
Comment on lines +86 to +107
- name: Generate Unit test coverage for features
run: |
mkdir -p features/coverage
touch features/coverage/lcov.info
touch features/coverage/sonar-executionTests-report.xml

pnpm turbo run coverage --filter="./features/**" --concurrency=4 -- --runInBand=1

for package_json in $(find ./features -name "package.json" -not -path "*/node_modules/*"); do
pkg=$(dirname "$package_json")
echo "Processing feature at path: $pkg"

if [ -f "$package_json" ] && jq -e '.scripts.coverage' "$package_json" > /dev/null 2>&1; then
if [ -f "$pkg/coverage/lcov.info" ] && [ -f "$pkg/coverage/sonar-executionTests-report.xml" ]; then
echo "Appending coverage files for $pkg"
cat "$pkg/coverage/lcov.info" >> features/coverage/lcov.info
cat "$pkg/coverage/sonar-executionTests-report.xml" >> features/coverage/sonar-executionTests-report.xml
fi
else
echo "No coverage script found for $pkg, skipping."
fi
done
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

This scheduled Sonar workflow aggregates features/**/coverage/sonar-executionTests-report.xml by concatenating XML files. Once multiple feature packages exist, this can produce an invalid XML document (multiple <testExecutions> roots) and make the Sonar scan fail to parse unit test execution. Prefer merging XML properly (single root + combined <file> elements) or configuring Sonar to read multiple report files rather than concatenating.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 3, 2026 13:09
@mcayuelas-ledger mcayuelas-ledger force-pushed the chore/connect-features-sonarcloud branch from 6a20cfc to b4cc7b3 Compare March 3, 2026 13:09
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

⚠️ E2E tests are required

Changes detected require e2e testing before merge (even before asking for any review).

🖥️ Desktop

-> Run Desktop E2E

  • Select "Run workflow"
  • Branch: chore/connect-features-sonarcloud
  • Device: nanoSP or stax

📱 Mobile

-> Run Mobile E2E

  • Select "Run workflow"
  • Branch: chore/connect-features-sonarcloud
  • Device: nanoX

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

name: "Test Features"
needs: determine-affected
if: ${{contains(needs.determine-affected.outputs.paths, 'features') && !github.event.pull_request.head.repo.fork}}
uses: LedgerHQ/ledger-live/.github/workflows/test-features-reusable.yml@chore/connect-features-sonarcloud
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The new test-features job calls a reusable workflow at LedgerHQ/ledger-live/.github/workflows/test-features-reusable.yml@develop, but that workflow file is introduced by this PR (so it won’t exist on the develop ref until after merge). This will cause the PR workflow to fail when GitHub Actions tries to resolve the reusable workflow. Consider either splitting this into two PRs (add reusable workflow first, then wire it in), or referencing a ref that includes this change (e.g., a pinned commit SHA or an in-repo reference if supported).

Suggested change
uses: LedgerHQ/ledger-live/.github/workflows/test-features-reusable.yml@chore/connect-features-sonarcloud
uses: ./.github/workflows/test-features-reusable.yml

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

@lewisd5 lewisd5 force-pushed the chore/connect-features-sonarcloud branch from 5686e3c to b4cc7b3 Compare March 3, 2026 13:37
@lewisd5 lewisd5 merged commit 1a90cfc into develop Mar 3, 2026
63 of 67 checks passed
@lewisd5 lewisd5 deleted the chore/connect-features-sonarcloud branch March 3, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants