This repository was archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathcircle.yml
114 lines (107 loc) · 3.81 KB
/
circle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# see orb options at
# https://github.com/cypress-io/circleci-orb
version: 2.1
orbs:
cypress: cypress-io/cypress@1
executors:
latest:
docker:
- image: cypress/browsers:node12.13.0-chrome78-ff70
commands:
save-partial-coverage-report:
description: |
Saves a single possibly partial coverage report by adding it to the
workspace. This way different CircleCI jobs can run parts of the tests
and save their results to be merged later.
parameters:
coverage-filename:
type: string
default: coverage/coverage-final.json
description: |
Path to the final coverage JSON file produced by "nyc" tool.
Typically called "coverage/coverage-final.json"
label:
type: string
default: default
description: |
Human name for the coverage file. For example, when saving both Cypress
and Jest coverage file, use "cypress" and "jest" to have distinct filenames.
steps:
# do not crash if the coverage is not found
# because a particular CI job might not have any tests to run
# producing no coverage.
- run: mkdir coverage-part || true
- run: touch coverage-part/.placeholder || true
# use unique job id to avoid accidentally overwriting coverage file
# and in case the build is parallel, use node index too
- run: cp <<parameters.coverage-filename>> coverage-part/coverage-<<parameters.label>>-$CIRCLE_WORKFLOW_JOB_ID-index-$CIRCLE_NODE_INDEX.json || true
- run: ls -la coverage-part
- persist_to_workspace:
root: ~/
paths:
# note that the current folder is "project"
# so we need to save the full path correctly
# otherwise the files will not be restored in the expected location
- 'project/coverage-part/*'
merge-coverage-reports:
description: |
Merges individual code coverage files using "nyc" tool
https://github.com/istanbuljs/nyc.
All individual files should be in the folder "coverage-part"
steps:
- run: ls -la .
- run: ls -la coverage-part || true
- run: npx nyc merge coverage-part
- run: mkdir .nyc_output || true
# storing the combined report in ".nyc_output/out.json"
# allows other NYC commands to find it right away
- run: mv coverage.json .nyc_output/out.json
- run: ls -la .nyc_output
jobs:
merge-coverage:
description: Merges individual code coverage files and sends combined data to Coveralls.io
executor: cypress/base-10
steps:
- attach_workspace:
at: ~/
- merge-coverage-reports
- run:
name: generate coverage report
command: |
npx nyc report \
--reporter lcov --reporter text-summary \
--report-dir coverage
- store_artifacts:
path: coverage
# send code coverage to coveralls.io
# https://coveralls.io/github/cypress-io/cypress-example-realworld
- run:
command: npm run coveralls || true
workflows:
build:
jobs:
- cypress/install:
executor: latest
pre-steps:
- run: npm config set unsafe-perm true
- cypress/run:
requires:
- cypress/install
executor: latest
parallel: true
parallelism: 2
no-workspace: true
start: npm run start:coverage
wait-on: http://localhost:4100
record: true
post-steps:
- store_artifacts:
path: coverage
# if this machine had no tests to run
# there will be no coverage report
- run: npx nyc report --reporter=text || true
- save-partial-coverage-report:
label: e2e
- merge-coverage:
requires:
- cypress/run