From 5f6d957c8c18190907941f39c26bae60a15e8481 Mon Sep 17 00:00:00 2001 From: Santosh Shinde Date: Thu, 16 May 2024 15:39:09 +0530 Subject: [PATCH] update sonar report and workflow --- .github/workflows/ci.yml | 68 ++++++ .github/workflows/node.js.yml | 44 ---- .github/workflows/sonarcloud-scan.yml | 12 - .gitignore | 2 + README.md | 2 +- coverage/lcov.info | 305 -------------------------- package-lock.json | 26 +-- package.json | 2 +- sonar-project.properties | 21 -- sonar-report.xml | 58 ++--- 10 files changed, 114 insertions(+), 426 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/node.js.yml delete mode 100644 .github/workflows/sonarcloud-scan.yml delete mode 100644 coverage/lcov.info delete mode 100644 sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..72139c8d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: CI +on: + push: + branches: + - main + - master + - dev + - release-* + pull_request: + types: [opened, synchronize, reopened] + branches: + - main + - master + - dev + - release-* + +jobs: + CI: + strategy: + matrix: + node-version: [18.x] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Set up nodejs version ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - name: Clean Cache + run: npm cache clean --force + - name: Install package + run: npm install + - name: Build + run: npm run build --if-present + - name: Test + run: npm run test + - name: CodeClimate Scan + uses: paambaati/codeclimate-action@v6.0.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TOKEN }} + with: + coverageLocations: | + ${{github.workspace}}/coverage/*.info:lcov + ${{github.workspace}}/coverage/clover.xml:clover + debug: true + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + with: + args: > + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.organization=santoshshinde2012 + -Dsonar.projectKey=santoshshinde2012_node-boilerplate + -Dsonar.projectName=node-boilerplate + -Dsonar.projectVersion=1.0 + -Dsonar.sources=. + -Dsonar.exclusions=**/tests/**/*.ts + -Dsonar.test.inclusions=**/tests/**/*.ts + -Dsonar.coverage.exclusions=**/tests/**/*.ts,/**/src/server.ts,node_modules/*,coverage/lcov-report/* + -Dsonar.language=ts + -Dsonar.tests=./tests + -Dsonar.verbose=false + -Dsonar.sourceEncoding=UTF-8 + -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info + -Dsonar.testExecutionReportPaths=./coverage/sonar-report.xml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 5c9cd507..00000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: CI -on: - push: - branches: - - main - - master - - dev - - release-* - pull_request: - types: [opened, synchronize, reopened] - branches: - - main - - master - - dev - - release-* - -jobs: - CI: - strategy: - matrix: - node-version: [18.x] - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Set up nodejs version ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - name: Clean Cache - run: npm cache clean --force - - name: Install package - run: npm install - - name: Build - run: npm run build --if-present - - name: Test - run: npm run test - - name: Test & publish code coverage - uses: paambaati/codeclimate-action@v6.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TOKEN }} - with: - coverageCommand: npm run test - debug: true \ No newline at end of file diff --git a/.github/workflows/sonarcloud-scan.yml b/.github/workflows/sonarcloud-scan.yml deleted file mode 100644 index d2fd6305..00000000 --- a/.github/workflows/sonarcloud-scan.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: SonarCloud Scan -on: [pull_request] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Run Snyk to check for vulnerabilities - uses: sonarsource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index c9f6e806..58a4b159 100755 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ build/ tmp/ temp/ logs +coverage +coverage/lcov.info coverage/lcov-report coverage/coverage-final.json coverage/clover.xml diff --git a/README.md b/README.md index 9291b5f4..5d343830 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [Node-Typescript-Boilerplate](https://blog.santoshshinde.com/skeleton-for-node-js-apps-written-in-typescript-444fa1695b30) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=santoshshinde2012_node-boilerplate&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=santoshshinde2012_node-boilerplate)![Github action workflow status](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/node.js.yml/badge.svg?branch=master)![CodeQL Analysis](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)![njsscan Analysis](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/njsscan.yml/badge.svg?branch=master)![Maintainability](https://api.codeclimate.com/v1/badges/0e53f5d93de102b39641/maintainability)![Test Coverage](https://api.codeclimate.com/v1/badges/0e53f5d93de102b39641/test_coverage) +# [Node-Typescript-Boilerplate](https://blog.santoshshinde.com/skeleton-for-node-js-apps-written-in-typescript-444fa1695b30) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=santoshshinde2012_node-boilerplate&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=santoshshinde2012_node-boilerplate)![Github action workflow status](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/ci.yml/badge.svg?branch=master)![CodeQL Analysis](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)![njsscan Analysis](https://github.com/santoshshinde2012/node-boilerplate/actions/workflows/njsscan.yml/badge.svg?branch=master)![Maintainability](https://api.codeclimate.com/v1/badges/0e53f5d93de102b39641/maintainability)![Test Coverage](https://api.codeclimate.com/v1/badges/0e53f5d93de102b39641/test_coverage) Skeleton for Node.js applications written in TypeScript diff --git a/coverage/lcov.info b/coverage/lcov.info deleted file mode 100644 index 8d3b431e..00000000 --- a/coverage/lcov.info +++ /dev/null @@ -1,305 +0,0 @@ -TN: -SF:src/App.ts -FN:16,(anonymous_1) -FN:39,(anonymous_2) -FN:48,(anonymous_3) -FN:68,(anonymous_4) -FN:78,(anonymous_5) -FN:85,(anonymous_6) -FNF:6 -FNH:6 -FNDA:2,(anonymous_1) -FNDA:2,(anonymous_2) -FNDA:2,(anonymous_3) -FNDA:1,(anonymous_4) -FNDA:2,(anonymous_5) -FNDA:2,(anonymous_6) -DA:1,2 -DA:2,2 -DA:3,2 -DA:4,2 -DA:5,2 -DA:6,2 -DA:7,2 -DA:8,2 -DA:9,2 -DA:11,2 -DA:17,2 -DA:18,2 -DA:19,2 -DA:22,2 -DA:25,2 -DA:28,2 -DA:31,2 -DA:32,2 -DA:40,2 -DA:41,2 -DA:42,2 -DA:52,2 -DA:53,2 -DA:54,2 -DA:58,2 -DA:65,2 -DA:75,1 -DA:82,2 -DA:86,2 -LF:29 -LH:29 -BRDA:31,0,0,2 -BRDA:31,1,0,2 -BRDA:31,1,1,2 -BRF:3 -BRH:3 -end_of_record -TN: -SF:src/routes.ts -FN:6,registerControllerRoutes -FN:8,(anonymous_2) -FN:36,registerRoutes -FN:44,(anonymous_4) -FNF:4 -FNH:4 -FNDA:2,registerControllerRoutes -FNDA:18,(anonymous_2) -FNDA:2,registerRoutes -FNDA:2,(anonymous_4) -DA:1,2 -DA:2,2 -DA:7,2 -DA:8,2 -DA:9,18 -DA:11,10 -DA:12,10 -DA:14,2 -DA:15,2 -DA:17,2 -DA:18,2 -DA:20,2 -DA:21,2 -DA:23,2 -DA:24,2 -DA:26,0 -DA:29,2 -DA:36,2 -DA:37,2 -DA:40,2 -DA:44,2 -DA:46,2 -DA:49,2 -LF:23 -LH:22 -BRDA:9,0,0,10 -BRDA:9,0,1,2 -BRDA:9,0,2,2 -BRDA:9,0,3,2 -BRDA:9,0,4,2 -BRDA:9,0,5,0 -BRF:6 -BRH:5 -end_of_record -TN: -SF:src/abstractions/ApiError.ts -FN:19,(anonymous_0) -FNF:1 -FNH:1 -FNDA:2,(anonymous_0) -DA:13,2 -DA:15,2 -DA:20,2 -DA:21,2 -DA:22,2 -DA:23,2 -DA:27,3 -LF:7 -LH:7 -BRDA:19,0,0,2 -BRF:1 -BRH:1 -end_of_record -TN: -SF:src/components/BaseController.ts -FN:17,(anonymous_0) -FNF:1 -FNH:1 -FNDA:6,(anonymous_0) -DA:2,3 -DA:4,3 -DA:9,3 -DA:18,6 -DA:19,6 -LF:5 -LH:5 -BRDA:17,0,0,6 -BRF:1 -BRH:1 -end_of_record -TN: -SF:src/components/system-status/SystemStatusController.ts -FN:18,(anonymous_7) -FN:25,(anonymous_8) -FN:47,(anonymous_9) -FN:78,(anonymous_10) -FN:93,(anonymous_11) -FN:120,(anonymous_12) -FN:154,(anonymous_13) -FNF:7 -FNH:7 -FNDA:3,(anonymous_7) -FNDA:2,(anonymous_8) -FNDA:4,(anonymous_9) -FNDA:2,(anonymous_10) -FNDA:3,(anonymous_11) -FNDA:3,(anonymous_12) -FNDA:3,(anonymous_13) -DA:2,3 -DA:3,3 -DA:4,3 -DA:5,3 -DA:6,3 -DA:18,3 -DA:20,3 -DA:26,2 -DA:52,4 -DA:53,4 -DA:64,4 -DA:66,4 -DA:68,3 -DA:79,2 -DA:80,2 -DA:83,2 -DA:98,3 -DA:99,3 -DA:100,3 -DA:103,3 -DA:107,3 -DA:108,3 -DA:110,2 -DA:125,3 -DA:126,3 -DA:127,3 -DA:128,3 -DA:130,3 -DA:141,3 -DA:142,3 -DA:144,2 -DA:159,3 -DA:160,3 -DA:169,3 -DA:170,3 -DA:172,2 -LF:36 -LH:36 -BRF:0 -BRH:0 -end_of_record -TN: -SF:src/lib/crypto.ts -FN:23,(anonymous_6) -FN:71,(anonymous_7) -FNF:2 -FNH:2 -FNDA:4,(anonymous_6) -FNDA:3,(anonymous_7) -DA:1,5 -DA:3,5 -DA:5,5 -DA:11,5 -DA:15,5 -DA:18,5 -DA:21,5 -DA:25,4 -DA:26,4 -DA:29,4 -DA:32,4 -DA:45,4 -DA:52,4 -DA:57,4 -DA:60,4 -DA:63,4 -DA:68,4 -DA:73,3 -DA:74,3 -DA:78,3 -DA:81,3 -DA:90,3 -DA:96,3 -DA:99,3 -DA:102,3 -DA:105,3 -DA:111,3 -DA:115,3 -DA:118,3 -LF:29 -LH:29 -BRF:0 -BRH:0 -end_of_record -TN: -SF:src/lib/logger.ts -FNF:0 -FNH:0 -DA:1,2 -DA:3,2 -DA:7,2 -DA:15,2 -LF:4 -LH:4 -BRF:0 -BRH:0 -end_of_record -TN: -SF:src/middleware/error-handler.ts -FN:9,(anonymous_1) -FNF:1 -FNH:1 -FNDA:4,(anonymous_1) -DA:1,3 -DA:3,3 -DA:5,3 -DA:6,3 -DA:9,3 -DA:15,4 -DA:16,3 -DA:17,3 -DA:18,3 -DA:26,3 -DA:34,3 -DA:36,3 -DA:38,1 -DA:43,3 -LF:14 -LH:14 -BRDA:15,0,0,3 -BRDA:15,0,1,1 -BRDA:16,1,0,3 -BRDA:16,1,1,1 -BRDA:17,2,0,3 -BRDA:17,2,1,1 -BRF:6 -BRH:6 -end_of_record -TN: -SF:src/utils/index.ts -FN:3,getEncryptedText -FNF:1 -FNH:1 -FNDA:11,getEncryptedText -DA:1,4 -DA:4,11 -DA:5,11 -DA:8,11 -DA:10,3 -DA:11,3 -DA:14,8 -DA:17,4 -DA:20,4 -LF:9 -LH:9 -BRDA:8,0,0,3 -BRDA:8,1,0,11 -BRDA:8,1,1,4 -BRDA:10,2,0,1 -BRDA:10,2,1,2 -BRF:5 -BRH:5 -end_of_record diff --git a/package-lock.json b/package-lock.json index 799c53ce..24c0f027 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.11", "jest": "^29.7.0", - "jest-to-sonar": "^1.0.0", + "jest-to-sonar": "^1.1.0", "nodemon": "^3.1.0", "prettier": "^3.2.5", "supertest": "^7.0.0", @@ -2467,9 +2467,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001618", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz", - "integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==", + "version": "1.0.30001620", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001620.tgz", + "integrity": "sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew==", "dev": true, "funding": [ { @@ -3036,9 +3036,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.769", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.769.tgz", - "integrity": "sha512-bZu7p623NEA2rHTc9K1vykl57ektSPQYFFqQir8BOYf6EKOB+yIsbFB9Kpm7Cgt6tsLr9sRkqfqSZUw7LP1XxQ==", + "version": "1.4.772", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.772.tgz", + "integrity": "sha512-jFfEbxR/abTTJA3ci+2ok1NTuOBBtB4jH+UT6PUmRN+DY3WSD4FFRsgoVQ+QNIJ0T7wrXwzsWCI2WKC46b++2A==", "dev": true }, "node_modules/emittery": { @@ -5628,9 +5628,9 @@ } }, "node_modules/jest-to-sonar": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/jest-to-sonar/-/jest-to-sonar-1.0.0.tgz", - "integrity": "sha512-j3iCFr+6JQa8o+8AJ1/+JLjXES5sEG9fy6g2nBipxNxomkmthr9jEfruhQjReFAmUp2971ohxfppYjFCD5PkQQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jest-to-sonar/-/jest-to-sonar-1.1.0.tgz", + "integrity": "sha512-CYBP51mOSvcelSQs3BZvuuGKFhcfLa9hzHcpl83/F16AhbTTiPXWOSmZfG9Dr6mz2OvmJZBSIzfU9+4oV2O/MQ==", "dev": true }, "node_modules/jest-util": { @@ -7548,9 +7548,9 @@ } }, "node_modules/swagger-ui-dist": { - "version": "5.17.9", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.9.tgz", - "integrity": "sha512-qhZdoXIleblFxufohnd4ir4KmVA7/uFfd/9sDTtH8A6Qm1lEK40MhrMrDqy9AygGjw1bnJpZH4yZ5wu12vW1aw==" + "version": "5.17.10", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.10.tgz", + "integrity": "sha512-fp8SYeEK216KS1/noDvursUOGojEbkvtckOpOmAGZUjlx/ma7VLD2PLQwyermjlzFrlHI5uCt1V+M1C3qBvRyQ==" }, "node_modules/swagger-ui-express": { "version": "5.0.0", diff --git a/package.json b/package.json index ef434a17..5298744a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.11", "jest": "^29.7.0", - "jest-to-sonar": "^1.0.0", + "jest-to-sonar": "^1.1.0", "nodemon": "^3.1.0", "prettier": "^3.2.5", "supertest": "^7.0.0", diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 2353fa1c..00000000 --- a/sonar-project.properties +++ /dev/null @@ -1,21 +0,0 @@ -sonar.host.url=https://sonarcloud.io -sonar.projectKey=santoshshinde2012_node-boilerplate -sonar.organization=santoshshinde2012 - -# This is the name and version displayed in the SonarCloud UI. -sonar.projectName=node-boilerplate -sonar.projectVersion=1.0 - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=. -sonar.exclusions=**/tests/**/*.ts -sonar.test.inclusions=**/tests/**/*.ts -sonar.coverage.exclusions=**/tests/**/*.ts,/**/src/server.ts,node_modules/*,coverage/lcov-report/* -sonar.language=ts -sonar.tests=./tests - -sonar.javascript.lcov.reportPaths=./coverage/lcov.info -sonar.testExecutionReportPaths=./sonar-report.xml - -# Encoding of the source code. Default is default system encoding -sonar.sourceEncoding=UTF-8 \ No newline at end of file diff --git a/sonar-report.xml b/sonar-report.xml index 2b060db8..cc3a5e91 100644 --- a/sonar-report.xml +++ b/sonar-report.xml @@ -1,47 +1,47 @@ - - + + - + - + - + - + + + - + - + - + + + - + - + - - - + - + - + - - - + - + - + - + - + @@ -49,21 +49,21 @@ - + - + - + - + - + - + \ No newline at end of file