Skip to content

Commit c5b902f

Browse files
authored
Add coverage parallelization (Synthetixio#1275)
* remove definition of NODE_OPTIONS form ci config as is already defined on package.json * add coverage reports parallelization and upload it to codecov * remove istanbul-combine for coverage merging let codecov to take care of merging the reports
1 parent aeb11d9 commit c5b902f

File tree

5 files changed

+72
-4
lines changed

5 files changed

+72
-4
lines changed

.circleci/config.yml

+38-2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ jobs:
210210
- store_artifacts:
211211
path: test/publish/test-log.html
212212
destination: test-log.html
213+
job-unit-tests-coverage-report:
214+
working_directory: ~/repo
215+
docker:
216+
- image: synthetixio/docker-node:14.16-focal
217+
auth:
218+
username: $DOCKERHUB_USERNAME
219+
password: $DOCKERHUB_TOKEN
220+
steps:
221+
- checkout
222+
- attach_workspace:
223+
at: /tmp/coverage
224+
- run:
225+
name: Upload coverage
226+
command: |
227+
cp -R /tmp/coverage/coverage-*.json .
228+
bash <(curl -s https://codecov.io/bash)
213229
job-unit-tests-coverage:
214230
working_directory: ~/repo
215231
docker:
@@ -218,12 +234,28 @@ jobs:
218234
username: $DOCKERHUB_USERNAME
219235
password: $DOCKERHUB_TOKEN
220236
resource_class: large
237+
parallelism: 8
221238
steps:
222239
- checkout
223240
- attach_workspace:
224241
at: .
225-
- run: NODE_OPTIONS=--max_old_space_size=4096 npm run coverage
226-
- run: bash <(curl -s https://codecov.io/bash)
242+
- run:
243+
name: Create shared coverage outputs folder
244+
command: mkdir -p /tmp/coverage
245+
- run:
246+
name: Coverage
247+
command: |
248+
TEST_FILES="{$(circleci tests glob "test/contracts/*.js" | \
249+
circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}"
250+
npm run coverage -- --testfiles "$TEST_FILES"
251+
- run:
252+
name: Save coverage
253+
command: |
254+
cp coverage.json /tmp/coverage/coverage-$CIRCLE_NODE_INDEX.json
255+
- persist_to_workspace:
256+
root: /tmp/coverage
257+
paths:
258+
- coverage-*.json
227259
job-unit-tests-gas-report:
228260
working_directory: ~/repo
229261
docker:
@@ -311,6 +343,10 @@ workflows:
311343
- job-unit-tests-coverage:
312344
requires:
313345
- job-prepare
346+
- job-unit-tests-coverage-report:
347+
requires:
348+
- job-prepare
349+
- job-unit-tests-coverage
314350
- job-unit-tests-gas-report:
315351
requires:
316352
- job-prepare
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Measures unit and spec test coverage
2+
{{> job-header.yml}}
3+
steps:
4+
- checkout
5+
- attach_workspace:
6+
at: /tmp/coverage
7+
- run:
8+
name: Upload coverage
9+
command: |
10+
cp -R /tmp/coverage/coverage-*.json .
11+
bash <(curl -s https://codecov.io/bash)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
# Measures unit and spec test coverage
22
{{> job-header.yml}}
33
resource_class: large
4+
parallelism: 8
45
steps:
56
- checkout
67
- attach_workspace:
78
at: .
8-
- run: NODE_OPTIONS=--max_old_space_size=4096 npm run coverage
9-
- run: bash <(curl -s https://codecov.io/bash)
9+
- run:
10+
name: Create shared coverage outputs folder
11+
command: mkdir -p /tmp/coverage
12+
- run:
13+
name: Coverage
14+
command: |
15+
TEST_FILES="{$(circleci tests glob "test/contracts/*.js" | \
16+
circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}"
17+
npm run coverage -- --testfiles "$TEST_FILES"
18+
- run:
19+
name: Save coverage
20+
command: |
21+
cp coverage.json /tmp/coverage/coverage-$CIRCLE_NODE_INDEX.json
22+
- persist_to_workspace:
23+
root: /tmp/coverage
24+
paths:
25+
- coverage-*.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requires:
2+
- job-prepare
3+
- job-unit-tests-coverage

.circleci/src/workflows/workflow-all.yml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
{{> require-prepare.yml}}
1818
- job-unit-tests-coverage:
1919
{{> require-prepare.yml}}
20+
- job-unit-tests-coverage-report:
21+
{{> require-unit-tests-coverage.yml}}
2022
- job-unit-tests-gas-report:
2123
{{> require-prepare.yml}}
2224
- job-test-deploy-script:

0 commit comments

Comments
 (0)