diff --git a/.semaphore/ensure-bundle.sh b/.semaphore/ensure-bundle.sh new file mode 100755 index 0000000..475c3a2 --- /dev/null +++ b/.semaphore/ensure-bundle.sh @@ -0,0 +1,18 @@ +# Ensure that the bundle is installed and cached +# + +bundle config set --local deployment true +bundle config set --local path vendor/bundle +gem update --no-doc bundler + +gemfile_checksum=$(checksum Gemfile.lock) +cache_key="${SEMAPHORE_AGENT_MACHINE_OS_IMAGE}-${RUBY_VERSION}-${gemfile_checksum}" + +if cache has_key "${cache_key}"; then + echo "Bundle for ${RUBY_VERSION} and Gemfile.lock found in cache" + cache restore "${cache_key}" +else + echo "Caching Bundle for ${RUBY_VERSION} and Gemfile.lock" + bundle install + cache store "${cache_key}" vendor/bundle +fi diff --git a/.semaphore/ensure-ruby-version.sh b/.semaphore/ensure-ruby-version.sh new file mode 100755 index 0000000..5d3ce46 --- /dev/null +++ b/.semaphore/ensure-ruby-version.sh @@ -0,0 +1,14 @@ +# Ensure the correct Ruby version is installed and cached +# +cache_key="${SEMAPHORE_AGENT_MACHINE_OS_IMAGE}-${RUBY_VERSION}" + +if cache has_key "${cache_key}"; then + echo "Ruby ${RUBY_VERSION} found in cache" + cache restore "${cache_key}" + sem-version ruby "${RUBY_VERSION}" -f +else + echo "Installing Ruby $RUBY_VERSION" + sem-version ruby "${RUBY_VERSION}" -f + cache store "${cache_key}" "${HOME}/.rbenv/versions/${RUBY_VERSION}" +fi +