From 4c9aea13a526561886e4a718517ea462d07f0143 Mon Sep 17 00:00:00 2001 From: Vladimir Rybas Date: Wed, 14 Aug 2024 11:40:35 +0200 Subject: [PATCH] [TU-13733] Add SonarCloud configuration (#659) --- .github/workflows/pull-request.yml | 18 ++++++++++++++++-- package.json | 1 + packages/embed-react/package.json | 2 +- packages/embed/package.json | 2 +- sonar-project.properties | 12 ++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7e4109fe..a0fa3029 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -12,7 +12,7 @@ jobs: node_version: - 18 # end of life 2025-04-30 - 20 # end of life 2026-04-30 - - 22 # end of life 2027-04-03 + - 22 # end of life 2027-04-03 # please update SonarCloud below when there is new latest node version name: build-lint-test - node ${{ matrix.node_version }} steps: - name: Check out Git repository @@ -39,7 +39,21 @@ jobs: - run: yarn build - run: yarn lint - - run: yarn test + - run: yarn test:coverage + + - name: Verify coverage file ready + run: find . | grep coverage + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@v2 + if: ${{ matrix.node_version == '22' }} + with: + args: > + -Dsonar.projectVersion=${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} + functional: runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 5e34b7e3..5132a78d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "build": "yarn lerna run build", "lint": "yarn lerna run lint && yarn docs-prettier-check", "test": "yarn lerna run test", + "test:coverage": "yarn lerna run test:coverage", "test:functional": "yarn lerna run test:functional", "test:visual": "yarn lerna run test:visual", "release": "sh ./scripts/release.sh", diff --git a/packages/embed-react/package.json b/packages/embed-react/package.json index 443a7662..6f442fd8 100644 --- a/packages/embed-react/package.json +++ b/packages/embed-react/package.json @@ -17,7 +17,7 @@ "demo-nextjs": "cd ../demo-nextjs && yarn start", "demo": "yarn concurrently 'yarn dev' 'yarn demo-nextjs'", "test": "jest", - "coverage": "jest --coverage", + "test:coverage": "jest --coverage", "lint": "eslint src --ext .js,.ts,.jsx,.tsx --max-warnings=0", "release": "npm config set @typeform:registry https://registry.npmjs.org/ && yarn semantic-release", "post-release": "yarn release:github", diff --git a/packages/embed/package.json b/packages/embed/package.json index 1e60871c..3dff8e7c 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -41,7 +41,7 @@ "prettier-check": "prettier --check . --ignore-path .eslintignore", "prettier": "prettier --write . --ignore-path .eslintignore", "test": "jest", - "coverage": "jest --coverage", + "test:coverage": "jest --coverage", "cy:open": "yarn cypress open", "cy:open:vrt": "yarn cypress open --env testType=visual", "cy:open:func": "yarn cy:open -c e2e.specPattern=./e2e/spec/functional/", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..69c84aae --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=Typeform_embed +sonar.organization=typeform +sonar.projectVersion=dev + +sonar.sources=packages + +sonar.inclusions=packages/*/src/**/*.ts,src/**/*.js +sonar.exclusions=node_modules/**,dist/**,**/*.spec.ts,**/*.test.ts + +sonar.test.exclusions=node_modules/**,dist/** + +sonar.javascript.lcov.reportPaths=packages/**/coverage/lcov.info