Skip to content

Commit 040bc36

Browse files
Add 'react_on_rails_pro/' from commit '93a456fad9a53653788c70aa6c35b16b560f1472'
git-subtree-dir: react_on_rails_pro git-subtree-mainline: 58d7404 git-subtree-split: 93a456f
2 parents 58d7404 + 93a456f commit 040bc36

File tree

666 files changed

+571752
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

666 files changed

+571752
-0
lines changed
Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
version: 2
2+
3+
aliases:
4+
# Print critical data and executables versions.
5+
- &print-system-info
6+
name: Print system information
7+
command: |
8+
echo "Linux release: "; cat /etc/issue
9+
echo "Current user: "; whoami
10+
echo "Current directory: "; pwd
11+
echo "Ruby version: "; ruby -v
12+
echo "Node version: "; node -v
13+
echo "Yarn version: "; yarn --version
14+
echo "Bundler version: "; bundle --version
15+
- &lint-js
16+
name: Linting of JS
17+
command: yarn run nps eslint
18+
19+
- &lint-ruby
20+
name: Linting of Ruby
21+
command: bundle exec rubocop
22+
23+
- &format
24+
name: Check formatting
25+
command: yarn run nps format.listDifferent
26+
27+
- &typescript-check
28+
name: Check TypeScript
29+
command: yarn run nps check-typescript
30+
31+
# Install/update Node modules for renderer package unless existing set of modules is satisfying Yarn.
32+
- &install-package-node-modules
33+
name: Install Node modules with Yarn for renderer package
34+
command: |
35+
sudo yarn global add yalc
36+
yarn install --frozen-lockfile --no-progress --no-emoji
37+
38+
# Install/update Node modules for dummy app unless existing set of modules is satisfying Yarn.
39+
- &install-dummy-app-node-modules
40+
name: Install Node modules with Yarn for dummy app
41+
command: |
42+
cd spec/dummy
43+
yarn install --frozen-lockfile --no-progress --no-emoji
44+
45+
# Install ruby gems unless existing set of gems is satisfying bundler.
46+
- &install-dummy-app-ruby-gems
47+
name: Install Ruby Gems for dummy app
48+
command: |
49+
gem install bundler -v "2.5.4"
50+
echo "Bundler version: "; bundle --version
51+
bundle config set --local path 'vendor/bundle'
52+
bundle config set --local disable_checksum_validation true
53+
cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle _2.5.4_ check || bundle _2.5.4_ install --jobs=4 --retry=3
54+
55+
- &generate-dummy-app-packs
56+
name: Generate file-system based entrypoints
57+
command: |
58+
cd spec/dummy
59+
bundle exec rake react_on_rails:generate_packs
60+
61+
# Install ruby gems unless existing set of gems is satisfying bundler.
62+
- &install-package-ruby-gems
63+
name: Install Ruby Gems for package
64+
command: |
65+
gem install bundler -v "2.5.4"
66+
echo "Bundler version: "; bundle --version
67+
bundle config set --local path 'vendor/bundle'
68+
bundle config set --local disable_checksum_validation true
69+
bundle _2.5.4_ check || bundle _2.5.4_ install --jobs=4 --retry=3
70+
71+
# Restore node_modules dir from cache using yarn.lock checksum as a key.
72+
- &restore-package-node-modules-cache
73+
name: Restore cached node_modules directory
74+
keys:
75+
- v4-package-node-modules-cache-{{ checksum "yarn.lock" }}
76+
77+
# Restore spec/dummy/node_modules dir from cache using yarn.lock checksum as a key.
78+
- &restore-dummy-app-node-modules-cache
79+
name: Restore cached spec/dummy/node_modules directory
80+
keys:
81+
- v4-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }}
82+
83+
# Restore vendor/bundle dir from cache using Gemfile.lock checksum as a key.
84+
- &restore-dummy-app-gem-cache
85+
name: Restore cached Ruby Gems for dummy app
86+
keys:
87+
- v4-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }}
88+
89+
# Restore vendor/bundle dir from cache using react_on_rails_pro.gemspec checksum as a key.
90+
- &restore-package-gem-cache
91+
name: Restore cached Ruby Gems for package
92+
keys:
93+
- v4-package-app-gem-cache-{{ checksum "react_on_rails_pro.gemspec" }}
94+
95+
# Restore webpack bundles for dummy app from cache
96+
- &restore-dummy-app-webpack-bundle-cache
97+
name: Restore cached webpack bundles for dummy app
98+
key: v4-dummy-app-webpack-bundle-{{ .Revision }}
99+
100+
# NOTE: Sometimes CI generated docker images are not updated in time to keep up with the minimum required
101+
# by chromedriver versions of Chrome. Just bump here Chrome version if chromedriver raises errors
102+
- &install-latest-chrome
103+
name: Ensure minimum required Chrome version
104+
command: |
105+
echo -e "Installed $(google-chrome --version)\n"
106+
MINIMUM_REQUIRED_CHROME_VERSION=75
107+
INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)"
108+
if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then
109+
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
110+
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
111+
sudo apt-get update
112+
sudo apt-get install google-chrome-stable
113+
echo -e "\nInstalled $(google-chrome --version)"
114+
fi
115+
116+
jobs:
117+
# Lint all
118+
lint-js-and-ruby:
119+
docker:
120+
- image: &docker_image cimg/ruby:3.3.7-browsers
121+
steps:
122+
- checkout
123+
- run: *print-system-info
124+
- restore_cache: *restore-package-node-modules-cache
125+
- restore_cache: *restore-package-gem-cache
126+
- restore_cache: *restore-dummy-app-node-modules-cache
127+
- run: *install-package-ruby-gems
128+
- run: *install-package-node-modules
129+
- run: *install-dummy-app-ruby-gems
130+
- run: *install-dummy-app-node-modules
131+
- run:
132+
name: Install Node modules with Yarn for ExecJS dummy app
133+
command: |
134+
cd spec/execjs-compatible-dummy
135+
yarn install --frozen-lockfile --no-progress --no-emoji
136+
- run: *generate-dummy-app-packs
137+
- run: *lint-ruby
138+
- run: *lint-js
139+
- run: *format
140+
- run: *typescript-check
141+
142+
# Install Node modules for Renderer package with Yarn and save them to cache.
143+
install-package-node-packages:
144+
docker:
145+
- image: *docker_image
146+
steps:
147+
- checkout
148+
- run: *print-system-info
149+
- restore_cache: *restore-package-node-modules-cache
150+
- run: *install-package-node-modules
151+
- save_cache:
152+
name: Save root node_modules to cache
153+
key: v4-package-node-modules-cache-{{ checksum "yarn.lock" }}
154+
paths:
155+
- node_modules
156+
157+
# Install Node modules for dummy app with Yarn and save them to cache.
158+
install-dummy-app-node-packages:
159+
docker:
160+
- image: *docker_image
161+
steps:
162+
- checkout
163+
- run: *print-system-info
164+
- restore_cache: *restore-dummy-app-node-modules-cache
165+
- run: *install-package-node-modules
166+
- run: *install-dummy-app-node-modules
167+
- save_cache:
168+
name: Save spec/dummy/node_modules to cache
169+
key: v4-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }}
170+
paths:
171+
- spec/dummy/node_modules
172+
173+
# Install Ruby gems for package with Bundler and save them to cache.
174+
install-package-ruby-gems:
175+
docker:
176+
- image: *docker_image
177+
steps:
178+
- checkout
179+
- run: *print-system-info
180+
- restore_cache: *restore-package-gem-cache
181+
- run: *install-package-ruby-gems
182+
- save_cache:
183+
name: Save dummy app ruby gems to cache
184+
key: v4-package-app-gem-cache-{{ checksum "react_on_rails_pro.gemspec" }}
185+
paths:
186+
- vendor/bundle
187+
188+
# Install Ruby gems for dummy app with Bundler and save them to cache.
189+
install-dummy-app-ruby-gems:
190+
docker:
191+
- image: *docker_image
192+
steps:
193+
- checkout
194+
- run: *print-system-info
195+
- restore_cache: *restore-dummy-app-gem-cache
196+
- run: *install-dummy-app-ruby-gems
197+
- save_cache:
198+
name: Save dummy app ruby gems to cache
199+
key: v4-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }}
200+
paths:
201+
- spec/dummy/vendor/bundle
202+
203+
# Build client and server bundles for dummy app with Webpack and save them to cache.
204+
# NOTE: keeping around this cache in case we have multiple rspec suites in the future to tests
205+
# different node renderers.
206+
build-dummy-app-webpack-test-bundles:
207+
docker:
208+
- image: *docker_image
209+
steps:
210+
- checkout
211+
- run: *print-system-info
212+
- restore_cache: *restore-package-node-modules-cache
213+
- restore_cache: *restore-dummy-app-node-modules-cache
214+
- restore_cache: *restore-dummy-app-gem-cache
215+
- run: *install-package-node-modules
216+
- run: *install-dummy-app-node-modules
217+
- run: *install-dummy-app-ruby-gems
218+
- run: *generate-dummy-app-packs
219+
- run:
220+
name: Build test bundles for dummy app
221+
command: cd spec/dummy && yarn run build:test
222+
- save_cache:
223+
name: Save test webpack bundles to cache (for build number checksum used by rspec job)
224+
key: v4-dummy-app-webpack-bundle-{{ .Revision }}
225+
paths:
226+
- spec/dummy/public/webpack/test
227+
- spec/dummy/ssr-generated
228+
229+
# Run JS unit tests for Renderer package.
230+
package-js-tests:
231+
docker:
232+
- image: *docker_image
233+
steps:
234+
- checkout
235+
- run: *print-system-info
236+
- restore_cache: *restore-package-node-modules-cache
237+
- run: rm -rf spec/dummy/public/webpack
238+
- run: rm -rf spec/dummy/ssr-generated
239+
- restore_cache: *restore-dummy-app-webpack-bundle-cache
240+
- run: *install-package-node-modules
241+
# https://circleci.com/docs/collect-test-data/#jest
242+
- run:
243+
name: Run JS unit tests for Renderer package
244+
command: yarn run nps test.ci
245+
environment:
246+
JEST_JUNIT_OUTPUT_DIR: ./jest
247+
JEST_JUNIT_ADD_FILE_ATTRIBUTE: "true"
248+
- store_test_results:
249+
path: ./jest
250+
251+
rspec-package-specs:
252+
docker:
253+
- image: *docker_image
254+
steps:
255+
- checkout
256+
- run: *print-system-info
257+
- restore_cache: *restore-package-gem-cache
258+
- run: *install-package-ruby-gems
259+
- run:
260+
name: Run rspec tests
261+
command: |
262+
bundle exec rspec spec/react_on_rails_pro
263+
- store_test_results:
264+
path: ~/rspec
265+
- store_artifacts:
266+
path: log/test.log
267+
268+
# Start Renderer and run RSpec test suite for dummy app.
269+
# NOTES:
270+
# Seems that we cannot use symlinks (yarn link) with caches for the main renderer package
271+
# react-on-rails-pro-node-renderer. Consequently, we just reinstall the top level, renderer, node packages
272+
# as well as the
273+
rspec-dummy-app-node-renderer:
274+
docker:
275+
- image: *docker_image
276+
steps:
277+
- checkout
278+
- run: *print-system-info
279+
- restore_cache: *restore-package-gem-cache
280+
- restore_cache: *restore-package-node-modules-cache
281+
- restore_cache: *restore-dummy-app-node-modules-cache
282+
- restore_cache: *restore-dummy-app-gem-cache
283+
- run: rm -rf spec/dummy/public/webpack
284+
- run: rm -rf spec/dummy/ssr-generated
285+
- restore_cache: *restore-dummy-app-webpack-bundle-cache
286+
- run: *install-dummy-app-ruby-gems
287+
- run: *install-package-node-modules
288+
- run: *install-latest-chrome
289+
- run: *install-dummy-app-node-modules
290+
- run:
291+
name: Generate file-system based entrypoints
292+
command: cd spec/dummy && bundle exec rake react_on_rails:generate_packs
293+
- run:
294+
name: Run Node renderer in a background
295+
command: cd spec/dummy && yarn run node-renderer
296+
background: true
297+
- run:
298+
name: run rails server in background
299+
command: cd spec/dummy && RAILS_ENV=test rails server
300+
background: true
301+
- run:
302+
name: wait for rails server to start
303+
command: |
304+
while ! curl -s http://localhost:3000 > /dev/null; do sleep 1; done
305+
- run:
306+
name: Run rspec tests
307+
working_directory: spec/dummy
308+
command: |
309+
circleci tests glob "spec/**/*_spec.rb" |
310+
circleci tests run --command="xargs bundle exec rspec \
311+
--profile 10 \
312+
--format progress \
313+
--format RspecJunitFormatter \
314+
--out ~/rspec/rspec.xml \
315+
--format documentation" \
316+
--verbose \
317+
--split-by=timings
318+
- store_test_results:
319+
path: ~/rspec
320+
- store_artifacts:
321+
path: spec/dummy/tmp/screenshots
322+
- store_artifacts:
323+
path: spec/dummy/log/test.log
324+
- store_artifacts:
325+
path: spec/dummy/yarn-error.log
326+
327+
workflows:
328+
version: 2
329+
build-and-test:
330+
jobs:
331+
- install-package-node-packages
332+
- install-package-ruby-gems
333+
- install-dummy-app-node-packages:
334+
requires:
335+
- install-package-node-packages
336+
- install-dummy-app-ruby-gems
337+
- lint-js-and-ruby:
338+
requires:
339+
- install-package-node-packages
340+
- install-package-ruby-gems
341+
- install-dummy-app-node-packages
342+
- build-dummy-app-webpack-test-bundles:
343+
requires:
344+
- install-package-node-packages
345+
- install-dummy-app-node-packages
346+
- install-dummy-app-ruby-gems
347+
- package-js-tests:
348+
requires:
349+
- install-package-node-packages
350+
- build-dummy-app-webpack-test-bundles
351+
- rspec-package-specs:
352+
requires:
353+
- install-package-ruby-gems
354+
- rspec-dummy-app-node-renderer:
355+
requires:
356+
- install-package-ruby-gems
357+
- build-dummy-app-webpack-test-bundles

0 commit comments

Comments
 (0)