Skip to content

Commit 618edcc

Browse files
Merge pull request #12 from rootstrap/chore/sonarqube
chore: setup sonar scanner
2 parents 5924d26 + 7024878 commit 618edcc

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

.github/workflows/sonar.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
jobs:
15+
sonar:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: 📦 Checkout project repo
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: 📦 Setup Node + PNPM + install deps
24+
uses: ./.github/actions/setup-node-pnpm-install
25+
26+
- name: Run Tests
27+
run: export NODE_OPTIONS=--experimental-vm-modules && pnpm test:ci
28+
29+
- name: SonarQube Scan
30+
uses: sonarsource/sonarqube-scan-action@master
31+
env:
32+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33+
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
34+
with:
35+
args: >
36+
-Dsonar.sonar.sources=./src
37+
-Dsonar.qualitygate.wait=true
38+
-Dsonar.projectBaseDir=.
39+
-Dsonar.verbose=false
40+
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT }}
41+
-Dsonar.sonar.sourceEncoding=UTF-8
42+
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
43+
-Dsonar.coverage.exclusions=**/storage/**,**/**.config.js,**/*.test.tsx,**/icons/**,**/docs/**,**/cli/**,**/__mocks__/**,**/android/**,**/ios/**

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)