Skip to content

ci: SonarCloud quality gate + coverage#7

Merged
aksOps merged 2 commits into
mainfrom
feat/sonarcloud-coverage
May 1, 2026
Merged

ci: SonarCloud quality gate + coverage#7
aksOps merged 2 commits into
mainfrom
feat/sonarcloud-coverage

Conversation

@aksOps

@aksOps aksOps commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wires SonarCloud scanning on push to main and on PRs, with Go + UI coverage uploaded in the same workspace pass.
  • Adds sonar-project.properties (project key RandomCodeSpace_ctm, org randomcodespace) covering source/test split, exclusions for generated/vendored/agent paths, and coverage report locations.
  • Enables vitest v8 coverage (@vitest/coverage-v8@^3.2.4, lcov + html + text reporters) and emits ui/coverage/lcov.info for Sonar.
  • Workflow gracefully degrades when SONAR_TOKEN is missing — emits a ::warning:: instead of failing, so the gate doesn't block merges before the secret is configured.

Manual setup required

  1. Sign in to https://sonarcloud.io with GitHub and import RandomCodeSpace/ctm.
  2. Generate a user token (Sonar UI → My Account → Security).
  3. Add it to repo secrets as SONAR_TOKEN (Settings → Secrets and variables → Actions).
  4. Confirm sonar.projectKey / sonar.organization in sonar-project.properties match what Sonar generated.

Until step 3 is done, the workflow runs the test/coverage steps and skips the upload with a warning.

Test plan

  • go test -tags sqlite_fts5 -coverprofile=coverage.out -covermode=atomic ./... succeeds locally; coverage.out populated.
  • pnpm -C ui exec vitest run --coverage succeeds locally; ui/coverage/lcov.info populated.
  • Workflow run on this PR completes (with SONAR_TOKEN warning until secret is set).
  • After SONAR_TOKEN is added, rerun the workflow and confirm Sonar dashboard shows coverage + new-code metrics.

🤖 Generated with Claude Code

Adds a SonarCloud scan that ingests Go + JS/TS coverage on every PR
and on push to main. Coverage is collected fresh in this workflow
rather than reused from CI — the existing ci.yml runs go test without
-coverprofile and adding it there would slow every PR build.

Setup required (manual, one-time):
  1. Sign in to sonarcloud.io with GitHub.
  2. Import RandomCodeSpace/ctm; project key auto-generated as
     RandomCodeSpace_ctm (matches sonar-project.properties).
  3. Generate a user token; add as repo secret SONAR_TOKEN.

Until SONAR_TOKEN is set, the workflow runs the test+coverage steps
and emits a workflow warning instead of erroring on the scan step.

Coverage layout:
  - Go:    go test -coverprofile=coverage.out (atomic mode for race-safe)
  - UI:    vitest run --coverage with provider:v8 → ui/coverage/lcov.info
  - Both:  excluded from git via .gitignore

Excluded from analysis: dist/, vendor/, node_modules/, _attic/,
.claude/, .codeiq/, internal/serve/dist/ (generated UI bundle),
ui/playwright-report/, ui/test-results/, docs/.

Quality gate uses SonarCloud's default ('clean as you code', 80%
new-code coverage) — adjustable in the SonarCloud UI later.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@socket-security

socket-security Bot commented May 1, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​vitest/​coverage-v8@​3.2.4991007298100

View full report

Comment thread .github/workflows/sonar.yml Fixed
Comment thread .github/workflows/sonar.yml Fixed
Closes the three findings the SonarCloud quality gate raised on PR #7:

- pnpm/action-setup pinned to commit SHA (v4 → b906aff). Tag-based refs
  for third-party actions can be silently rewritten — Sonar S7637.
- SonarSource/sonarqube-scan-action bumped v5 → v6 and pinned to SHA
  fd88b7d. v5 emits a deprecation/security warning on every run.
- pnpm install now passes --ignore-scripts (Sonar S6505). Modern vitest
  + React stack doesn't require lifecycle scripts; verified locally
  with a clean install + `vitest run --coverage`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented May 1, 2026

Copy link
Copy Markdown

@aksOps aksOps merged commit 21d5284 into main May 1, 2026
10 checks passed
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