File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Sonar Analysis
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ types : [opened, synchronize, reopened]
9+ branches :
10+ - main
11+
12+ jobs :
13+ sonarcloud_scan :
14+ name : Build, Test and Analyze
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout Code
19+ uses : actions/checkout@v4
20+ with :
21+ # Fetch depth 0 is crucial for SonarCloud to analyze all code history
22+ # and correctly compute 'New Code' metrics, especially for PRs.
23+ fetch-depth : 0
24+
25+ - name : Set up Node.js
26+ uses : actions/setup-node@v4
27+ with :
28+ node-version : ' 20'
29+ cache : ' npm'
30+
31+ - name : Install dependencies
32+ run : npm install
33+
34+ - name : Run tests and generate coverage
35+ run : npm test
36+
37+ - name : Run SonarCloud Analysis
38+ # This command runs the sonar-scanner executable from the sonarqube-scanner package.
39+ # The configuration is taken from sonar-project.js
40+ run : npm exec sonar-scanner
41+ env :
42+ # The SONAR_TOKEN is needed for authentication with SonarCloud.
43+ # It should be stored as a secret in your GitHub repository.
44+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
45+ # The SONAR_HOST_URL is required by the scanner.
46+ SONAR_HOST_URL : https://sonarcloud.io
Original file line number Diff line number Diff line change 1+ const sonarqubeScanner = require ( 'sonarqube-scanner' ) ;
2+
3+ sonarqubeScanner ( {
4+ serverUrl : 'https://sonarcloud.io' ,
5+ options : {
6+ 'sonar.organization' : 'rohithandique' ,
7+ 'sonar.projectKey' : 'rohithandique_generic-server-spring-boot' ,
8+ 'sonar.sources' : 'src' ,
9+ 'sonar.tests' : 'src' ,
10+ 'sonar.inclusions' : '**/*.ts,**/*.tsx' ,
11+ 'sonar.test.inclusions' : 'src/**/*.test.tsx,src/**/*.test.ts' ,
12+ 'javascript.lcov.reportPaths' : 'coverage/lcov.info' ,
13+ 'sonar.token' : process . env . SONAR_TOKEN ,
14+ } ,
15+ } , ( ) => process . exit ( ) ) ;
Original file line number Diff line number Diff line change 1+ import { render , screen } from '@testing-library/react' ;
2+ import { describe , it , expect } from 'vitest' ;
3+ import App from './App' ;
4+
5+ describe ( 'App' , ( ) => {
6+ it ( 'renders headline' , ( ) => {
7+ render ( < App /> ) ;
8+ const headline = screen . getByText ( / V i t e \+ R e a c t / i) ;
9+ expect ( headline ) . toBeInTheDocument ( ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ import '@testing-library/jest-dom' ;
You can’t perform that action at this time.
0 commit comments