action.yml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: Setup build environment (macOS)
  5. inputs:
  6. matrix_runner:
  7. required: true
  8. runs:
  9. using: composite
  10. steps:
  11. # Free up disk space as the macOS runners end up using most for Xcode
  12. # versions we don't need and iOS simulators.
  13. - name: Free up disk space
  14. shell: bash
  15. run: |
  16. # The xcrun occasionally fails (maybe a race condition?), so retry a few
  17. # times. Example failure:
  18. # "data" couldn't be moved to "Deleting-<ID>"
  19. echo '*** Delete iOS simulators'
  20. xcrun simctl delete all || \
  21. xcrun simctl delete all || \
  22. xcrun simctl delete all
  23. sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
  24. # Install and cache LLVM 19 from Homebrew. Some runners may have LLVM 19,
  25. # but this is reliable (including with libc++), and gives us testing at the
  26. # minimum supported LLVM version.
  27. - name: Cache Homebrew
  28. id: cache-homebrew-macos
  29. uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
  30. with:
  31. # Cover all the critical parts of Homebrew here. Homebrew on Arm macOS
  32. # uses its own prefix making this easy to cover, but we need a few
  33. # different paths for Intel.
  34. path: |
  35. ${{
  36. runner.arch == 'ARM64' && '/opt/homebrew' ||
  37. '
  38. /usr/local/Homebrew
  39. /usr/local/Cellar
  40. /usr/local/Frameworks
  41. /usr/local/bin
  42. /usr/local/opt
  43. '
  44. }}
  45. # Note the key needs to include all the packages we're adding.
  46. key:
  47. Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}-llvm@19
  48. - name: Install LLVM and Clang with Homebrew
  49. if: steps.cache-homebrew-macos.outputs.cache-hit != 'true'
  50. shell: bash
  51. run: |
  52. echo '*** Prune brew leaves'
  53. # We prune all the leaf packages to have a minimal environment. This
  54. # both minimizes the install space and avoids accidental dependencies
  55. # on installed packages.
  56. brew leaves
  57. LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$')
  58. brew uninstall -f --ignore-dependencies $LEAVES
  59. echo '*** Installing LLVM deps'
  60. brew install --force-bottle --only-dependencies llvm@19
  61. echo '*** Installing LLVM itself'
  62. brew install --force-bottle --force --verbose llvm@19
  63. echo '*** brew info llvm@19'
  64. brew info llvm@19
  65. echo '*** brew autoremove'
  66. brew autoremove
  67. echo '*** brew info'
  68. brew info
  69. echo '*** brew leaves'
  70. brew leaves
  71. echo '*** brew config'
  72. brew config
  73. - name: Setup LLVM and Clang
  74. shell: bash
  75. run: |
  76. LLVM_PATH="$(brew --prefix llvm@19)"
  77. echo "Using ${LLVM_PATH}"
  78. echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
  79. echo '*** ls "${LLVM_PATH}"'
  80. ls "${LLVM_PATH}"
  81. echo '*** ls "${LLVM_PATH}/bin"'
  82. ls "${LLVM_PATH}/bin"