Skip to content

Commit

Permalink
Merge pull request #11 from Typeform/TU-13734-Measure-Unit-Test-Coverage
Browse files Browse the repository at this point in the history
[TU-13734] Add SonarCloud configuration
  • Loading branch information
vrybas authored Jul 30, 2024
2 parents ce97776 + 7da43fd commit 656a34f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
42 changes: 41 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
- build-lint-test
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 }}
12 changes: 12 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 656a34f

Please sign in to comment.