-
-
Save pavanprakash21/f2bb493ce66ea0b8f86a1bed99c279a0 to your computer and use it in GitHub Desktop.
CircleCI 2.0 configuration for Ruby on Rails 5.1+ with Vue frontend and headless chromedriver
This file contains 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
# Ruby CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-ruby/ for more details | |
# | |
version: 2 | |
jobs: | |
build: | |
docker: | |
# specify the version you desire here | |
- image: circleci/ruby:2.5.1-browsers | |
environment: | |
- PG_HOST=localhost | |
- PG_PORT=5432 | |
- PG_PASSWORD=ubuntu | |
- PG_USER=ubuntu | |
- RAILS_ENV=test | |
- RACK_ENV=test | |
- image: postgres:9.6 | |
environment: | |
- POSTGRES_USER=ubuntu | |
- POSTGRES_DB=nowserving_test | |
- image: bitjourney/elasticsearch-ci | |
working_directory: ~/repo | |
steps: | |
- checkout | |
# Download and cache dependencies | |
- restore_cache: | |
keys: | |
- gem-cache-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | |
- gem-cache-{{ .Branch }} | |
- gem-cache | |
- run: | |
name: Install Yarn | |
command: | | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee -a /etc/apt/sources.list | |
sudo apt-get --no-install-recommends install apt-transport-https | |
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - | |
sudo apt-get update | |
sudo apt-get --no-install-recommends install nodejs yarn | |
yarn --version | |
- run: | |
name: Install Latest Browsers | |
command: | | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' | |
sudo apt-get update && sudo apt-get upgrade firefox | |
sudo apt-get install google-chrome-stable | |
- run: | |
name: Install Ruby Dependencies | |
command: gem install bundler && bundle install --jobs=4 --retry=3 --path vendor/bundle | |
- save_cache: | |
paths: | |
- ./vendor/bundle | |
key: gem-cache-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | |
- restore_cache: | |
keys: | |
- yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }} | |
- yarn-cache-{{ .Branch }} | |
- yarn-cache | |
- run: yarn install | |
# Store yarn / webpacker cache | |
- save_cache: | |
key: yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }} | |
paths: | |
- node_modules | |
- run: | |
name: Wait for DB | |
command: dockerize -wait tcp://localhost:5432 -timeout 1m | |
- run: | |
name: Set up DB | |
command: | | |
bundle exec rake db:create db:schema:load --trace | |
bundle exec rake db:migrate | |
- run: bin/webpack | |
# run tests! | |
- run: | |
name: run tests | |
command: | | |
mkdir /tmp/test-results | |
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings --timings-type=classname)" | |
bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress $TEST_FILES | |
# collect reports | |
- store_test_results: | |
path: /tmp/test-results | |
- store_artifacts: | |
path: /tmp/test-results | |
destination: test-results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment