-
Notifications
You must be signed in to change notification settings - Fork 86
/
config.yml
202 lines (173 loc) · 4.89 KB
/
config.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
version: 2.1
# --- YAML Aliases ----------------------------------------------------------- #
aliases: [
# List of dependency paths that should be persisted to the
# CircleCI workspace.
&dependency-paths [
"node_modules",
"packages/@magic-sdk/*/node_modules",
"packages/*/node_modules",
],
# List of Yarn cache paths that should be persisted to the
# CircleCI workspace cache.
&yarn-cache-paths [
".yarn/cache",
".yarn/unplugged",
],
# List of build output paths that should be persisted to the
# CircleCI workspace.
&build-output-paths [
"packages/@magic-sdk/*/dist",
"packages/*/dist",
],
# Yarn lockfile cache key (update "vN" => "vN+1" to cache-bust).
&dependency-cache-key "v3-dependency-cache-{{ checksum \"yarn.lock\" }}",
&workspace-root "/home/circleci/project",
&attach-workspace {
attach_workspace: {
at: *workspace-root
}
},
# Filter pull requests not in "master" or "next" (development code)
&filter-default-branches {
filters: {
branches: {
ignore: "/^master$|^next$/"
}
}
},
# Filter pull requests in "master" only (production code).
&filter-release-branches-only {
filters: {
branches: {
only: [
"master",
"next",
]
}
}
},
]
# --- Executor definitions --------------------------------------------------- #
executors:
default:
docker:
- image: circleci/node:14.17.0-browsers
resource_class: medium
# --- Job definitions -------------------------------------------------------- #
jobs:
# Installs Node dependencies via NPM, caches them, then persists
# to the workspace.
install-dependencies:
executor: default
steps:
- checkout
- *attach-workspace
- restore_cache:
key: *dependency-cache-key
- run:
name: Install Module Dependencies
command: yarn install
- save_cache:
paths: *yarn-cache-paths
key: *dependency-cache-key
- persist_to_workspace:
paths: *dependency-paths
root: *workspace-root
# Runs a linter against relevant source files.
lint:
executor: default
steps:
- checkout
- *attach-workspace
- run:
name: Lint source files
command: yarn run lint
# Builds modules and persists the build output to the workspace.
build:
executor: default
steps:
- checkout
- *attach-workspace
- run:
name: Apply semver updates (if any)
command: |
AUTO_VERSION=$(yarn auto version)
if [[ $AUTO_VERSION == pre* ]]; then
yarn lerna version $(echo $AUTO_VERSION) --no-git-tag-version --no-push --yes --preid $(echo $CIRCLE_BRANCH)
elif [[ $AUTO_VERSION ]]; then
yarn lerna version $(echo $AUTO_VERSION) --no-git-tag-version --no-push --yes
fi
- run:
name: Build modules
command: yarn run build
- persist_to_workspace:
paths: *build-output-paths
root: *workspace-root
# Run unit tests and builds a coverage report.
test:
executor: default
steps:
- checkout
- *attach-workspace
- run:
name: Run unit tests
command: yarn run test
# For display in CircleCI Artifacts: https://circleci.com/docs/2.0/artifacts/
- store_artifacts:
path: packages/@magic-sdk/provider/coverage
- store_artifacts:
path: packages/@magic-sdk/react-native/coverage
- store_artifacts:
path: packages/magic-sdk/coverage
# Publish all packages to NPM
create-release:
executor: default
steps:
- checkout
- *attach-workspace
- run:
name: Publish to NPM
command: yarn auto shipit
# --- Workflow definitions --------------------------------------------------- #
workflows:
# Builds modules, verifies code with the linter, runs unit tests, and builds a
# coverage report.
pull-request:
jobs:
- install-dependencies: *filter-default-branches
- build:
requires:
- install-dependencies
- lint:
requires:
- build
- test:
requires:
- build
# Builds modules, verifies code with the linter, runs unit tests, and
# publishes the built packages to NPM.
publish-to-npm:
jobs:
- install-dependencies: *filter-release-branches-only
- build:
requires:
- install-dependencies
- test:
requires:
- build
- lint:
requires:
- build
# Manual approval step as a final gatekeeper to prevent
# possible mistakes!
- confirm-release:
type: approval
requires:
- test
- lint
- create-release:
requires:
- confirm-release
- test
- lint