Skip to content

Commit 3309e44

Browse files
committed
ci(circleci): improve workflow and add linting
1 parent 7853ec2 commit 3309e44

File tree

1 file changed

+61
-56
lines changed

1 file changed

+61
-56
lines changed

.circleci/config.yml

+61-56
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
version: 2
22

33
aliases:
4+
- &repo_path
5+
~/ui-theme
46
- &defaults
5-
working_directory: ~/ui-theme
6-
- &node11_executor
7+
working_directory: *repo_path
8+
- &node_latest_executor
79
docker:
8-
- image: circleci/node:11.10.1
9-
- &node8_executor
10+
- image: circleci/node:latest
11+
- &node_lts_executor
1012
docker:
11-
- image: circleci/node:8
12-
- &node10_executor
13+
- image: circleci/node:lts
14+
- &node_8_executor
1315
docker:
14-
- image: circleci/node:10
16+
- image: circleci/node:8
1517
- &default_executor
16-
<<: *node10_executor
17-
- &repo_key
18-
repo-{{ .Branch }}-{{ .Revision }}
19-
- &coverage_key
20-
coverage-{{ .Branch }}-{{ .Revision }}
21-
- &base_config_key
22-
base-config-{{ .Branch }}-{{ .Revision }}
18+
<<: *node_latest_executor
2319
- &yarn_cache_key
2420
yarn-sha-{{ checksum "yarn.lock" }}
21+
- &coverage_key
22+
coverage-{{ .Branch }}-{{ .Revision }}
2523
- &restore_repo
26-
restore_cache:
27-
keys:
28-
- *repo_key
24+
attach_workspace:
25+
at: *repo_path
2926
- &ignore_non_dev_branches
3027
filters:
3128
tags:
@@ -36,7 +33,7 @@ aliases:
3633
- &execute_on_release
3734
filters:
3835
tags:
39-
only: /(v)?[0-9]+(\.[0-9]+)*/
36+
only: /v?[0-9]+(\.[0-9]+)*([-+\.][a-zA-Z0-9]+)*/
4037
branches:
4138
ignore:
4239
- /.*/
@@ -48,21 +45,11 @@ jobs:
4845
steps:
4946
- *restore_repo
5047
- checkout
51-
- restore_cache:
52-
key: *base_config_key
53-
- run:
54-
name: 'Base environment setup'
55-
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
56-
- save_cache:
57-
key: *base_config_key
58-
paths:
59-
- ~/.npmrc
60-
- ~/.gitconfig
6148
- restore_cache:
6249
key: *yarn_cache_key
6350
- run:
64-
name: Install Js dependencies
65-
command: yarn install --no-progress --registry https://registry.verdaccio.org --no-lockfile
51+
name: Install dependencies
52+
command: yarn install --frozen-lockfile
6653
- run:
6754
name: Build project
6855
command: yarn run build
@@ -72,10 +59,20 @@ jobs:
7259
- ~/.yarn
7360
- ~/.cache/yarn
7461
- node_modules
75-
- save_cache:
76-
key: *repo_key
62+
- persist_to_workspace:
63+
root: *repo_path
7764
paths:
78-
- ~/ui-theme
65+
- ./*
66+
67+
lint:
68+
<<: *defaults
69+
<<: *default_executor
70+
steps:
71+
- *restore_repo
72+
- run:
73+
name: Lint code
74+
command: yarn lint
75+
7976
test_bundlesize:
8077
<<: *defaults
8178
<<: *default_executor
@@ -85,36 +82,36 @@ jobs:
8582
name: Test BundleSize
8683
command: yarn test:size
8784

88-
test_node11:
85+
test_node_latest:
8986
<<: *defaults
90-
<<: *node11_executor
87+
<<: *node_latest_executor
9188
steps:
9289
- *restore_repo
9390
- run:
94-
name: Test with Node 11
91+
name: Test with Node (Latest)
9592
command: yarn test
93+
- save_cache:
94+
key: *coverage_key
95+
paths:
96+
- coverage
9697

97-
test_node8:
98+
test_node_lts:
9899
<<: *defaults
99-
<<: *node8_executor
100+
<<: *node_lts_executor
100101
steps:
101102
- *restore_repo
102103
- run:
103-
name: Test with Node 8
104+
name: Test with Node (LTS)
104105
command: yarn test
105106

106-
test_node10:
107+
test_node_8:
107108
<<: *defaults
108-
<<: *node10_executor
109+
<<: *node_8_executor
109110
steps:
110111
- *restore_repo
111112
- run:
112-
name: Test with Node 10
113+
name: Test with Node (8)
113114
command: yarn run test
114-
- save_cache:
115-
key: *coverage_key
116-
paths:
117-
- coverage
118115

119116
coverage:
120117
<<: *defaults
@@ -140,8 +137,9 @@ jobs:
140137
<<: *default_executor
141138
steps:
142139
- *restore_repo
143-
- restore_cache:
144-
key: *base_config_key
140+
- run:
141+
name: 'Setup publish credentials'
142+
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
145143
- run:
146144
name: Publish
147145
command: yarn publish
@@ -152,29 +150,36 @@ workflows:
152150
jobs:
153151
- prepare:
154152
<<: *ignore_non_dev_branches
155-
- test_node11:
153+
- lint:
156154
requires:
157155
- prepare
158156
<<: *ignore_non_dev_branches
159-
- test_node8:
157+
- test_bundlesize:
160158
requires:
161159
- prepare
162160
<<: *ignore_non_dev_branches
163-
- test_node10:
161+
- test_node_latest:
164162
requires:
165163
- prepare
166164
<<: *ignore_non_dev_branches
167-
- test_bundlesize:
165+
- test_node_lts:
168166
requires:
169-
- test_node11
170-
- test_node8
171-
- test_node10
167+
- prepare
168+
<<: *ignore_non_dev_branches
169+
- test_node_8:
170+
requires:
171+
- prepare
172172
<<: *ignore_non_dev_branches
173173
- coverage:
174174
requires:
175-
- test_bundlesize
175+
- test_node_latest
176176
<<: *ignore_non_dev_branches
177177
- publish_package:
178178
requires:
179+
- lint
180+
- test_bundlesize
181+
- test_node_latest
182+
- test_node_lts
183+
- test_node_8
179184
- coverage
180185
<<: *execute_on_release

0 commit comments

Comments
 (0)