From 25aa69b154f559d342235356ff5a85bcc283647f Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel <51385738+EduardoGurgel@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:58:59 -0300 Subject: [PATCH 1/3] =?UTF-8?q?Atualizando=20configura=C3=A7=C3=B5es=20do?= =?UTF-8?q?=20Sonar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sonar-project.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index c14a608..6dafb92 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,15 +4,15 @@ sonar.organization=fga-eps-mds-1 sonar.projectName=2023-2-GEROcuidado-APIUsuario sonar.host.url=https://sonarcloud.io -sonar.language=ts sonar.sourceEncoding=UTF-8 sonar.python.version=3 -sonar.sources=./src -sonar.inclusions=** -sonar.exclusions=**/main.ts,**/ormconfig.ts,**/*.module.ts,src/migration/*.ts,src/migrations.ts,**/*.spec.ts +sonar.sources=src +sonar.exclusions=**/main.ts,**/ormconfig.ts,**/*.module.ts,src/migration/*.ts,src/migrations.ts -sonar.javascript.lcov.reportPaths=./coverage/unit/lcov.info -sonar.dynamicAnalysis=reuseReports -sonar.core.codeCoveragePlugin=cobertura +sonar.javascript.lcov.reportPaths=coverage/unit/lcov.info + +sonar.tests=src +sonar.test.inclusions=**/*.spec.ts +sonar.testExecutionReportPaths=reports/sonar-report.xml From 08e2e164aec35ddf6a6501df2809c338e11f9e61 Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel <51385738+EduardoGurgel@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:59:49 -0300 Subject: [PATCH 2/3] Atualizando build --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5fa8a17..d868b01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,8 @@ name: Build on: push: branches: - - main + - develop + - release-sonar pull_request: types: [opened, synchronize, reopened] jobs: From 25c2259761304262106c07c03de0ace4627781e2 Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel <51385738+EduardoGurgel@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:00:33 -0300 Subject: [PATCH 3/3] =?UTF-8?q?Atualizando=20package.json=20para=20configu?= =?UTF-8?q?ra=C3=A7=C3=B5es=20adaptadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7e2940b..e3fee56 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "start:debug": "nest start --debug 0.0.0.0:7001 --watch --preserveWatchOutput", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest --no-cache --colors --detectOpenHandles", + "test:all": "CI=true npm run test -- --coverage", + "test": "jest --passWithNoTests --no-cache --runInBand --detectOpenHandles --coverage --colors", "test:watch": "jest --watchAll", "test:cov": "jest --runInBand --coverage --colors", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", @@ -27,6 +28,7 @@ "typeorm:migrate": "npm run typeorm migration:generate -- -d src/ormconfig.ts", "typeorm:run": "./node_modules/.bin/typeorm-ts-node-commonjs migration:run -d src/ormconfig.ts", "schema:drop": "npm run typeorm schema:drop", + "sonar": "sonar-scanner", "schema:sync": "npm run typeorm schema:sync" }, "dependencies": { @@ -54,6 +56,7 @@ "dotenv": "10.0.0", "express-actuator": "1.8.2", "helmet": "6.0.0", + "jest-sonar-reporter": "^2.0.0", "passport": "0.5.2", "passport-jwt": "4.0.0", "passport-local": "1.0.0", @@ -76,7 +79,7 @@ "@types/cors": "2.8.12", "@types/express": "4.17.13", "@types/express-actuator": "1.8.0", - "@types/jest": "27.0.2", + "@types/jest": "^29.5.6", "@types/node": "18.17.0", "@types/passport-jwt": "3.0.6", "@types/passport-local": "1.0.34", @@ -88,12 +91,14 @@ "eslint-config-prettier": "8.4.0", "eslint-plugin-prettier": "4.0.0", "graphql": "16.6.0", - "jest": "27.5.1", + "jest": "^29.2.1", + "jest-mock-extended": "^3.0.5", + "jest-sonar": "^0.2.16", "prettier": "2.5.1", "sonarqube-scanner": "2.8.1", "source-map-support": "0.5.21", "supertest": "6.2.2", - "ts-jest": "27.1.3", + "ts-jest": "^29.1.1", "ts-loader": "9.2.7", "ts-node": "10.6.0", "tsconfig-paths": "3.12.0", @@ -115,9 +120,21 @@ "transform": { "^.+\\.(t|j)s$": "ts-jest" }, + "collectCoverage": true, "collectCoverageFrom": [ "**/*.(t|j)s" ], + "reporters": [ + "default", + [ + "jest-sonar", + { + "outputDirectory": "reports", + "outputName": "sonar-report.xml", + "relativeRootDir": "." + } + ] + ], "coverageDirectory": "../coverage/unit", "coveragePathIgnorePatterns": [ "src/migration",