diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 880b7cd..f508c8f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,14 @@ jobs: - run: yarn dist - run: yarn lint - - run: yarn test + - run: yarn test --coverage + + - name: Upload coverage file + uses: actions/upload-artifact@v4 + with: + name: coverage + path: ./coverage/lcov.info + retention-days: 1 deploy-preview: runs-on: ubuntu-latest @@ -84,3 +91,36 @@ jobs: GH_TOKEN: ${{ secrets.GH_TOKEN }} JARVIS_NOTIFY_PREVIEW_TEMPLATE: ${{ secrets.JARVIS_NOTIFY_PREVIEW_TEMPLATE }} PUBLIC_CDN_URL: 'https://btn.typeform.com' + + sonarcloud: + name: Test and Code Quality Report (SonarCloud) + needs: + - main + runs-on: ubuntu-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download coverage file + uses: actions/download-artifact@v4 + with: + name: coverage + + - name: Move the coverage file to a proper location + run: | + mkdir -p coverage + mv lcov.info coverage/lcov.info + + - name: Verify coverage file ready + run: ls -lah ./coverage/lcov.info + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@v2 + with: + args: > + -Dsonar.projectVersion=${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..6eda70c --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=Typeform_button +sonar.organization=typeform +sonar.projectVersion=dev + +sonar.sources=src + +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=./coverage/lcov.info