Skip to content

Commit e3dcba6

Browse files
chore: setup sonar scanner
1 parent 2d5464a commit e3dcba6

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

.github/workflows/sonar.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: SonarQube analysis
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
push:
7+
branches:
8+
- main
9+
- master
10+
- staging
11+
- qa
12+
- development
13+
14+
env:
15+
SONAR_PROJECT: myapp-delete
16+
17+
jobs:
18+
sonar:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: 📦 Checkout project repo
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- name: 📦 Setup Node + PNPM + install deps
27+
uses: ./.github/actions/setup-node-pnpm-install
28+
29+
- name: Run Tests
30+
run: export NODE_OPTIONS=--experimental-vm-modules && pnpm test:ci
31+
32+
- name: SonarQube Scan
33+
uses: sonarsource/sonarqube-scan-action@master
34+
env:
35+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
36+
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
37+
with:
38+
args: >
39+
-Dsonar.sonar.sources=./src
40+
-Dsonar.qualitygate.wait=true
41+
-Dsonar.projectBaseDir=.
42+
-Dsonar.verbose=false
43+
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT }}
44+
-Dsonar.sonar.sourceEncoding=UTF-8
45+
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
46+
-Dsonar.coverage.exclusions=**/storage/**,**/**.config.js,**/*.test.tsx,**/icons/**

README-project.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ To run the app on Android
3737
pnpm android
3838
```
3939

40+
### SonarQube setup
41+
42+
SonarQube is an open-source platform for continuous inspection of code quality. It performs automatic reviews to detect bugs, code smells, and security vulnerabilities. Rootstrap has a SonarQube instance to improve the quality of the software we develop. On each PR, a GitHub Action is triggered to perform the analysis. To set up SonarQube correctly, you need to add the `SONAR_TOKEN`, `SONAR_URL`, and `SONAR_PROJECT` secrets to the repository. Additionally, you must select the quality gate named `ReactNativeTemplate` for your project on SonarQube. In case you're using this project outside Rootstrap and you're not planning to use SonarQube the sonar scanner [workflow](.github/workflows/sonar.yml) should be deleted.
43+
4044
## ✍️ Documentation
4145

4246
- [Rules and Conventions](https://starter.obytes.com/getting-started/rules-and-conventions/)

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ module.exports = {
1818
transformIgnorePatterns: [
1919
`node_modules/(?!(?:.pnpm/)?((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg))`,
2020
],
21-
coverageReporters: ['json-summary', ['text', { file: 'coverage.txt' }]],
21+
coverageReporters: [
22+
'json-summary',
23+
['text', { file: 'coverage.txt' }],
24+
'lcov',
25+
],
2226
reporters: [
2327
'default',
2428
['github-actions', { silent: false }],

0 commit comments

Comments
 (0)