Skip to content

Commit

Permalink
adding semaphore ensure files
Browse files Browse the repository at this point in the history
  • Loading branch information
copiousfreetime committed Mar 4, 2024
1 parent 647b41d commit e512696
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .semaphore/ensure-bundle.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions .semaphore/ensure-ruby-version.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e512696

Please sign in to comment.