From a605d39dbe0aaf2044408b72a6ba937f27d1a2c7 Mon Sep 17 00:00:00 2001 From: Sivaprakash Ramasamy Date: Wed, 6 Aug 2025 19:40:24 +0530 Subject: [PATCH 1/2] Create sonarqube.yml --- .github/workflows/sonarqube.yml | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..1d57edc --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,39 @@ +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 Java + uses: actions/setup-java@v3 + with: + java-version: '17' # Adjust to your app + + - name: Cache SonarQube packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + + - name: Run SonarQube Scanner + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: | + ./gradlew sonarqube \ + -Dsonar.projectKey=nodebb \ + -Dsonar.host.url=$SONAR_HOST_URL \ + -Dsonar.login=$SONAR_TOKEN + + - name: Check Quality Gate (Optional workaround) + run: echo "Can't check quality gate in Community Edition" From 8b64321d18197acd06241dc97a4e2b11eae677b1 Mon Sep 17 00:00:00 2001 From: Sivaprakash Ramasamy Date: Thu, 7 Aug 2025 16:58:27 +0530 Subject: [PATCH 2/2] Update sonarqube.yml --- .github/workflows/sonarqube.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 1d57edc..a69a3e3 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -14,26 +14,34 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Java - uses: actions/setup-java@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 with: - java-version: '17' # Adjust to your app + node-version: '22' - - name: Cache SonarQube packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar + - 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: | - ./gradlew sonarqube \ - -Dsonar.projectKey=nodebb \ + npm install -g sonarqube-scanner + sonar-scanner \ + -Dsonar.projectKey=sunbird-nodebb \ + -Dsonar.sources=. \ -Dsonar.host.url=$SONAR_HOST_URL \ - -Dsonar.login=$SONAR_TOKEN + -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"