Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 377f1df

Browse files
authored
reporting test coverage to code climate (#45)
1 parent 3720cc6 commit 377f1df

1 file changed

Lines changed: 67 additions & 3 deletions

File tree

.circleci/config.yml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,33 @@ jobs:
4545
paths:
4646
- dist/
4747

48+
test_pre:
49+
<<: *defaults
50+
steps:
51+
- attach_workspace:
52+
at: .
53+
- run:
54+
name: Download cc-test-reporter
55+
command: |
56+
mkdir -p tmp/
57+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
58+
chmod +x ./tmp/cc-test-reporter
59+
- persist_to_workspace:
60+
root: .
61+
paths:
62+
- tmp/cc-test-reporter
63+
64+
test_post:
65+
<<: *defaults
66+
steps:
67+
- attach_workspace:
68+
at: .
69+
- run:
70+
name: Upload coverage results to Code Climate
71+
command: |
72+
tmp/cc-test-reporter sum-coverage tmp/coverage/codeclimate.*.json -p 1 -o tmp/coverage/codeclimate.total.json
73+
CC_TEST_REPORTER_ID=$CODE_CLIMATE_REPORTER_ID tmp/cc-test-reporter upload-coverage -i tmp/coverage/codeclimate.total.json
74+
4875
test_unit:
4976
<<: *defaults
5077
steps:
@@ -53,7 +80,14 @@ jobs:
5380
at: .
5481
- run:
5582
name: Unit Tests
56-
command: npm run test:unit:coverage
83+
command: |
84+
npm run test:unit:coverage
85+
- run:
86+
name: Code Climate Coverage
87+
command: |
88+
ls
89+
ls tmp/
90+
tmp/cc-test-reporter format-coverage -t lcov -o tmp/coverage/codeclimate.unit.json tests/reports/unit/coverage/lcov.info
5791
- store_artifacts:
5892
path: tests/reports/unit/junit.xml
5993
prefix: tests
@@ -62,6 +96,10 @@ jobs:
6296
prefix: coverage
6397
- store_test_results:
6498
path: tests/reports/unit
99+
- persist_to_workspace:
100+
root: .
101+
paths:
102+
- tmp/coverage
65103
# - run:
66104
# name: Coveralls
67105
# command: export COVERALLS_GIT_COMMIT=$CIRCLE_SHA1 && npm run coveralls < tests/reports/unit/coverage/lcov.info
@@ -102,15 +140,23 @@ workflows:
102140
- lint:
103141
requires:
104142
- dependencies
105-
- test_unit:
143+
- build:
106144
requires:
107145
- lint
108-
- build:
146+
- test_pre
147+
- test_unit:
109148
requires:
110149
- lint
150+
- test_pre
151+
111152
- test_int:
112153
requires:
113154
- build
155+
- test_pre
156+
- test_post:
157+
requires:
158+
- test_unit
159+
- test_int
114160

115161
release:
116162
jobs:
@@ -128,9 +174,16 @@ workflows:
128174
only: /^v.*/
129175
branches:
130176
ignore: /.*/
177+
- test_pre:
178+
filters:
179+
tags:
180+
only: /^v.*/
181+
branches:
182+
ignore: /.*/
131183
- test_unit:
132184
requires:
133185
- lint
186+
- test_pre
134187
filters:
135188
tags:
136189
only: /^v.*/
@@ -147,6 +200,16 @@ workflows:
147200
- test_int:
148201
requires:
149202
- build
203+
- test_pre
204+
filters:
205+
tags:
206+
only: /^v.*/
207+
branches:
208+
ignore: /.*/
209+
- test_post:
210+
requires:
211+
- test_unit
212+
- test_int
150213
filters:
151214
tags:
152215
only: /^v.*/
@@ -156,6 +219,7 @@ workflows:
156219
requires:
157220
- test_unit
158221
- test_int
222+
- build
159223
filters:
160224
tags:
161225
only: /^v.*/

0 commit comments

Comments
 (0)