Skip to content

Commit 83227f1

Browse files
committed
[TU-13737] Add SonarCloud test coverage configuration
1 parent ef1c507 commit 83227f1

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

.github/workflows/pr.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,45 @@ jobs:
4444
run: yarn lint
4545

4646
- name: Unit tests
47-
run: yarn test:unit
47+
run: yarn test:unit --coverage
4848

4949
- name: Integration tests
50-
run: (yarn server &) && sleep 1 && yarn test:integration
50+
run: (yarn server &) && sleep 1 && yarn test:integration --coverage
51+
52+
- name: Merge coverage reports and generate lcov.info
53+
run: npx nyc merge ./coverage && npx nyc report --reporter=lcov
54+
55+
- name: Upload coverage file
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: coverage-report
59+
path: ./coverage/lcov.info
60+
retention-days: 1
61+
62+
sonarcloud:
63+
name: Test and Code Quality Report (SonarCloud)
64+
needs:
65+
- build-lint-test
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Check out Git repository
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Download coverage file
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: coverage-report
77+
78+
- name: Verify coverage file download
79+
run: find . | grep lcov.info
80+
81+
- name: SonarCloud Scan
82+
uses: SonarSource/sonarcloud-github-action@v2
83+
with:
84+
args: >
85+
-Dsonar.projectVersion=${{ github.run_id }}
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
88+
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}

sonar-project.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sonar.projectKey=Typeform_js-api-client
2+
sonar.organization=typeform
3+
sonar.projectVersion=dev
4+
5+
# Define the main source and test directories
6+
sonar.sources=src
7+
sonar.tests=tests
8+
9+
# Exclude specific files or directories from analysis
10+
sonar.exclusions=node_modules/**,dist/**,**/*.spec.ts,**/*.test.ts
11+
sonar.test.exclusions=node_modules/**,dist/**
12+
13+
# Specify the location of the coverage report
14+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
15+
16+
# Additional configurations for TypeScript if needed
17+
sonar.typescript.lcov.reportPaths=coverage/lcov.info
18+
sonar.test.inclusions=**/*.spec.ts,**/*.test.ts

0 commit comments

Comments
 (0)