Fixed Circle CI cache for Ruby version.

Was missing the checksum which would cause Ruby to be downloaded and
rebuilt each time.

The Docker image has been updated to use an unspecified version to
reduce version maintenance.

The `CI_RUBY_VERSION` environment variable was introduced to be
dynamically set based on value in the `.ruby-version` for improved
maintainability.
This commit is contained in:
Brooke Kuhlmann
2018-12-30 10:01:44 -07:00
parent 4d9ad7315d
commit 6c2de5a5bb

View File

@@ -3,7 +3,7 @@ jobs:
build: build:
working_directory: ~/project working_directory: ~/project
docker: docker:
- image: circleci/ruby:2.5 - image: circleci/ruby
environment: environment:
BUNDLE_JOBS: 3 BUNDLE_JOBS: 3
BUNDLE_RETRY: 3 BUNDLE_RETRY: 3
@@ -12,17 +12,22 @@ jobs:
steps: steps:
- checkout - checkout
- run:
name: Environment Setup
command: |
printf "%s\n" 'export CI_RUBY_VERSION=$(cat ".ruby-version" | tr -d "\n")' >> $BASH_ENV
- type: cache-restore - type: cache-restore
name: Ruby Restore name: Ruby Restore
key: ruby key: ruby-{{checksum ".ruby-version"}}
- run: - run:
name: Ruby Install name: Ruby Install
command: | command: |
curl https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.0.tar.bz2 -o ../ruby-2.6.0.tar.gz curl https://cache.ruby-lang.org/pub/ruby/${CI_RUBY_VERSION::-2}/ruby-$CI_RUBY_VERSION.tar.bz2 > ../ruby-$CI_RUBY_VERSION.tar.gz
cd .. cd ..
tar --extract --bzip2 --verbose --file ruby-2.6.0.tar.gz tar --extract --bzip2 --verbose --file ruby-$CI_RUBY_VERSION.tar.gz
cd ruby-2.6.0 cd ruby-$CI_RUBY_VERSION
./configure ./configure
make make
make update-gems make update-gems
@@ -31,9 +36,9 @@ jobs:
- type: cache-save - type: cache-save
name: Ruby Store name: Ruby Store
key: ruby key: ruby-{{checksum ".ruby-version"}}
paths: paths:
- ../ruby-2.6.0 - ../ruby-$CI_RUBY_VERSION
- type: cache-restore - type: cache-restore
name: Bundler Cache Restore name: Bundler Cache Restore