Skip to content

Commit 1abd90d

Browse files
authored
DGS-16859: Enable SonarQube code coverage reporting (#226)
1 parent f62e379 commit 1abd90d

File tree

9 files changed

+3183
-1156
lines changed

9 files changed

+3183
-1156
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ deps/*
1717
.idea
1818
.vscode
1919
coverage
20+
21+
.nyc_output/
22+
*lcov.info
23+
**/lcov-report

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ deps/librdkafka/config.h
1717
/bench
1818
/ci
1919
/proto
20-
/docs
20+
/docs
21+
22+
.nyc_output/
23+
*lcov.info
24+
**/lcov-report

.semaphore/semaphore.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ blocks:
101101
- name: "Test"
102102
commands:
103103
- make test
104+
- artifact push workflow coverage/mocha/coverage-final.json --destination "mocha-coverage.json"
104105
- name: "Promisified Tests"
105106
commands:
106107
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
107108
- docker compose up -d && sleep 30
108109
- export NODE_OPTIONS='--max-old-space-size=1536'
109110
- npx jest --no-colors --ci test/promisified/
111+
- artifact push workflow coverage/jest/coverage-final.json --destination "jest-coverage.json"
110112
- name: "Lint"
111113
commands:
112114
- make lint
@@ -447,4 +449,20 @@ blocks:
447449
commands:
448450
- artifact pull workflow releases
449451
- tar -czvf releases.${SEMAPHORE_GIT_TAG_NAME}.tar.gz releases
450-
- artifact push project "releases.${SEMAPHORE_GIT_TAG_NAME}.tar.gz" --destination "releases/${SEMAPHORE_GIT_TAG_NAME}/releases.${SEMAPHORE_GIT_TAG_NAME}.tar.gz"
452+
- artifact push project "releases.${SEMAPHORE_GIT_TAG_NAME}.tar.gz" --destination "releases/${SEMAPHORE_GIT_TAG_NAME}/releases.${SEMAPHORE_GIT_TAG_NAME}.tar.gz"
453+
454+
after_pipeline:
455+
task:
456+
agent:
457+
machine:
458+
type: s1-prod-ubuntu20-04-amd64-1
459+
jobs:
460+
- name: SonarQube
461+
commands:
462+
- checkout
463+
- sem-version java 11
464+
- artifact pull workflow mocha-coverage.json
465+
- artifact pull workflow jest-coverage.json
466+
- npx --yes istanbul-merge --out merged-output/merged-coverage.json *-coverage.json
467+
- npx nyc report -t merged-output --report-dir coverage --reporter=text --reporter=lcov
468+
- emit-sonarqube-data --run_only_sonar_scan

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $(CONFIG_OUTPUTS): node_modules/.dirstamp binding.gyp
5151
@$(NODE-GYP) configure
5252

5353
test: node_modules/.dirstamp
54-
@./node_modules/.bin/mocha --ui exports $(TEST_REPORTER) $(TESTS) $(TEST_OUTPUT)
54+
@./node_modules/.bin/nyc --reporter=text --reporter=json --reporter=html --report-dir=coverage/mocha ./node_modules/.bin/mocha --ui exports $(TEST_REPORTER) $(TESTS) $(TEST_OUTPUT)
5555

5656
promisified_test: node_modules/.dirstamp
5757
@./node_modules/.bin/jest --ci --runInBand $(PROMISIFIED_TESTS)
@@ -81,4 +81,4 @@ release-patch:
8181

8282
clean: node_modules/.dirstamp
8383
@rm -f deps/librdkafka/config.h
84-
@$(NODE-GYP) clean
84+
@$(NODE-GYP) clean

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ module.exports = {
22
transform: {
33
'^.+\\.tsx?$': 'ts-jest',
44
},
5+
"collectCoverage": true,
6+
"coverageReporters": ['json', 'text', 'html'],
7+
"coverageDirectory": 'coverage/jest/',
58
};

0 commit comments

Comments
 (0)