Skip to content

Instantly share code, notes, and snippets.

@pftg
Created January 13, 2018 21:03
Show Gist options
  • Select an option

  • Save pftg/181813564423ce969e769fc6dfb72f70 to your computer and use it in GitHub Desktop.

Select an option

Save pftg/181813564423ce969e769fc6dfb72f70 to your computer and use it in GitHub Desktop.
Pre-compile Assets and Cache for CircleCI
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
build:
environment:
BUNDLE_GEMFILE: Gemfile
BUNDLE_WITHOUT: "production:staging:development"
docker:
# specify the version you desire here
- image: circleci/ruby:2.4.3-node-browsers
environment:
RAILS_ENV: test
RACK_ENV: test
PGHOST: 127.0.0.1
PGUSER: ubuntu
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:alpine
environment:
POSTGRES_USER: ubuntu
POSTGRES_DB: rails-bootstrap_test
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: bundle check --path vendor/bundle || bundle install --deployment --jobs=4 --retry=3
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
- restore_cache:
keys:
- v1-asset-cache-{{ arch }}-{{ .Branch }}
- v1-asset-cache-
- run: bundle exec rake assets:precompile
- save_cache:
key: v1-asset-cache-{{ arch }}-{{ .Branch }}-{{ epoch }}
paths:
- public/assets
- tmp/cache/assets/sprockets
- run: bundle exec rake db:schema:load
- run: bundle exec rake test test:system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment