Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: SonarQube PR Check

on:
pull_request:
branches:
- main

jobs:
sonarqube:
name: Run SonarQube Analysis
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Install dependencies
run: npm ci

- name: Run tests and generate coverage
run: |
npm test -- --coverage
ls coverage

- name: Run SonarQube Scanner
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: |
npm install -g sonarqube-scanner
sonar-scanner \
-Dsonar.projectKey=sunbird-nodebb \
-Dsonar.sources=. \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.exclusions="**/node_modules/**, **/*.module.ts, **/*.model.ts, **/*.conf.js, **/*.guard.ts, **/*.constants.ts" \
-Dsonar.tests=src \
-Dsonar.test.inclusions=**/*.spec.ts \
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info

- name: Check Quality Gate (Optional workaround)
run: echo "Can't check quality gate in Community Edition"
Loading