1- # @prettier
2- version : 2
1+ version : 2.1
32
4- who_am_i : &who_am_i
3+ restore_cache : &restore_cache
4+ restore_cache :
5+ key : dependency-cache-{{ checksum "package-lock.json" }}
6+
7+ manage_dependencies : &manage_dependencies
58 run :
6- name : Tell the CI who I am
7- command : |
8- git config --global user.email $GIT_EMAIL
9- git config --global user.name $GIT_USERNAME
9+ name : Install/Manage dependencies
10+ command : npm ci && npx lerna bootstrap
1011
11- install_submodule : &install_submodule
12+ build : &build
1213 run :
13- name : Prepare example repo
14- command : |
15- git submodule sync --recursive
16- git submodule update --init --recursive
14+ name : Build/Compile project
15+ command : npm run build
1716
1817unit_tests : &unit_tests
18+ run :
19+ name : Run unit tests.
20+ command : npm run test:coverage -- --runInBand --silent --ci
21+
22+ tests : &tests
1923 steps :
2024 - checkout
21- - << : *who_am_i
22- - << : *install_submodule
23- - restore_cache :
24- key : dependency-cache-{{ checksum "package-lock.json" }}
25- - run :
26- name : NPM Rebuild
27- command : npm install --quiet
28- - run :
29- name : NPM Build
30- command : npm run build
31- - run :
32- name : Run unit tests.
33- command : npm run ci:test
25+ - << : *restore_cache
26+ - << : *manage_dependencies
27+ - << : *build
28+ - << : *unit_tests
3429
3530jobs :
3631 # region PREPARATION
@@ -39,34 +34,33 @@ jobs:
3934 - image : circleci/node:latest
4035 steps :
4136 - checkout
42- - restore_cache :
43- key : dependency-cache-{{ checksum "package-lock.json" }}
44- - run :
45- name : Install Dependencies
46- command : npm install --quiet
47- - save_cache :
37+ - << : *restore_cache
38+ - run : npm ci --prefer-offline && npx lerna bootstrap
39+ - save_cache : # I hope they supprot globbing/wildcard pattern :cry:
4840 key : dependency-cache-{{ checksum "package-lock.json" }}
4941 paths :
50- - ./node_modules
42+ - ~/.npm
5143 analysis :
5244 docker :
5345 - image : circleci/node:latest
5446 steps :
5547 - checkout
56- - restore_cache :
57- key : dependency-cache-{{ checksum "package-lock.json" }}
58- - run :
59- name : NPM Rebuild
60- command : npm install --quiet
48+ - << : *restore_cache
49+ - << : *manage_dependencies
6150 - run :
6251 name : Run linting.
63- command : npm run ci: lint
52+ command : npm run lint
6453 - run :
65- name : Run NSP Security Check.
66- command : npm audit --quiet || true
54+ name : Run Security Check.
55+ command : npx lerna exec --no-bail -- npm audit --quiet --audit-level high
6756 - run :
68- name : Validate Commit Messages
69- command : npm run ci:lint:commits
57+ name : Found security issue! Check if it's fixable or just have low severity.
58+ command : npx lerna exec --no-bail -- npm audit fix --quiet
59+ when : on_fail
60+ - run :
61+ name : Validate commit messages
62+ command : npx commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}
63+ when : always
7064 # endregion
7165
7266 # region CROSS-BUILD
@@ -75,69 +69,57 @@ jobs:
7569 - image : circleci/node:latest
7670 steps :
7771 - checkout
78- - << : *who_am_i
79- # - <<: *install_submodule
80- - restore_cache :
81- key : dependency-cache-{{ checksum "package-lock.json" }}
82- - run :
83- name : NPM Rebuild
84- command : npm install --quiet
85- - run :
86- name : NPM Build
87- command : npm run build
88- # - run:
89- # name: Run unit tests.
90- # command: npm run ci:coverage
91- # - run:
92- # name: Submit coverage data to codecov.
93- # command: |
94- # if [[ -z $CIRCLE_PULL_REQUEST ]]; then
95- # bash <(curl -s https://codecov.io/bash)
96- # fi
97- # when: on_success
72+ - << : *restore_cache
73+ - << : *manage_dependencies
74+ - << : *build
75+ - << : *unit_tests
76+ - run :
77+ name : Submit coverage data to codecov.
78+ command : |
79+ if [[ -z $CIRCLE_PULL_REQUEST ]]; then
80+ bash <(curl -s https://codecov.io/bash)
81+ fi
82+ when : on_success
9883 node10-latest :
9984 docker :
10085 - image : circleci/node:10
101- << : *unit_tests
86+ << : *tests
87+ node8-latest :
88+ docker :
89+ - image : circleci/node:8
90+ << : *tests
10291 # endregion
10392
104- # region DOCUMENTATION
105- document :
93+ # region RELEASE VERSION
94+ deploy-docs :
10695 docker :
10796 - image : circleci/node:latest
10897 steps :
10998 - checkout
110- - << : *who_am_i
111- - restore_cache :
112- key : dependency-cache-{{ checksum "package-lock.json" }}
113- - run :
114- name : NPM Rebuild
115- command : npm install --quiet
99+ - << : *restore_cache
100+ - << : *manage_dependencies
116101 - run :
117- name : Generate Typedoc documentations
118- command : npm run ci:typedoc
102+ name : Generate documentations
103+ command : npm run predocs
119104 - run :
120- name : Push the documentations to Github gh-pages
121- command : npm run ci:push-docs
122- # endregion
123-
124- # region RELEASE VERSION
105+ name : Push the documentations to Github pages
106+ command : npx gh-pages --dist docs
125107 draft :
126108 docker :
127109 - image : circleci/node:latest
128110 steps :
129111 - checkout
130- - restore_cache :
131- key : dependency-cache-{{ checksum "package-lock.json" }}
132- - run :
133- name : NPM Rebuild
134- command : npm install --quiet
112+ - << : *restore_cache
113+ - << : *manage_dependencies
135114 - run :
136115 name : Validate Commit Messages
137- command : npm run release:validate
116+ command : npx commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)
117+ - run : npm run build && npx lerna exec --no-bail -- npm pack
118+ - run : npm run predocs && tar cvzf docs-$CIRCLE_TAG.tgz docs
138119 - run :
139- name : Draft Releases to Github
140- command : npm run ci:release
120+ name : Draft Github release
121+ # TODO: change to lerna (MAYBE)
122+ command : GH_RELEASE_GITHUB_API_TOKEN=$GH_TOKEN npx gh-release --draft --assets $(ls -m packages/*/*.tgz | tr -d ' ') --yes
141123 publish :
142124 docker :
143125 - image : circleci/node:latest
@@ -146,14 +128,9 @@ jobs:
146128 - run :
147129 name : set npm TOKEN
148130 command : echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
149- - restore_cache :
150- key : dependency-cache-{{ checksum "package-lock.json" }}
151- - run :
152- name : NPM Rebuild
153- command : npm install --quiet
154- - run :
155- name : Publish to NPM
156- command : npm publish --verbose
131+ - << : *restore_cache
132+ - << : *manage_dependencies
133+ - run : npx lerna publish from-git --no-git-reset --yes
157134 # endregion
158135
159136workflows :
@@ -163,6 +140,8 @@ workflows:
163140 # region PREPARATION
164141 - dependency_cache :
165142 filters :
143+ branches :
144+ ignore : gh-pages
166145 tags :
167146 only : /.*/
168147 - analysis :
@@ -180,49 +159,50 @@ workflows:
180159 filters :
181160 tags :
182161 only : /.*/
183- # - node10-latest:
184- # requires:
185- # - analysis
186- # # - node6-latest
187- # filters:
188- # tags:
189- # only: /.*/
162+ - node8-latest :
163+ requires :
164+ - analysis
165+ filters :
166+ tags :
167+ only : /.*/
168+ - node10-latest :
169+ requires :
170+ - analysis
171+ filters :
172+ tags :
173+ only : /.*/
190174 # endregion
191175
192- # region DOCUMENTATION [just temporary test]
193- # - document:
194- # requires:
195- # - node-latest
196- # # - node10-latest
197- # filters:
198- # tags:
199- # only: /^v\d+[.]\d+[.]\d+$/
200- # branches:
201- # ignore: /.*/
202- # endregion
203176
204177 # region RELEASE VERSION
205178 - draft :
206179 requires :
207180 - node-latest
208181 - analysis
209- # - node10-latest
210182 filters :
211183 tags :
212- only : /^v\d+[.]\d+[.]\d+$/
184+ only : /^v\d+[.]\d+[.]\d+(-\d+|-\w+|)$/
185+ branches :
186+ ignore : /.*/
187+ - deploy-docs :
188+ requires :
189+ - publish package?
190+ filters :
191+ tags :
192+ only : /^v\d+[.]\d+[.]\d+$/ # don't support pre-release
213193 branches :
214194 ignore : /.*/
215- - check github Releases! :
195+ - publish package? :
216196 type : approval
217197 requires :
218198 - draft
219199 filters :
220200 tags :
221- only : /^v\d+[.]\d+[.]\d+$/
201+ only : /^v\d+[.]\d+[.]\d+(-\d+|-\w+|) $/
222202 - publish :
223203 requires :
224- - check github Releases!
204+ - publish package?
225205 filters :
226206 tags :
227- only : /^v\d+[.]\d+[.]\d+$/
207+ only : /^v\d+[.]\d+[.]\d+(-\d+|-\w+|) $/
228208 # endregion
0 commit comments