Skip to content

Commit 121ee02

Browse files
eran132claude
andcommitted
chore: add SonarCloud static analysis workflow
Adds SonarCloud configuration and GitHub Action workflow for automated code quality and security scanning on PRs and pushes to main. Runs Jest with coverage and uploads results to SonarCloud. Requires org admin to: 1. Register the project at sonarcloud.io 2. Add SONAR_TOKEN to repository secrets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 363519b commit 121ee02

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: SonarCloud Analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
sonarcloud:
14+
name: SonarCloud Scan
15+
runs-on: ubuntu-latest
16+
if: github.event.pull_request.head.repo.fork == false
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 22
25+
cache: npm
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run unit tests with coverage
31+
run: npx jest --coverage --coverageReporters=lcov
32+
33+
- name: SonarCloud Scan
34+
uses: SonarSource/sonarqube-scan-action@v5
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sonar.projectKey=hasadna_open-bus-map-search
2+
sonar.organization=hasadna
3+
sonar.projectName=open-bus-map-search
4+
5+
sonar.sources=src
6+
sonar.tests=src
7+
sonar.test.inclusions=**/*.test.ts,**/*.test.tsx,**/*.spec.ts
8+
sonar.exclusions=**/node_modules/**,**/*.spec.ts,**/*.stories.tsx
9+
sonar.coverage.exclusions=**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.stories.tsx
10+
11+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
12+
sonar.typescript.lcov.reportPaths=coverage/lcov.info
13+
14+
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)