Last active
August 29, 2018 15:17
-
-
Save toadkicker/cc22117da633134c0694e40bf996f0d1 to your computer and use it in GitHub Desktop.
CircleCI 2.0 configuration for Ruby on Rails 5.1+ with headless chromedriver
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
# 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-node-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-{{ checksum "Gemfile.lock" }} | |
- gem-cache | |
- 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-{{ checksum "Gemfile.lock" }} | |
- restore_cache: | |
keys: | |
- yarn-cache-{{ checksum "yarn.lock" }} | |
- yarn-cache | |
- yarn-cache | |
- run: yarn install | |
# Store yarn / webpacker cache | |
- save_cache: | |
key: yarn-cache-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.yarn-cache | |
- 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 | |
- 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
Why do you have multiple keys for the
caches
?