action.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 16 from Homebrew. Some runners may have LLVM 16,
  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. env:
  31. cache-name: cache-homebrew
  32. with:
  33. # Cover all the critical parts of Homebrew here. Homebrew on Arm macOS
  34. # uses its own prefix making this easy to cover, but we need a few
  35. # different paths for Intel.
  36. path: |
  37. ${{
  38. runner.arch == 'ARM64' && '/opt/homebrew' ||
  39. '
  40. /usr/local/Homebrew
  41. /usr/local/Cellar
  42. /usr/local/Frameworks
  43. /usr/local/bin
  44. /usr/local/opt
  45. '
  46. }}
  47. # Note the key needs to include all the packages we're adding.
  48. key: Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}
  49. - name: Install LLVM and Clang with Homebrew
  50. if: steps.cache-homebrew-macos.outputs.cache-hit != 'true'
  51. shell: bash
  52. run: |
  53. echo '*** Prune brew leaves'
  54. # We prune all the leaf packages to have a minimal environment. This
  55. # both minimizes the install space and avoids accidental dependencies
  56. # on installed packages.
  57. brew leaves
  58. LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$')
  59. brew uninstall -f --ignore-dependencies $LEAVES
  60. echo '*** Installing LLVM deps'
  61. brew install --force-bottle --only-dependencies llvm@16
  62. echo '*** Installing LLVM itself'
  63. brew install --force-bottle --force --verbose llvm@16
  64. echo '*** brew info llvm@16'
  65. brew info llvm@16
  66. echo '*** brew autoremove'
  67. brew autoremove
  68. echo '*** brew info'
  69. brew info
  70. echo '*** brew leaves'
  71. brew leaves
  72. echo '*** brew config'
  73. brew config
  74. - name: Setup LLVM and Clang
  75. shell: bash
  76. run: |
  77. LLVM_PATH="$(brew --prefix llvm@16)"
  78. echo "Using ${LLVM_PATH}"
  79. echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
  80. echo '*** ls "${LLVM_PATH}"'
  81. ls "${LLVM_PATH}"
  82. echo '*** ls "${LLVM_PATH}/bin"'
  83. ls "${LLVM_PATH}/bin"