Skip to content

Fixes #38648: feed browser-test coverage to the nightly SonarCloud scan; follow-ups from #38673 - #38649

Merged
chirag-madlani merged 9 commits into
mainfrom
ci/sonar-browser-coverage
Nov 26, 2026
Merged

chirag-madlani merged 9 commits into
mainfrom
ci/sonar-browser-coverage

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #38648

Describe your changes:

The UI SonarCloud scan read only the Jest lcov. Code covered only by the Vitest browser suite therefore showed as uncovered. This PR adds the browser-test coverage to the scan:

  • .github/workflows/ui-sonarcloud-nightly.yml: after the Jest coverage step, the job installs Chromium and runs yarn test:ui:coverage, the full browser suite of about 1,070 tests. It reuses the job's own Node, ANTLR and yarn install. ./.github/actions/ui-browser-setup would have installed those a second time, so it isn't used. Chromium is installed without --with-deps, which matches ui-browser-setup. The job timeout goes from 90 to 180 minutes.
  • Failure handling: a failing browser test still fails the job and posts to Slack. Vitest is configured with reportOnFailure: true, so the lcov is written anyway. The sonar-scanner install and scan steps now use if: ${{ !cancelled() }}, so that lcov still gets scanned. Before this change, the retry scan step already ran after a Jest failure because of its !cancelled() condition, but the sonar-scanner install had been skipped. Jest failures and browser failures now both lead to a working scan.
  • sonar-project.properties: sonar.typescript.lcov.reportPaths now lists both src/test/unit/coverage/lcov.info and src/test/browser/coverage/lcov.info, and sonar.tests includes src/test/browser. sonar.exclusions already covers src/test/** and src/**/*.test.tsx, so *.browser.test.tsx files are not counted as sources.
  • vitest.browser.config.ts and src/test/browser/README.md now say that the nightly Sonar scan reads this report.

The UI has no PR or merge-queue Sonar scan. The nightly run is the only one, so it is the full-suite baseline and the "PR runs a subset" concern does not apply. This is the OSS half of open-metadata/openmetadata-collate#8350.

Type of change:

  • Improvement

Tests

  • python3 -c "import yaml; yaml.safe_load(...)" on the workflow: parses.
  • actionlint .github/workflows/ui-sonarcloud-nightly.yml: no errors. It reports five SC2086 info notes, and the same five appear on the main version of the file, on lines this PR does not change.
  • yarn test:ui:coverage src/pages/BotsPageV1/BotsPageV1.browser.test.tsx: 1 file and 3 tests passed in 29s. It wrote src/test/browser/coverage/lcov.info (288 KB). Its SF: paths are relative to the UI directory (for example SF:src/queryClient.ts), which is how Sonar resolves them, and no test files are listed.
  • The full browser suite and the Sonar scan were not run locally. The first nightly run after merge, or a workflow_dispatch run, will exercise them.

Jest coverage was never reaching Sonar

test:cov-summary writes only json-summary, so src/test/unit/coverage/lcov.info never existed. The last nightly scan logged No LCOV files were found and No coverage information will be saved, which means SonarCloud has had no UI coverage at all. The nightly now runs yarn test:cov-summary --coverageReporters lcov. I checked locally that Jest writes both reports and that the lcov uses UI-relative paths.

The scan now runs only after a successful yarn install and with both lcov files present (a Check coverage reports step), so a crashed suite skips one night's scan instead of publishing a false coverage drop on main. The rule is recorded in ADR:2026-11-25-ui-sonar-coverage-is-jest-plus-the-browser-suite-from-one-nightly-run.

Browser-test report: job summary only

Following ADR:2026-11-10-pr-jobs-never-receive-credentials ("results appear in annotations, logs, artifacts, and job summaries rather than PR comments"), this removes the PR comment:

  • ui-browser-tests-comment.yml (the workflow_run publisher that posted PR-built markdown with a write token) is deleted.
  • The browser-tests-comment artifacts are gone. The report ("what ran and why", the result, the changed code no test executes) and the "Ran: none" note go to $GITHUB_STEP_SUMMARY only.
  • browser-tests-report.mjs drops the comment marker; its tests pass (12/12).

