action.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. remote_cache_upload:
  9. required: true
  10. runs:
  11. using: composite
  12. steps:
  13. # Setup Python and related tools.
  14. - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
  15. with:
  16. # Match the min version listed in docs/project/contribution_tools.md
  17. # or the oldest version available on the OS.
  18. python-version:
  19. ${{ inputs.matrix_runner == 'macos-14' && '3.11' || '3.9' }}
  20. - uses: ./.github/actions/build-setup-macos
  21. if: startsWith(inputs.matrix_runner, 'macos')
  22. with:
  23. matrix_runner: ${{ inputs.matrix_runner }}
  24. - uses: ./.github/actions/build-setup-ubuntu
  25. if: startsWith(inputs.matrix_runner, 'ubuntu')
  26. # Print the various tool paths and versions to help in debugging.
  27. - name: Print tool debugging info
  28. shell: bash
  29. run: |
  30. echo '*** PATH'
  31. echo $PATH
  32. echo '*** bazelisk'
  33. which bazelisk
  34. bazelisk --version
  35. echo '*** run_bazel.py'
  36. ./scripts/run_bazel.py --version
  37. echo '*** python'
  38. which python
  39. python --version
  40. echo '*** clang'
  41. which clang
  42. clang --version
  43. echo '*** clang++'
  44. which clang++
  45. clang++ --version
  46. # Add our bazel configuration and print basic info to ease debugging.
  47. - name: Configure Bazel and print info
  48. env:
  49. # Add a cache version for changes that bazel won't otherwise detect,
  50. # like llvm version changes.
  51. CACHE_VERSION: 1
  52. shell: bash
  53. run: |
  54. cat >user.bazelrc <<EOF
  55. # Disable the local disk cache as we use a remote cache and don't want
  56. # two copies of every output taking up disk space. The only way to
  57. # disable the disk cache is with an empty string:
  58. # https://github.com/bazelbuild/bazel/issues/5308
  59. build --disk_cache=
  60. # Enable remote cache for our CI but minimize downloads.
  61. build --remote_cache=https://storage.googleapis.com/carbon-builds-github-v${CACHE_VERSION}
  62. build --remote_download_minimal
  63. # We import a special key into every action in order to key the Bazel
  64. # remote cache in a way that avoids collisions between different
  65. # runners. Anything that might change the system external to Bazel but
  66. # not be fully captured by the sand-boxing of the build should be used
  67. # as part of the key. We don't need to use the CPU target for example,
  68. # as that is captured by Bazel's configuration of each action. And the
  69. # Clang version is incorporated by our Clang toolchain setup. But we
  70. # do need to capture any differences between GitHub runner OSes that
  71. # don't impact the Bazel configuration to avoid collisions between
  72. # those.
  73. build --action_env=BAZEL_REMOTE_CACHE_KEY=github-action-${{ inputs.matrix_runner }}
  74. build ${{ inputs.remote_cache_upload }}
  75. # Set an artificially high jobs count. This flag controls the number
  76. # of concurrency Bazel itself uses, which is essential for actions
  77. # that are internally blocked on for example downloading results form
  78. # the cache above. Without setting this high, Bazel will pick a small
  79. # number based on the available host CPUs and the reality will be a
  80. # long chain of largely serialized download events with little or no
  81. # usage of the host machine. Fortunately, local actions are
  82. # *separately* gated on '--local_*_resources' that will avoid a large
  83. # jobs value overwhelming the host. There is a bug to make downloads
  84. # behave completely asynchronously and remove the need for this filed
  85. # back in 2018 but work seemed to not finish:
  86. # https://github.com/bazelbuild/bazel/issues/6394
  87. #
  88. # There is a new effort (yay!) but until then it seems worth using the
  89. # workaround of a high jobs value. The biggest downside (increased
  90. # heap usage) seems like it isn't currently a big loss for our builds.
  91. #
  92. # Higher values like 50 have led to CI failures with network errors
  93. # and IOExceptions, see
  94. # https://discord.com/channels/655572317891461132/707150492370862090/1151605725576056934
  95. build --jobs=32
  96. # Avoid any cache impact from build stamping in CI.
  97. build --nostamp
  98. # General build options.
  99. build --verbose_failures
  100. test --test_output=errors
  101. EOF
  102. ./scripts/run_bazel.py info