forked from shakacode/react_on_rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
337 lines (311 loc) · 11.8 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
330
331
332
333
334
335
336
337
version: 2
aliases:
- &docker-image
- image: circleci/ruby:2.7-node-browsers
# Print critical data and executables versions.
- &print-system-info
name: Print system information
command: |
echo "Linux release: "; cat /etc/issue
echo "Current user: "; whoami
echo "Current directory: "; pwd
echo "Ruby version: "; ruby -v
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- &lint-js
name: Linting of JS
command: yarn start lint
- &lint-ruby
name: Linting of Ruby
command: bundle exec rubocop
- &format
name: Check formatting
command: yarn start format.listDifferent
# Install/update Node modules for renderer package unless existing set of modules is satisfying Yarn.
- &install-package-node-modules
name: Install Node modules with Yarn for renderer package
command: |
sudo yarn global add yalc
yarn install --no-progress --no-emoji
yarn run eslint -v
# Install/update Node modules for dummy app unless existing set of modules is satisfying Yarn.
- &install-dummy-app-node-modules
name: Install Node modules with Yarn for dummy app
command: cd spec/dummy && yarn install --no-progress --no-emoji
# Setup yarn links for react-on-rails
- &install-yalc-publish
name: yalc publish for react-on-rails
command: yalc publish
- &install-yalc-add-react-on-rails
name: yalc add react-on-rails
command: cd spec/dummy && yalc add react-on-rails
# Install ruby gems unless existing set of gems is satisfying bundler.
- &install-dummy-app-ruby-gems
name: Install Ruby Gems for dummy app
command: |
gem install bundler
echo "Bundler version: "; bundle --version
cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
# Install ruby gems unless existing set of gems is satisfying bundler.
- &install-package-ruby-gems
name: Install Ruby Gems for package
command: |
gem install bundler
echo "Bundler version: "; bundle --version
bundle lock --add-platform 'x86_64-linux'
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
# Restore node_modules dir from cache using yarn.lock checksum as a key.
- &restore-package-node-modules-cache
name: Restore cached node_modules directory
keys:
- v5-package-node-modules-cache-{{ checksum "yarn.lock" }}
# Restore spec/dummy/node_modules dir from cache using yarn.lock checksum as a key.
- &restore-dummy-app-node-modules-cache
name: Restore cached spec/dummy/node_modules directory
keys:
- v5-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }}
# Restore vendor/bundle dir from cache using Gemfile.lock checksum as a key.
- &restore-dummy-app-gem-cache
name: Restore cached Ruby Gems for dummy app
keys:
- v5-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }}
# Restore vendor/bundle dir from cache using react_on_rails.gemspec checksum as a key.
- &restore-package-gem-cache
name: Restore cached Ruby Gems for package
keys:
- v5-package-app-gem-cache-{{ checksum "react_on_rails.gemspec" }}
# NOTE: Sometimes CI generated docker images are not updated in time to keep up with the minimum required
# by chromedriver versions of Chrome. Just bump here Chrome version if chromedriver raises errors
- &install-latest-chrome
name: Ensure minimum required Chrome version
command: |
echo -e "Installed $(google-chrome --version)\n"
MINIMUM_REQUIRED_CHROME_VERSION=75
INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)"
if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
echo -e "\nInstalled $(google-chrome --version)"
fi
jobs:
# Lint all
lint-js-and-ruby:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-node-modules-cache
- restore_cache: *restore-package-gem-cache
- run: *install-package-ruby-gems
- run: *lint-ruby
- run: *lint-js
- run: *format
prettier:
docker: *docker-image
parallelism: 1
steps:
- checkout
- restore_cache: *restore-package-node-modules-cache
- run:
name: prettier
command: yarn start format.listDifferent
# Install Node modules for Renderer package with Yarn and save them to chache.
install-package-node-packages:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-node-modules-cache
- run: *install-package-node-modules
- save_cache:
name: Save root node_modules to cache
key: v5-package-node-modules-cache-{{ checksum "yarn.lock" }}
paths:
- node_modules
# Install Node modules for dummy app with Yarn and save them to cache.
install-dummy-app-node-packages:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-dummy-app-node-modules-cache
- run: *install-package-node-modules
- run: *install-yalc-publish
- run: *install-yalc-add-react-on-rails
- run: *install-dummy-app-node-modules
- save_cache:
name: Save spec/dummy/node_modules to cache
key: v5-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }}
paths:
- spec/dummy/node_modules
- spec/dummy/node_modules
# Install Ruby gems for package with Bundler and save them to cache.
install-package-ruby-gems:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-gem-cache
- run: *install-package-ruby-gems
- save_cache:
name: Save dummy app ruby gems to cache
key: v5-package-app-gem-cache-{{ checksum "react_on_rails.gemspec" }}
paths:
- vendor/bundle
# Install Ruby gems for dummy app with Bundler and save them to cache.
install-dummy-app-ruby-gems:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-dummy-app-gem-cache
- run: *install-dummy-app-ruby-gems
- save_cache:
name: Save dummy app ruby gems to cache
key: v5-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }}
paths:
- spec/dummy/vendor/bundle
# Build client and server bundles for dummy app with Webpack and save them to cache.
# NOTE: keeping around this cache in case we have multiple rspec suites in the future to tests
# different node renderers.
build-dummy-app-webpack-test-bundles:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- run: *install-package-node-modules
- run: *install-yalc-publish
- restore_cache: *restore-dummy-app-node-modules-cache
- run: *install-yalc-add-react-on-rails
- run: *install-dummy-app-node-modules
- run: *install-dummy-app-ruby-gems
- run:
name: generate file system-based packs
command: cd spec/dummy && bundle exec rake react_on_rails:generate_packs
- run:
name: Build test bundles for dummy app
command: cd spec/dummy && yarn run build:test
- save_cache:
name: Save test webpack bundles to cache (for build number checksum used by rspec job)
key: v5-dummy-app-webpack-bundle-{{ .Revision }}
paths:
- spec/dummy/public/webpack
# Run JS unit tests for Renderer package.
package-js-tests:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-node-modules-cache
- run: *install-package-node-modules
- run:
name: Run JS unit tests for Renderer package
command: yarn test
rspec-package-specs:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-gem-cache
- run: *install-package-ruby-gems
- run:
name: Run rspec tests
command: |
bundle exec rspec spec/react_on_rails
- store_test_results:
path: ~/rspec
- store_artifacts:
path: log/test.log
main:
docker: *docker-image
steps:
- checkout
- run: *print-system-info
- restore_cache: *restore-package-gem-cache
- restore_cache: *restore-dummy-app-gem-cache
- restore_cache:
name: Restore cached webpack bundles for dummy app
key: v5-dummy-app-webpack-bundle-{{ .Revision }}
- restore_cache: *restore-dummy-app-node-modules-cache
- restore_cache: *restore-package-node-modules-cache
- run: *install-package-node-modules
- run: *install-yalc-publish
- run: *install-yalc-add-react-on-rails
- run: *install-package-ruby-gems
- run: *install-dummy-app-ruby-gems
- run: *install-latest-chrome
- run:
name: Touch webpack bundles
command: touch spec/dummy/public/webpack/test/*
- run:
name: Install yalc globally
command: sudo yarn global add yalc
- run:
name: Prep for CI
# TODO -- need to leverage Circle CI containers
command: |
bundle exec rails prepare_for_ci
- run:
name: Main CI
# TODO -- need to leverage Circle CI containers
command: |
bundle exec rails run_rspec:all_dummy
# The following step will run only if the main job is finished successfully.
# Build hook is triggered by curl command described here https://docs.netlify.com/configure-builds/build-hooks/
# NETLIFY_HOOK is an environment variable on CircleCI to keep sensitive data outside the repo
- run:
name: Deploy SC website
command: |
if [ $CIRCLE_BRANCH = "master" ]; then
curl -X POST -d '{}' ${NETLIFY_HOOK}
fi
when: on_success
- store_test_results:
path: ~/rspec
- store_artifacts:
path: spec/dummy/tmp/capybara
- store_artifacts:
path: spec/dummy/tmp/screenshots
- store_artifacts:
path: spec/dummy/log/test.log
- store_artifacts:
path: spec/dummy/yarn-error.log
workflows:
version: 2
build-and-test:
jobs:
- install-package-node-packages
- install-package-ruby-gems
- install-dummy-app-node-packages
- install-dummy-app-ruby-gems
- lint-js-and-ruby:
requires:
- install-package-node-packages
- install-package-ruby-gems
- prettier:
filters:
branches:
ignore: master
requires:
- install-package-node-packages
- build-dummy-app-webpack-test-bundles:
requires:
- install-dummy-app-node-packages
- install-dummy-app-ruby-gems
- package-js-tests:
requires:
- install-package-node-packages
- rspec-package-specs:
requires:
- install-package-ruby-gems
- build-dummy-app-webpack-test-bundles
- install-dummy-app-ruby-gems
- main:
requires:
- install-package-ruby-gems
- install-dummy-app-ruby-gems
- install-package-node-packages
- build-dummy-app-webpack-test-bundles