-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.43 KB
/
Copy pathsonar.yml
File metadata and controls
49 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Sonar Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
jobs:
sonarcloud_scan:
name: Build, Test and Analyze
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
# Fetch depth 0 is crucial for SonarCloud to analyze all code history
# and correctly compute 'New Code' metrics, especially for PRs.
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run tests and generate coverage
run: npm test
- name: Run SonarCloud Analysis
# This command runs the sonar-scanner executable from the sonarqube-scanner package.
# It passes organization and project key from secrets to ensure they are always correctly set.
run: >
npm exec sonar-scanner --
-Dsonar.organization=rohithandique
-Dsonar.projectKey=rohithandique_generic-ui-react
env:
# The SONAR_TOKEN is needed for authentication with SonarCloud.
# It should be stored as a secret in your GitHub repository.
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# The SONAR_HOST_URL is required by the scanner.
SONAR_HOST_URL: https://sonarcloud.io