Thanks @Colin for response.
Here is redacted Github Actions YAML
name: Mobile App Sonar Analysis
on:
pull_request:
branches:
- development
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
SonarAnalysis:
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '14.x'
- uses: c-hive/gha-yarn-cache@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Install dependencies
run: yarn --frozen-lockfile --network-timeout 90000
- name: Run Tests in one chunk
run: |
npm run test:ci:pre-process
npm run lint
npm run test:ci
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENV_DEV: ${{ secrets.ENV_DEV }}
- name: Collect and Publish Sonar Report
run: |
npm run test:ci:post-process -- -Dsonar.projectVersion="${GITHUB_SHA::10}"
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENV_DEV: ${{ secrets.ENV_DEV }}
Here is package.json section that’s relevant
...
"scripts": {
"test:ci:pre-process": "node react-native.config.js",
"test:ci": "NODE_ENV=test jest --coverage --ci --env=jsdom --watchAll=false --testResultsProcessor jest-sonar-reporter --reporters='default'",
"test:ci:post-process": "sonar-scanner",
"lint": "tsc --noEmit && eslint --cache --ext .js,.jsx,.ts,.tsx ./",
}
...
Relevant configuration for sonar-project.properties file
...
sonar.exclusions=node_modules/**/*,reports/**/*, **/__mocks__/**/*, android/**/*.java, coverage/**/*, env/**/*, fastlane/**/*, ios/**/*, nswag/**/*, patches/**/*, babel.config.js, declarations.d.ts, jestSetupFile.js, metro.config.js, react-native.config.js, test-report.xml, .github/**/*, .githooks/**/*, src/common/service-proxies/**/*, src/assets/**/*,src/app/data/model/**/*, src/common/enums/**/*, src/app/data/raw/**/*,XXXXXXXXXXXXXXXXXXXX
sonar.host.url=https://sonarcloud.io
sonar.organization=XXXXXXXXXX
sonar.projectKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sonar.sourceEncoding=UTF-8
sonar.sources=.
sonar.test.inclusions=**/__tests__/*.tsx, **/__tests__/*.ts, **/__test__/*.tsx, **/__test__/*.ts, **/__tests__/**/*.tsx, **/__tests__/**/*.ts, **/__test__/**/*.tsx, **/__test__/**/*.ts, **/*.test.ts, **/*.test.tsx
sonar.test.exclusions=node_modules/**/*,reports/**/*, **/__mocks__/**/*, android/**/*.java, coverage/**/*, env/**/*, fastlane/**/*, ios/**/*, nswag/**/*, patches/**/*, babel.config.js, declarations.d.ts, jestSetupFile.js, metro.config.js, react-native.config.js, test-report.xml, .github/**/*, .githooks/**/*, src/common/service-proxies/**/*, src/assets/**/*,src/common/enums/**/*, src/common/constant/**/*, src/common/context/featureFlag/**/*, src/common/generic/**/*, src/common/navigator/**/*, src/common/types/**/*, src/app/data/**/*, src/app/index.tsx, src/redux/store/**/*, XXXXXXXXXXXXXXXXXXXX
sonar.coverage.exclusions=src/common/service-proxies/**/*, src/assets/**/*,src/common/enums/**/*, src/common/constant/**/*, src/common/context/featureFlag/**/*, src/common/generic/**/*, src/common/navigator/**/*, src/common/types/**/*, src/app/data/**/*, src/app/index.tsx, src/redux/store/**/*, .storybook/**/*, src/components/modules/**/index.ts, **/*stories.tsx, XXXXXXXXXXXXXXXXXXXX
sonar.testExecutionReportPaths=test-report.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.qualitygate.wait=true
...