mirror of
https://github.com/actions/runner-images.git
synced 2026-01-05 01:35:22 +08:00
[macos] improve brew caching approach (#8630)
This commit is contained in:
@@ -5,8 +5,8 @@ source ~/utils/utils.sh
|
||||
arch=$(get_arch)
|
||||
|
||||
echo "Installing Homebrew..."
|
||||
HOMEBREW_INSTALL_URL="https://raw.githubusercontent.com/Homebrew/install/master/install.sh"
|
||||
/bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"
|
||||
download_with_retries "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" "/tmp" "homebrew-install.sh"
|
||||
/bin/bash /tmp/homebrew-install.sh
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
/opt/homebrew/bin/brew update
|
||||
|
||||
@@ -7,7 +7,8 @@ source ~/utils/utils.sh
|
||||
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
VERSION=$(curl "${authString[@]}" -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name')
|
||||
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash
|
||||
download_with_retries "https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh" "/tmp" "nvm-install.sh"
|
||||
bash /tmp/nvm-install.sh
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
. ~/.bashrc
|
||||
|
||||
@@ -179,9 +179,7 @@ brew_smart_install() {
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew deps $tool_name > /tmp/$tool_name && failed=false || sleep 60
|
||||
if [ "$failed" = false ]; then
|
||||
break
|
||||
fi
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
@@ -189,14 +187,12 @@ brew_smart_install() {
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
for dep in $(cat /tmp/$tool_name); do
|
||||
for dep in $(cat /tmp/$tool_name) $tool_name; do
|
||||
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew --cache $dep && failed=false || sleep 60
|
||||
if [ "$failed" = false ]; then
|
||||
break
|
||||
fi
|
||||
brew --cache $dep >/dev/null && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
@@ -205,7 +201,17 @@ brew_smart_install() {
|
||||
fi
|
||||
done
|
||||
|
||||
brew install $tool_name
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew install $tool_name >/dev/null && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
echo "Failed: brew install $tool_name"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user