From 2ccef4f1005354274efa8c006927aec8601150d4 Mon Sep 17 00:00:00 2001 From: ilia-shipitsin <125650415+ilia-shipitsin@users.noreply.github.com> Date: Fri, 7 Jul 2023 16:24:33 +0200 Subject: [PATCH] [macos] fix XCode simulator install behaviour (#7878) * [macos] fix XCode simulator install behaviour in https://github.com/actions/runner-images/commit/3929bc9f6e249a4731ad86b7b11793af9fec2d03 was introduced regression: simulators were installed only for latest XCode-14 instance. However, they should be installed for all XCode-14 instances. let us revert that behaviour * improve code readability by moving version comparison outside loop * rework brew installation for ARM64 --- images/macos/helpers/Xcode.Installer.psm1 | 5 ----- images/macos/provision/core/homebrew.sh | 12 ++++++------ images/macos/provision/core/xcode.ps1 | 10 ++++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/images/macos/helpers/Xcode.Installer.psm1 b/images/macos/helpers/Xcode.Installer.psm1 index c0a05ca72..af7e1ec6e 100644 --- a/images/macos/helpers/Xcode.Installer.psm1 +++ b/images/macos/helpers/Xcode.Installer.psm1 @@ -163,11 +163,6 @@ function Install-AdditionalSimulatorRuntimes { [string]$Version ) - if ($Version.Split(".")[0] -lt 14) { - # Additional simulator runtimes are included by default for Xcode < 14 - return - } - Write-Host "Installing Simulator Runtimes for Xcode $Version ..." $xcodebuildPath = Get-XcodeToolPath -Version $Version -ToolName "xcodebuild" Invoke-ValidateCommand "$xcodebuildPath -downloadAllPlatforms | xcpretty" diff --git a/images/macos/provision/core/homebrew.sh b/images/macos/provision/core/homebrew.sh index 7ae4aac26..4e5b63795 100755 --- a/images/macos/provision/core/homebrew.sh +++ b/images/macos/provision/core/homebrew.sh @@ -8,12 +8,6 @@ echo "Installing Homebrew..." HOMEBREW_INSTALL_URL="https://raw.githubusercontent.com/Homebrew/install/master/install.sh" /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})" -git clone https://github.com/Homebrew/homebrew-cask $(brew --repository)/Library/Taps/homebrew/homebrew-cask --origin=origin --template= --config core.fsmonitor=false --depth 1 -git clone https://github.com/Homebrew/homebrew-core $(brew --repository)/Library/Taps/homebrew/homebrew-core --origin=origin --template= --config core.fsmonitor=false --depth 1 - -brew tap homebrew/cask -brew tap homebrew/core - if [[ $arch == "arm64" ]]; then /opt/homebrew/bin/brew update /opt/homebrew/bin/brew upgrade @@ -22,6 +16,12 @@ if [[ $arch == "arm64" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" fi +git clone https://github.com/Homebrew/homebrew-cask $(brew --repository)/Library/Taps/homebrew/homebrew-cask --origin=origin --template= --config core.fsmonitor=false --depth 1 +git clone https://github.com/Homebrew/homebrew-core $(brew --repository)/Library/Taps/homebrew/homebrew-core --origin=origin --template= --config core.fsmonitor=false --depth 1 + +brew tap homebrew/cask +brew tap homebrew/core + echo "Disabling Homebrew analytics..." brew analytics off diff --git a/images/macos/provision/core/xcode.ps1 b/images/macos/provision/core/xcode.ps1 index 0af0dcdf2..e051fa4ca 100644 --- a/images/macos/provision/core/xcode.ps1 +++ b/images/macos/provision/core/xcode.ps1 @@ -30,11 +30,13 @@ Write-Host "Configuring Xcode versions..." $xcodeVersions | ForEach-Object { Write-Host "Configuring Xcode $($_.link) ..." Invoke-XcodeRunFirstLaunch -Version $_.link -} -$latestVersion = $xcodeVersions | Sort-Object -Property link -Descending | Select-Object -First 1 -ExpandProperty link -Write-Host "Installing simulators for version $latestVersion..." -Install-AdditionalSimulatorRuntimes -Version $latestVersion + if ($_.link.Split(".")[0] -ge 14) { + # Additional simulator runtimes are included by default for Xcode < 14 + Install-AdditionalSimulatorRuntimes -Version $_.link + } + +} Invoke-XcodeRunFirstLaunch -Version $defaultXcode