Skip to content

Instantly share code, notes, and snippets.

@Mifrill
Last active August 4, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mifrill/bb1cfc81884620148e3e2fe476fe7859 to your computer and use it in GitHub Desktop.
Save Mifrill/bb1cfc81884620148e3e2fe476fe7859 to your computer and use it in GitHub Desktop.
version: 2
jobs:
build:
working_directory: ~/circleci-demo-ruby-rails
docker:
- image: circleci/ruby:2.4.1-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle-test_test
- image: selenium/standalone-chrome:3.4.0
steps:
- checkout
# Restore bundle cache
- type: cache-restore
key: rails-demo-{{ checksum "Gemfile.lock" }}
- run: sudo apt install postgresql-client
# Bundle install dependencies
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
# Install dependencies.
- run: sudo apt-get install software-properties-common
- run: lsb_release --a
- run: sudo apt-get update
- run: sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4
# Install Chrome for Debian.
- run: echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
- run: wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- run: sudo apt-get update && sudo apt-get install google-chrome-stable
# Install ChromeDriver.
- run: wget -N http://chromedriver.storage.googleapis.com/2.9/chromedriver_linux64.zip -P ~/
- run: unzip ~/chromedriver_linux64.zip -d ~/
- run: rm ~/chromedriver_linux64.zip
- run: sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
- run: sudo chown root:root /usr/local/bin/chromedriver
- run: sudo chmod 0755 /usr/local/bin/chromedriver
# Install Selenium.
- run: wget -N http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar -P ~/
- run: sudo mv -f ~/selenium-server-standalone-3.4.0.jar /usr/local/bin/selenium-server-standalone.jar
- run: sudo chown root:root /usr/local/bin/selenium-server-standalone.jar
- run: sudo chmod 0755 /usr/local/bin/selenium-server-standalone.jar
# Install xvfb
- run: sudo apt-get install xvfb -y
- run: sudo pkill Xvfb
# Store bundle cache
- save_cache:
key: rails-demo-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Database Setup
command: |
bundle exec rails db:create
bundle exec rails db:structure:load
bundle exec rails db:seed
- run:
name: Parallel RSpec
command: HEADLESS=on bundle exec rspec --profile 10 \
--out /tmp/test-results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- run:
name: Codecoverage Report
command: CODECLIMATE_REPO_TOKEN=YOUR_TOKEN bundle exec codeclimate-test-reporter
# Save artifacts
- store_test_results:
path: ./coverage/.resultset.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment