Skip to content

Commit c6a0530

Browse files
committed
Add CI & Coverage
1 parent b15b42b commit c6a0530

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

.circleci/config.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
version: 2
2+
3+
jobs:
4+
checkout_code:
5+
working_directory: ~/repo
6+
docker:
7+
- image: circleci/node:6.17.0
8+
steps:
9+
- checkout
10+
- save_cache:
11+
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
12+
paths:
13+
- ~/repo
14+
15+
install_deps:
16+
working_directory: ~/repo
17+
docker:
18+
- image: circleci/node:6.17.0
19+
steps:
20+
- restore_cache:
21+
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
22+
- restore_cache:
23+
key: dependency-cache-{{ checksum "yarn.lock" }}
24+
- run: yarn install
25+
- save_cache:
26+
key: dependency-cache-{{ checksum "yarn.lock" }}
27+
paths:
28+
- node_modules
29+
30+
run_test:
31+
working_directory: ~/repo
32+
docker:
33+
- image: circleci/node:6.17.0
34+
environment:
35+
JEST_JUNIT_OUTPUT: reports/jest/summary.xml
36+
steps:
37+
- restore_cache:
38+
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
39+
- restore_cache:
40+
key: dependency-cache-{{ checksum "yarn.lock" }}
41+
- run: yarn test
42+
- save_cache:
43+
key: coverage-cache-{{ .Environment.CIRCLE_SHA1 }}
44+
paths:
45+
- coverage
46+
- store_test_results:
47+
path: reports
48+
49+
coverage:
50+
working_directory: ~/repo
51+
docker:
52+
- image: circleci/node:6.17.0
53+
steps:
54+
- restore_cache:
55+
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
56+
- restore_cache:
57+
key: dependency-cache-{{ checksum "yarn.lock" }}
58+
- restore_cache:
59+
key: coverage-cache-{{ .Environment.CIRCLE_SHA1 }}
60+
- run: yarn codecov
61+
62+
63+
workflows:
64+
version: 2
65+
build-and-test:
66+
jobs:
67+
- checkout_code
68+
- install_deps:
69+
requires:
70+
- checkout_code
71+
- run_test:
72+
requires:
73+
- install_deps
74+
- coverage:
75+
requires:
76+
- run_test

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ if (typeof obj.a.b().c[1].d()[unwrap] === 'number') {
1919
// do something here
2020
}
2121

22-
// fallback to default value
22+
// Easier to set default value
2323
const name = obj.getUsers().list[0].name[unwrap] || ''
2424
```

codecov.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
range: 85..100
6+
round: down
7+
precision: 2
8+
9+
parsers:
10+
javascript:
11+
enable_partials: yes

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"scripts": {
1313
"build": "rm -fr ./dist && tsc",
14+
"codecov": "codecov -s coverage",
1415
"show:coverage": "open ./coverage/lcov-report/index.html",
1516
"test": "jest --runInBand"
1617
},

0 commit comments

Comments
 (0)