Skip to content

Commit

Permalink
Feature/GitHub workflow (#2)
Browse files Browse the repository at this point in the history
* feature: continue setup
  • Loading branch information
ashrafhofney authored Feb 8, 2022
1 parent 5240754 commit 7ff0dda
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 27 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,11 @@ jobs:
node-version: '16'

- name: Install Dependencies
run: |
npm install
npm test
ls
cat test-report.xml
run: npm install

- name: Sonar Scan
uses: sonarsource/sonarqube-scan-action@master
with:
args: >
-Dsonar.projectKey=node-ts-conventions
-Dsonar.projectVersion=1.0.0
-Dsonar.sourceEncoding=UTF-8
-Dsonar.links.scm=https://github.com/blink22/node-ts-conventions/
-Dsonar.sources=src
-Dsonar.tests=tests
-Dsonar.exclusions=**/tests/*.*
-Dsonar.test.inclusions=**/*.test.*
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.testExecutionReportPaths=test-report.xml
-Dsonar.coverage.exclusions=**/*.spec.js,**/*.spec.ts,**/*.mock.js,**/*.mock.ts,node_modules/*,coverage/lcov-report/*
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
run: SONAR_URL=${{ secrets.SONAR_HOST_URL }} SONAR_LOGIN=${{ secrets.SONAR_TOKEN }} npm run sonarqube

- name: Sonar Quality Gate
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# node-ts-conventions

[![Quality Gate Status](http://198.211.115.56:9000/api/project_badges/measure?project=node-ts-conventions&metric=alert_status&token=6e973d15010512eca45c3740f9114584c9e39e96)](http://198.211.115.56:9000/dashboard?id=node-ts-conventions)
[![Quality Gate Status](http://198.211.115.56:9000/api/project_badges/measure?project=node-ts-conventions&metric=alert_status&token=6e973d15010512eca45c3740f9114584c9e39e96)](http://198.211.115.56:9000/dashboard?id=node-ts-conventions)
[![Coverage](http://198.211.115.56:9000/api/project_badges/measure?project=node-ts-conventions&metric=coverage&token=6e973d15010512eca45c3740f9114584c9e39e96)](http://198.211.115.56:9000/dashboard?id=node-ts-conventions)
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
transform: {
"^.+\\.ts$": "<rootDir>/node_modules/ts-jest/preprocessor.js",
},
testMatch: ["<rootDir>/tests/**/*.test.ts"],
testMatch: ["**/tests/**/*.test.ts"],
collectCoverage: true,
coverageThreshold: {
global: {
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
"scripts": {
"build": "tsc -p .",
"test": "jest --coverage",
"sonarqube": "npm test && node sonarqube.js",
"start": "ts-node src/index.ts"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0"
},
"devDependencies": {
"@types/jest": "^27.4.0",
"@types/node": "^17.0.16",
"jest": "^21.2.1",
"jest-sonar-reporter": "^2.0.0",
"sonarqube-scanner": "^2.8.1",
Expand Down
24 changes: 24 additions & 0 deletions sonarqube.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const scanner = require("sonarqube-scanner");
const dotenv = require("dotenv");

dotenv.config();

scanner(
{
// this example uses local instance of SQ
serverUrl: process.env.SONAR_URL,
options: {
"sonar.projectKey": "node-ts-conventions",
"sonar.projectVersion": "1.0.0",
"sonar.login": process.env.SONAR_LOGIN,
"sonar.sources": "src",
"sonar.tests": "tests",
"sonar.test.inclusions": "**/*.test.*",
"sonar.typescript.lcov.reportPaths": "coverage/lcov.info",
"sonar.testExecutionReportPaths": "test-report.xml",
"sonar.coverage.exclusions":
"**/*.test.*,**/*.spec.js,**/*.spec.ts,**/*.mock.js,**/*.mock.ts,node_modules/*,coverage/lcov-report/*",
},
},
() => process.exit()
);

0 comments on commit 7ff0dda

Please sign in to comment.