Follow-ups from Harsh's review of #38673

This PR also carries the points from #38673 (review), which merged before they were addressed:

  • Failed scheduled runs alert someone. A new notify job posts to #pw-health (C0C008ZAK0V) when a scheduled UI Browser Tests run fails. It uses COLLATE_BOT_SLACK_TOKEN, the token the daily Playwright report already posts there with. The job runs only on schedule, so check_pr_workflow_security.py still passes.
  • The map lookup queries each event separately (schedule and workflow_dispatch on main, and merge_group), then takes the newest run that has the artifact. PR runs can no longer push a good map off a 100-run list while main's full run is red.
  • PR runs skip impact. They no longer record impact, upload browser-impact-*, or carry impact-map.json in browser-selection.
  • New decision record: ADR:2026-11-25-browser-tests-are-selected-before-main-and-run-in-full-on-main supersedes ADR:2026-11-23-browser-tests-run-by-impact-on-pull-requests-and-in-full-in-the-merge-queue. The old record is restored to its v1 text and marked superseded. The new one records the two gaps in map freshness: concurrent queue entries overwriting each other's update, and a queue entry that passes but leaves the queue still publishing its map. The next full run fixes both, and neither can hide a test.

Verified: the workflow parses as YAML, check_pr_workflow_security.py passes, and the per-event lookup returns run IDs newest first against the live API.

🤖 Generated with Claude Code

The UI SonarCloud scan runs only nightly and read only Jest's lcov, so code covered only by the Vitest browser suite showed as uncovered. The nightly job now installs Chromium, runs the full browser suite with coverage after Jest, and lists src/test/browser/coverage/lcov.info next to the Jest report in sonar.typescript.lcov.reportPaths (with src/test/browser added to sonar.tests). A failing test suite still fails the job and notifies Slack, but the scan steps run whenever the job was not cancelled, so the report written on failure is still scanned.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chirag-madlani
chirag-madlani requested a review from a team as a code owner November 25, 2026 06:05
@chirag-madlani
chirag-madlani requested review from shah-harshit and a balanced review from Copilot November 25, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

UI browser tests

Ran: all test files (.github/workflows/ui-browser-tests.yml affects every browser test)

Result: ✅ 1072 passed · 154 skipped

chirag-madlani and others added 2 commits November 25, 2026 18:02
…ent; no impact on PRs

Follow-ups from the review of #38673:
- A failed scheduled full run posts to Slack: GitHub only emails whoever
  last edited the schedule, and that run is where a selection miss shows.
- The map lookup queries schedule, workflow_dispatch and merge_group runs
  separately, so PR runs cannot push a good map off the list.
- Pull requests no longer record or upload impact, or carry the map.
- A new decision record supersedes the 2026-11-23 one, whose title said
  the opposite of what we now do, and notes the two map-freshness gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:34
@chirag-madlani chirag-madlani changed the title Fixes #38648: feed the browser-test coverage to the nightly SonarCloud scan Fixes #38648: feed browser-test coverage to the nightly SonarCloud scan; follow-ups from #38673 Nov 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…; record the coverage rule

- test:cov-summary wrote only json-summary, so every nightly scan logged
  "No LCOV files were found" and saved no UI coverage. The nightly now
  asks Jest for lcov as well.
- The scan runs only after a successful dependency install and with both
  the Jest and browser lcov present; otherwise a partial scan would
  publish a false coverage drop on main.
- ADR:2026-11-25-ui-sonar-coverage-is-jest-plus-the-browser-suite-from-one-nightly-run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…rage

# Conflicts:
#	.github/workflows/ui-browser-tests.yml
Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

… comment publisher

