diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d963f8e..534de6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: Next Bulletproof Template CI on: pull_request: branches: [main] + push: + branches: [main] jobs: build-lint-test-lhci: name: Build & Lint @@ -29,12 +31,23 @@ jobs: - name: Build Project run: yarn build - - # commenting for now to make CI green , will try this - # - name: run Lighthouse CI - # run: | - # yarn global add @lhci/cli@0.8.x - # lhci autorun --collect.staticDistDir - + + # commenting for now to make CI green , will try this + # - name: run Lighthouse CI + # run: | + # yarn global add @lhci/cli@0.8.x + # lhci autorun --collect.staticDistDir + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + # commenting for now to make CI green , will try this + # - uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1e53056..b2b9417 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ yarn-error.log* /public/workbox-*.js.map /public/worker-*.js.map /public/fallback-*.js +reports diff --git a/jest.config.js b/jest.config.js index c02bddd..d2fbe33 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,6 +17,18 @@ const jestConfig = { "./themes/**/*.{js,jsx,ts,tsx}", "./utils/**/*.{js,jsx,ts,tsx}", ], + reporters: [ + "default", + [ + "jest-sonar", + { + outputDirectory: "reports", + outputName: "test-report.xml", + relativeRootDir: "./", + reportedFilePath: "relative", + }, + ], + ], moduleNameMapper: { // Handle CSS imports (with CSS modules) // https://jestjs.io/docs/webpack#mocking-css-modules diff --git a/package.json b/package.json index fbd4aff..e61e579 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "husky": "^7.0.4", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "jest-sonar": "^0.2.16", "jest-styled-components": "^7.2.0", "lint-staged": "^12.3.3", "next-router-mock": "^0.9.10", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..b1b751e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,27 @@ +# Project identification +sonar.organization=wednesday-solutions +sonar.projectKey=wednesday-solutions_next-bulletproof-ts_AY6yu6eKB2n8RRmGoUz4 + +# Specify the language +sonar.language=ts + +# Source directory +sonar.sources=. + +# Test directory +sonar.tests=common,containers,features,pages,store,styles,themes,translations,utils + +# Exclude node_modules +# Let's not exclude anything for now, after refractoring changes we can decide what to exclude from the analysis +sonar.exclusions=node_modules/**/* + +sonar.test.inclusions=**/*.test.tsx,**/*.test.js,**/*.test.ts + +# Encoding of the source code +sonar.sourceEncoding=UTF-8 + +# Coverage report path +sonar.javascript.lcov.reportPaths=coverage/lcov.info + +# Test execution report path +sonar.testExecutionReportPaths=./reports/test-report.xml \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f318f87..11b4556 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3782,6 +3782,11 @@ enhanced-resolve@^5.12.0: graceful-fs "^4.2.4" tapable "^2.2.0" +entities@4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.3.0.tgz#62915f08d67353bb4eb67e3d62641a4059aec656" + integrity sha512-/iP1rZrSEJ0DTlPiX+jbzlA3eVkY/e8L8SozroF395fIqE3TYF/Nz7YOMAawta+vLmyJ/hkGNNPcSbMADCCXbg== + entities@^4.4.0: version "4.5.0" resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" @@ -5472,6 +5477,14 @@ jest-snapshot@^29.7.0: pretty-format "^29.7.0" semver "^7.5.3" +jest-sonar@^0.2.16: + version "0.2.16" + resolved "https://registry.yarnpkg.com/jest-sonar/-/jest-sonar-0.2.16.tgz#58d2e150dbcb9a3c781c78ae8fda327ea2439b4c" + integrity sha512-ES6Z9BbIVDELtbz+/b6pv41B2qOfp38cQpoCLqei21FtlkG/GzhyQ0M3egEIM+erpJOkpRKM8Tc8/YQtHdiTXA== + dependencies: + entities "4.3.0" + strip-ansi "6.0.1" + jest-styled-components@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/jest-styled-components/-/jest-styled-components-7.2.0.tgz#67e768b98d3d58513341a62baca76f3e253a4deb" @@ -7715,7 +7728,7 @@ stringify-object@^3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: +strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==