mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-29 12:58:00 +08:00
[macOS] Pre-cache Ruby binaries (#2085)
* precache ruby binaries * remove github_feed_token and minor change * do not install ruby binaries from toolset * remove toolcache file
This commit is contained in:
committed by
GitHub
parent
38b0a6005d
commit
75d141eb67
@@ -4,3 +4,40 @@ source ~/utils/utils.sh
|
||||
|
||||
echo Installing Ruby...
|
||||
brew install ruby
|
||||
|
||||
#if High Sierra - skip installation from toolset
|
||||
if is_HighSierra; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Install Ruby from toolset..."
|
||||
PACKAGE_TAR_NAMES=$(curl -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
|
||||
TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]')
|
||||
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"
|
||||
|
||||
echo "Check if Ruby hostedtoolcache folder exists..."
|
||||
if [ ! -d $RUBY_PATH ]; then
|
||||
mkdir -p $RUBY_PATH
|
||||
fi
|
||||
|
||||
for TOOLSET_VERSION in ${TOOLSET_VERSIONS[@]}; do
|
||||
PACKAGE_TAR_NAME=$(echo "$PACKAGE_TAR_NAMES" | grep "^ruby-${TOOLSET_VERSION}-macos-latest.tar.gz$" | sort -V | tail -1)
|
||||
RUBY_VERSION=$(echo "$PACKAGE_TAR_NAME" | cut -d'-' -f 2)
|
||||
RUBY_VERSION_PATH="$RUBY_PATH/$RUBY_VERSION"
|
||||
|
||||
echo "Create Ruby $RUBY_VERSION directory..."
|
||||
mkdir -p $RUBY_VERSION_PATH
|
||||
|
||||
echo "Downloading tar archive $PACKAGE_TAR_NAME"
|
||||
DOWNLOAD_URL="https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}"
|
||||
download_with_retries $DOWNLOAD_URL "/tmp" $PACKAGE_TAR_NAME
|
||||
|
||||
echo "Expand '$PACKAGE_TAR_NAME' to the '$RUBY_VERSION_PATH' folder"
|
||||
tar xf "/tmp/$PACKAGE_TAR_NAME" -C $RUBY_VERSION_PATH
|
||||
|
||||
COMPLETE_FILE_PATH="$RUBY_VERSION_PATH/x64.complete"
|
||||
if [ ! -f $COMPLETE_FILE_PATH ]; then
|
||||
echo "Create complete file"
|
||||
touch $COMPLETE_FILE_PATH
|
||||
fi
|
||||
done
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# Download hosted tool cache with npm
|
||||
NPM_FEED="npm.pkg.github.com"
|
||||
TOOLSET_PATH="$HOME/image-generation/toolcache.json"
|
||||
|
||||
echo "Installing npm-toolcache..."
|
||||
PACKAGE_LIST=($(jq -r 'keys | .[]' $TOOLSET_PATH))
|
||||
|
||||
# Execute in /tmp folder to avoid node_modules creation in $HOME
|
||||
pushd /tmp
|
||||
|
||||
# GitHub Package Registry doesn't support downloading public packages without auth so we have to authorize
|
||||
# Put the .npmrc to /tmp directory on the image to make sure that it will deleted after image generation
|
||||
echo "Configure auth for github package registry"
|
||||
echo "@actions:registry=https://${NPM_FEED}/" >> ".npmrc"
|
||||
echo "//${NPM_FEED}/:_authToken=${GITHUB_FEED_TOKEN}" >> ".npmrc"
|
||||
|
||||
echo "Install packages..."
|
||||
for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do
|
||||
PACKAGE_VERSIONS=($(jq -r ".[\"$PACKAGE_NAME\"] | .[]" $TOOLSET_PATH))
|
||||
for PACKAGE_VERSION in ${PACKAGE_VERSIONS[@]}; do
|
||||
echo "Install ${PACKAGE_NAME}@${PACKAGE_VERSION}"
|
||||
|
||||
npm install ${PACKAGE_NAME}@${PACKAGE_VERSION}
|
||||
|
||||
exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "${PACKAGE_NAME}@${PACKAGE_VERSION} installation failure; Error:${exit_code}"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
done;
|
||||
done;
|
||||
|
||||
rm -f ".npmrc"
|
||||
|
||||
popd
|
||||
Reference in New Issue
Block a user