PR jobs post no comments (ADR:2026-11-10-pr-jobs-never-receive-credentials):
results belong in annotations, logs, artifacts and job summaries. The
workflow_run publisher posted markdown built by PR code with a write token.
Delete ui-browser-tests-comment.yml and the comment artifacts; both report
steps write to $GITHUB_STEP_SUMMARY.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 3 closed / 3 findings

The UI workflow now uses selected browser tests before main and nightly full runs, so a missed test could let a regression merge before detection.

Feeds Vitest browser-test coverage into the nightly UI SonarCloud scan alongside Jest lcov, moves browser-run reporting to the job summary, and adds Slack alerts for failed scheduled browser runs. Resolved the 0%-coverage publish on setup failure, the unrecorded coverage rule, and the silent pass when an lcov is missing.

✅ 3 closed
✅ Bug: Scan now publishes a 0%-coverage analysis when setup fails

📄 .github/workflows/ui-sonarcloud-nightly.yml:76-89 📄 .github/workflows/ui-sonarcloud-nightly.yml:97-100 📄 .github/workflows/ui-sonarcloud-nightly.yml:103-107 📄 .github/workflows/ui-sonarcloud-nightly.yml:111-124
Before this PR, Install sonar-scanner used the default success() condition. Any earlier failure therefore skipped the scanner install, and the retry scan step could not run. Now every step from Install Chromium onward uses if: ${{ !cancelled() }}. If Install Yarn Packages fails after its three attempts (the step expects registry 5xx errors), the steps keep going: npx playwright install fetches Playwright from the registry, yarn test:ui:coverage fails, the global sonarqube-scanner install still succeeds, and sonar-scanner runs with no lcov file. SonarJS only logs a warning about the missing report, so the main branch analysis on SonarCloud gets uploaded with 0% coverage. That pollutes the baseline and the quality-gate history. A dependency-install failure should block the scan. The goal of !cancelled() is only to keep the scan running after a test failure.

✅ Quality: UI Sonar coverage rule and its failure policy are not recorded

📄 .github/workflows/ui-sonarcloud-nightly.yml:33-34 📄 .github/workflows/ui-sonarcloud-nightly.yml:109-118 📄 openmetadata-ui/src/main/resources/ui/sonar-project.properties:12
This PR sets a policy that other jobs and the Collate half (openmetadata-collate#8350) must follow, but no record in docs/decisions/ states it. 2026-11-10-pr-jobs-never-receive-credentials only says UI Sonar stays nightly. 2026-11-23-browser-tests-run-by-impact… covers PR and merge-queue selection and sharding, not Sonar. The policy is stated only in the PR description: "The nightly run is the only one, so it is the full-suite baseline" and "a failing browser test still fails the job … the sonar-scanner install and scan steps now use if: ${{ !cancelled() }}, so that lcov still gets scanned." It also picks a new 180-minute job timeout by judgment for an unsharded run. The record would say: "UI SonarCloud coverage is the union of the Jest lcov and the browser-suite lcov from one unsharded nightly run on main. A test failure still fails the job but does not block the scan. The job is capped at 180 minutes."

✅ Edge Case: Missing lcov skips the scan but the job still passes, with no Slack alert

📄 .github/workflows/ui-sonarcloud-nightly.yml:115-127
Check coverage reports writes ready=false and exits 0 when a report is missing. If both suites pass but a report is not written, for example because coverageDirectory, the reporters or the test:ui:coverage config change, the job succeeds. The notify job (contains(needs.*.result, 'failure')) then never fires, and Sonar stops updating with only an annotation to show for it. That is the same silent No LCOV files were found state this commit fixes. Fail the step after writing the output: the later steps already gate on ready == 'true', so they still skip, and the run notifies Slack.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@chirag-madlani
chirag-madlani merged commit 6c23808 into main Nov 26, 2026
49 checks passed
@chirag-madlani
chirag-madlani deleted the ci/sonar-browser-coverage branch November 26, 2026 07: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.

SonarCloud reads only the Jest lcov; the browser-test coverage is not counted

4 participants