Skip to content

Commit f09023b

Browse files
authored
CCM-7478: Enable Test Coverage Reporting in Sonar (#1007)
* CCM-7478: Remove unnecessary sandbox dependency * CCM-7478: Configure test coverage reporting * CCM-7478: Don't set Node.js path for Sonar * CCM-7478: Make Sonar scan fail if quality gate fails
1 parent 801bb2f commit f09023b

5 files changed

Lines changed: 12 additions & 146 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ jobs:
5757
run: |
5858
cd sandbox
5959
npm run test
60+
cd -
61+
mkdir coverage coverage-temp
62+
TMPDIR="./coverage-temp" npx lcov-result-merger sandbox/coverage/lcov.info coverage/lcov.info --prepend-source-files
63+
rm -r coverage-temp
6064
6165
- name: Check licenses
6266
run: make check-licenses

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env
2525
*.pem
2626
sandbox/coverage
2727
sandbox/.nyc_output
28+
coverage
2829
zap-report/
2930
zap-report.json
3031
zap-report.xml

sandbox/package-lock.json

Lines changed: 0 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sandbox/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"license-checker": "^25.0.1",
2525
"mocha": "^11.7.2",
2626
"mocha-junit-reporter": "^2.2.1",
27-
"mocha-multi": "^1.1.3",
2827
"nodemon": "^3.1.10",
2928
"supertest": "^7.1.4"
3029
}

scripts/config/sonar-scanner.properties

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ sonar.organization=nhsdigital
33
sonar.projectKey=NHSDigital_communications-manager-api
44
sonar.sourceEncoding=UTF-8
55
sonar.language=js,python
6+
sonar.qualitygate.wait=true
67

8+
sonar.sources=.
9+
sonar.tests=tests/, sandbox/__test__
10+
sonar.test.inclusions=tests/**.py, sandbox/__test__/**
711
sonar.exclusions=.venv/**,proxies/utils/performance/*
812

9-
#exclude everything from test coverage, this is covered by other tools
10-
sonar.coverage.exclusions=**/*
11-
#sonar.nodejs.executable=/usr/bin/node
1213
sonar.python.version=3.10.8
1314

15+
# Configure test coverage reporting
16+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
17+
1418
#exclusion rules for our proxy JS - rhinojs 1.7.12 -https://mozilla.github.io/rhino/compat/engines.html
1519
sonar.issue.ignore.multicriteria=optChain,useLet
1620

0 commit comments

Comments
 (0)