Files
carbon-lang/.github/actions/build-setup-macos/action.yml
T
dependabot[bot] 4e4b35e6e7 Bump the github-actions-major group across 5 directories with 9 updates (#8098)
- `actions/cache` 5.0.3 -> 6.1.0 (major)
- `actions/checkout` 6.0.2 -> 7.0.1 (major)
- `actions/configure-pages` 5.0.0 -> 6.0.0 (major)
- `actions/deploy-pages` 4.0.5 -> 5.0.1 (major)
- `actions/stale` 9.0.0 -> 11.0.0 (major)
- `actions/upload-pages-artifact` 4.0.0 -> 5.0.0 (major)
- `astral-sh/setup-uv` 8.1.0 -> 10.3.3 (major)
- `dorny/paths-filter` 3.0.2 -> 4.0.3 (major)
- `jlumbroso/free-disk-space` 1.3.1 -> 2.0.0 (major)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-06 03:12:37 +00:00

87 lines
3.2 KiB
YAML

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Setup build environment (macOS)
inputs:
matrix_runner:
required: true
runs:
using: composite
steps:
# Free up disk space as the macOS runners end up using most for Xcode
# versions we don't need and iOS simulators.
- name: Free up disk space
shell: bash
run: |
# The xcrun occasionally fails (maybe a race condition?), so retry a few
# times. Example failure:
# "data" couldn't be moved to "Deleting-<ID>"
echo '*** Delete iOS simulators'
xcrun simctl delete all || \
xcrun simctl delete all || \
xcrun simctl delete all
sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
# Install and cache LLVM 21 from Homebrew. Some runners may have LLVM 21,
# but this is reliable (including with libc++), and gives us testing at the
# minimum supported LLVM version.
- name: Cache Homebrew
id: cache-homebrew-macos
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
# Cover all the critical parts of Homebrew here. Homebrew on Arm macOS
# uses its own prefix making this easy to cover, but we need a few
# different paths for Intel.
path: |
${{
runner.arch == 'ARM64' && '/opt/homebrew' ||
'
/usr/local/Homebrew
/usr/local/Cellar
/usr/local/Frameworks
/usr/local/bin
/usr/local/opt
'
}}
# Note the key needs to include all the packages we're adding.
key:
Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}-llvm@21
- name: Install LLVM and Clang with Homebrew
if: steps.cache-homebrew-macos.outputs.cache-hit != 'true'
shell: bash
run: |
echo '*** Prune brew leaves'
# We prune all the leaf packages to have a minimal environment. This
# both minimizes the install space and avoids accidental dependencies
# on installed packages.
brew leaves
LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$')
brew uninstall -f --ignore-dependencies $LEAVES
echo '*** Installing LLVM deps'
brew install --force-bottle --only-dependencies llvm@21
echo '*** Installing LLVM itself'
brew install --force-bottle --force --verbose llvm@21
echo '*** brew info llvm@21'
brew info llvm@21
echo '*** brew autoremove'
brew autoremove
echo '*** brew info'
brew info
echo '*** brew leaves'
brew leaves
echo '*** brew config'
brew config
- name: Setup LLVM and Clang
shell: bash
run: |
LLVM_PATH="$(brew --prefix llvm@21)"
echo "Using ${LLVM_PATH}"
echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
echo '*** ls "${LLVM_PATH}"'
ls "${LLVM_PATH}"
echo '*** ls "${LLVM_PATH}/bin"'
ls "${LLVM_PATH}/bin"