Skip to content

Commit 43cf5fa

Browse files
committed
#21: Add SonarCloud integration for code quality analysis
- Created GitHub Actions workflow for automated SonarCloud scans - Updated .sonarcloud.properties with coverage reporting config - Configured to run on push to master/main/release branches and PRs - Uses existing SONAR_TOKEN secret and project key
1 parent 0516879 commit 43cf5fa

2 files changed

Lines changed: 57 additions & 6 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: SonarCloud Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- 'release/**'
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
12+
jobs:
13+
sonarcloud:
14+
name: SonarCloud Scan
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # Shallow clones should be disabled for better analysis
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Run tests with coverage
36+
run: npm run test:coverage
37+
38+
- name: SonarCloud Scan
39+
uses: SonarSource/sonarqube-scan-action@v3
40+
env:
41+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
42+
SONAR_HOST_URL: https://sonarcloud.io
43+
with:
44+
args: >
45+
-Dsonar.organization=migration-script-runner
46+
-Dsonar.projectKey=migration-script-runner_msr-firebase

.sonarcloud.properties

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Path to sources
22
sonar.sources=src
3-
sonar.exclusions=test
4-
#sonar.inclusions=
3+
sonar.exclusions=**/*.test.ts,**/*.spec.ts,**/test/**,**/dist/**,**/node_modules/**
54

65
# Path to tests
76
sonar.tests=test
8-
#sonar.test.exclusions=
9-
#sonar.test.inclusions=
7+
sonar.test.inclusions=**/*.test.ts,**/*.spec.ts
108

119
# Source encoding
12-
#sonar.sourceEncoding=UTF-8
10+
sonar.sourceEncoding=UTF-8
11+
12+
# Coverage paths
13+
sonar.javascript.lcov.reportPaths=reports/coverage/lcov.info
14+
sonar.typescript.lcov.reportPaths=reports/coverage/lcov.info
15+
16+
# Language
17+
sonar.language=ts
1318

1419
# Exclusions for copy-paste detection
15-
#sonar.cpd.exclusions=
20+
sonar.cpd.exclusions=**/*.test.ts,**/*.spec.ts

0 commit comments

Comments
 (0)