Skip to content

Commit 656a34f

Browse files
authored
Merge pull request #11 from Typeform/TU-13734-Measure-Unit-Test-Coverage
[TU-13734] Add SonarCloud configuration
2 parents ce97776 + 7da43fd commit 656a34f

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.github/workflows/pull-request.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ jobs:
3333

3434
- run: yarn dist
3535
- run: yarn lint
36-
- run: yarn test
36+
- run: yarn test --coverage
37+
38+
- name: Upload coverage file
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: coverage
42+
path: ./coverage/lcov.info
43+
retention-days: 1
3744

3845
deploy-preview:
3946
runs-on: ubuntu-latest
@@ -84,3 +91,36 @@ jobs:
8491
GH_TOKEN: ${{ secrets.GH_TOKEN }}
8592
JARVIS_NOTIFY_PREVIEW_TEMPLATE: ${{ secrets.JARVIS_NOTIFY_PREVIEW_TEMPLATE }}
8693
PUBLIC_CDN_URL: 'https://btn.typeform.com'
94+
95+
sonarcloud:
96+
name: Test and Code Quality Report (SonarCloud)
97+
needs:
98+
- build-lint-test
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Check out Git repository
102+
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
105+
106+
- name: Download coverage file
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: coverage
110+
111+
- name: Move the coverage file to a proper location
112+
run: |
113+
mkdir -p coverage
114+
mv lcov.info coverage/lcov.info
115+
116+
- name: Verify coverage file ready
117+
run: ls -lah ./coverage/lcov.info
118+
119+
- name: SonarCloud Scan
120+
uses: SonarSource/sonarcloud-github-action@v2
121+
with:
122+
args: >
123+
-Dsonar.projectVersion=${{ github.run_id }}
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
126+
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}

sonar-project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sonar.projectKey=Typeform_button
2+
sonar.organization=typeform
3+
sonar.projectVersion=dev
4+
5+
sonar.sources=src
6+
7+
sonar.inclusions=packages/*/src/**/*.ts,src/**/*.js
8+
sonar.exclusions=node_modules/**,dist/**,**/*.spec.ts,**/*.test.ts
9+
10+
sonar.test.exclusions=node_modules/**,dist/**
11+
12+
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

0 commit comments

Comments
 (0)