-
Notifications
You must be signed in to change notification settings - Fork 242
/
config.yml
329 lines (318 loc) 路 12.4 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
version: 2.1
# These "CircleCI Orbs" are reusable bits of configuration that can be shared
# across projects. See https://circleci.com/orbs/ for more information.
orbs:
# `oss` is a local reference to the package. The source for Apollo Orbs can
# be found at http://github.com/apollographql/CircleCI-Orbs/.
# We could use Renovate to bump this version via PR, but that's not set up now.
oss: apollo/oss-ci-cd-tooling@0.0.20
# Rust steps which are used below (like `rust/install`, `rust/test`) are
# defined in this orb. For reference, the orb can be found here:
# https://github.com/CircleCI-Public/rust-orb
rust: circleci/rust@1.5.0
commands:
# These are the steps used for each version of Node which we're testing
# against. Thanks to YAMLs inability to merge arrays (though it is able
# to merge objects), every version of Node must use the exact same steps,
# or these steps would need to be repeated in a version of Node that needs
# something different. Probably best to avoid that, out of principle, though.
common_test_steps:
description: "Commands run on each Node.js job (not for Rust jobs)"
steps:
- oss/install_specific_npm_version:
version: '7'
- checkout
- oss/npm_clean_install_with_caching
- run:
command: npm run test:ci
environment:
JEST_JUNIT_OUTPUT_DIR: "reports/junit/"
- store_test_results:
path: reports/junit
- store_artifacts:
path: reports/junit
executors:
rust_linux: &rust_linux_executor
docker:
- image: cimg/base:stable
rust_macos: &rust_macos_executor
macos:
xcode: 11.4
rust_windows: &rust_windows_executor
machine:
image: 'windows-server-2019-vs2019:stable'
resource_class: windows.xlarge
shell: powershell.exe -ExecutionPolicy Bypass
# Important! When adding a new job to `jobs`, make sure to define when it
# executes by also adding it to the `workflows` section below!
jobs:
# Platform tests, each with the same tests but different platform or version.
# The docker tag represents the Node.js version and the full list is available
# at https://hub.docker.com/r/circleci/node/.
NodeJS 12:
docker:
- image: cimg/node:12.22.1
steps:
- common_test_steps
# We will save the results of this one particular invocation to use in
# the publish step. Not only does this make the publishing step take less
# time, this also ensures that a passing version gets deployed even if,
# theoretically, rebuilding the same commit on the same version of
# Node.js should yield the same results!
- persist_to_workspace:
root: .
paths:
- ./**
NodeJS 14:
docker:
- image: cimg/node:14.16.1
steps:
- common_test_steps
NodeJS 16:
docker:
- image: cimg/node:16.0.0
steps:
- common_test_steps
GraphQL Types:
description: "Assert generated GraphQL types are up to date"
docker:
- image: cimg/node:14.16.1
steps:
- oss/install_specific_npm_version:
version: '7'
- checkout
- oss/npm_clean_install_with_caching
- run:
command: npm run codegen:check
Rust:
parameters:
platform:
type: executor
executor: << parameters.platform >>
environment:
# Note: This is a no-op at the second, but bear with me on this. If this
# comment is not removed by 2021-06-30 remove it along with the next line.
# renovate: datasource=github-tags depName=nodejs/node versioning=node
NODE_VERSION: 14.17.5
NPM_VERSION: 7.10.0
steps:
- checkout
- when:
condition:
equal: [ *rust_macos_executor, << parameters.platform >> ]
steps:
- rust/install:
version: stable
- restore_cache:
keys:
- rust-target-v1-macos-{{ checksum "Cargo.lock" }}
# Installing this with the curl nvm command was proving difficult,
# so I've opted to just install the .pkg. Should be the same net
# result, even if liked the opportunity for symmetry with Linux.
- run:
name: Installing Node.js with a .pkg.
command: |
curl "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" > "$HOME/Downloads/node.pkg" && sudo installer -store -pkg "$HOME/Downloads/node.pkg" -target "/"
- run:
name: Install specific version of npm
command: |
sudo npm install --global npm@${NPM_VERSION}
- run:
name: Assert Node.js version
command: test "$(node --version)" = "v${NODE_VERSION}"
- run:
name: Assert npm version
command: test "$(npm --version)" = "${NPM_VERSION}"
- run: npm clean-install
- rust/test:
# This is prefixed in the orb with 'cargo-'
cache_version: v2-macos
- rust/format:
with_cache: false # Only the first needs to restore cache.
- rust/clippy:
with_cache: false # Only the first needs to restore cache.
- save_cache:
key: rust-target-v1-macos-{{ checksum "Cargo.lock" }}
paths:
- target/
- when:
condition:
equal: [ *rust_linux_executor, << parameters.platform >> ]
steps:
- rust/install:
version: stable
- restore_cache:
keys:
- rust-target-v1-linux-{{ checksum "Cargo.lock" }}
- run:
name: Install nvm
command: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
- run: echo '. ~/.nvm/nvm.sh' >> $BASH_ENV
- run:
name: Install desired Node.js version
command: |
nvm install $NODE_VERSION
nvm alias default $NODE_VERSION
npm install --global npm@${NPM_VERSION}
- run:
name: Assert Node.js version
command: test "$(node --version)" = "v${NODE_VERSION}"
- run:
name: Assert npm version
command: test "$(npm --version)" = "${NPM_VERSION}"
- run: npm clean-install
- rust/test:
# This is prefixed in the orb with 'cargo-'
cache_version: v2-linux
- rust/format:
with_cache: false # Only the first needs to restore cache.
- rust/clippy:
with_cache: false # Only the first needs to restore cache.
- save_cache:
key: rust-target-v1-linux-{{ checksum "Cargo.lock" }}
paths:
- target/
- when:
condition:
equal: [ *rust_windows_executor, << parameters.platform >> ]
steps:
- run:
name: Install rustup
environment:
# Override auto-detection of RAM for Rustc install.
# https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925
RUSTUP_UNPACK_RAM: "21474836480"
command: |
$installer_dir = "$Env:TEMP"
echo "Downloading rustup"
(New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe")
echo "Installing rustup"
& $installer_dir\rustup-init.exe --profile minimal --component rustfmt,clippy -y
exit $LASTEXITCODE
- run:
name: Special case for Windows because of ssh-agent
command: |
Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @"
[net]
git-fetch-with-cli = true
"@
- restore_cache:
keys:
- rust-target-v1-windows-{{ checksum "Cargo.lock" }}
- run:
name: Install desired Node.js version with nvm
command: |
nvm install ${Env:NODE_VERSION}
nvm on
- run:
# https://github.com/coreybutler/nvm-windows/issues/300
# Have to move the command out of the way because it can't
# overwrite itself otherwise. This is madness, but apparently
# accepted. Other things I tried: using yarn to install npm,
# using http://npm.im/npm-windows-upgrade and even shouting.
name: Install specific version of npm in a crazy Windows way
command: |
$node_dir = (get-item (get-command npm).source).directory.fullname
foreach ($cmd in @("npm", "npx")) {
foreach ($ext in @(".ps1", ".cmd", "")) {
if (Test-Path "$node_dir/$cmd$ext") {
rename-item -path (join-path -path $node_dir -childpath "$cmd$ext") "${cmd}-orig${ext}"
}
}
}
npm-orig install --global "npm@${Env:NPM_VERSION}"
- run:
name: Assert Node.js version
command: |
if ((node --version) -Ne "v${Env:NODE_VERSION}") { exit 1 }
- run:
name: Assert npm version
command: |
if ((npm --version) -Ne "${Env:NPM_VERSION}") { exit 1 }
- run:
name: npm clean-install
command: |
npm clean-install
- rust/test:
# This is prefixed in the orb with 'cargo-'
cache_version: v2-windows
- rust/format:
with_cache: false # Only the first needs to restore cache.
- rust/clippy:
with_cache: false # Only the first needs to restore cache.
- save_cache:
key: rust-target-v1-windows-{{ checksum "Cargo.lock" }}
paths:
- target/
# XXX We used to use this filter to only run a "Docs" job on docs branches.
# Now we use it to disable all jobs. It's unclear if there's a simpler way
# to do this!
common_non_publish_filters: &common_non_publish_filters
filters:
branches:
# If 'docs' is found, with word boundaries on either side, skip.
ignore: /.*?\bdocs\b.*/
# Ensure every job has `tags` filters since the publish steps have tags.
# This is some wild configuration thing that's pretty hard to figure out.
tags:
only: /.*/
common_publish_filters: &common_publish_filters
filters:
# Only run pre-publish and publish steps on specific tags.
tags:
only: /^publish\/[0-9]+$/
# We want the publish to trigger on the above tag, not any branch.
branches:
ignore: /.*/
workflows:
version: 2
Build:
jobs:
- NodeJS 12:
name: "JS: Node 12"
<<: *common_non_publish_filters
- NodeJS 14:
name: "JS: Node 14"
<<: *common_non_publish_filters
- NodeJS 16:
name: "JS: Node 16"
<<: *common_non_publish_filters
- GraphQL Types:
name: "GraphQL Types (up to date)"
<<: *common_non_publish_filters
- Rust:
<<: *common_non_publish_filters
matrix:
parameters:
platform:
- rust_macos
- rust_windows
- rust_linux
- oss/lerna_tarballs:
name: "JS: Package tarballs"
<<: *common_non_publish_filters
requires:
- "JS: Node 12"
- "JS: Node 14"
- "JS: Node 16"
- "GraphQL Types (up to date)"
- oss/dry_run:
name: "JS: Dry-run"
<<: *common_publish_filters
requires:
- "JS: Node 12"
- "JS: Node 14"
- "JS: Node 16"
- Rust
- "GraphQL Types (up to date)"
- oss/confirmation:
name: "JS: Confirmation"
type: approval
<<: *common_publish_filters
requires:
- "JS: Dry-run"
- oss/publish:
name: "JS: Publish"
<<: *common_publish_filters
requires:
- "JS: Confirmation"