Skip to content

added generic test exclusion #5

added generic test exclusion

added generic test exclusion #5

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 --ignore-scripts
- 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