Created
December 15, 2019 06:28
-
-
Save channainfo/c5e7c7a1d7d84457cce92245011fcd4b to your computer and use it in GitHub Desktop.
CircleCI rubyonrails 4.2, Yarn, React, Ruby 2.3, MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 # use CircleCI 2.0 | |
jobs: # a collection of steps | |
build: # runs not using Workflows must have a `build` job as entry point | |
parallelism: 1 # run three instances of this job in parallel | |
docker: # run the steps with Docker | |
- image: circleci/ruby:2.3.4-jessie-node # ...with this image as the primary container; this is where all `steps` will run | |
environment: # environment variables for primary container | |
BUNDLE_JOBS: 3 | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
RAILS_ENV: test | |
- image: circleci/mysql:5.7.28 # database image | |
environment: # environment variables for database | |
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' | |
steps: # a collection of executable commands | |
- checkout # special step to check out source code to working directory | |
# - run: | |
# name: Dependencies | |
# command: | | |
# sudo apt-get update && \ | |
# DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
# build-essential mysql-client nodejs yarn && \ | |
# apt-get clean && \ | |
# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# Which version of bundler? | |
- run: | |
name: Which bundler? | |
command: bundle -v | |
# Restore bundle cache | |
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/ | |
- restore_cache: | |
keys: | |
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} | |
- rails-demo-bundle-v2- | |
- run: # Install Ruby dependencies | |
name: Bundle Install | |
command: bundle check --path vendor/bundle || bundle install --deployment | |
# Store bundle cache for Ruby dependencies | |
- save_cache: | |
key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} | |
paths: | |
- vendor/bundle | |
# Only necessary if app uses webpacker or yarn in some other way | |
- restore_cache: | |
keys: | |
- rails-demo-yarn-{{ checksum "yarn.lock" }} | |
- rails-demo-yarn- | |
- run: | |
name: Yarn Install | |
command: yarn install --cache-folder ~/.cache/yarn | |
# Store yarn / webpacker cache | |
- save_cache: | |
key: rails-demo-yarn-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.cache/yarn | |
- run: | |
name: Wait for DB | |
command: | | |
for i in `seq 1 10`; | |
do | |
nc -z 127.0.0.1 3306 && echo Success && exit 0 | |
echo -n . | |
sleep 1 | |
done | |
echo Failed waiting for MySQL && exit 1 | |
- run: | |
name: Database setup | |
command: bundle exec rake db:create db:migrate | |
- run: | |
name: Run rspec in parallel | |
command: | | |
bundle exec rspec --profile 10 \ | |
--format documentation \ | |
--out test_results/rspec.xml \ | |
--format progress \ | |
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) | |
# Save test results for timing analysis | |
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/ | |
path: test_results | |
# See https://circleci.com/docs/2.0/deployment-integrations/ for example deploy configs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment