tests.yaml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: test
  5. on:
  6. push:
  7. branches: [trunk]
  8. paths:
  9. # Conservatively run the tests. However, skip them if the only paths in
  10. # the pull request match files that we know don't impact the build.
  11. - '**'
  12. - '!**/*.md'
  13. - '!LICENSE'
  14. - '!CODEOWNERS'
  15. - '!.git*'
  16. pull_request_target:
  17. paths:
  18. # Conservatively run the tests. However, skip them if the only paths in
  19. # the pull request match files that we know don't impact the build.
  20. - '**'
  21. - '!**/*.md'
  22. - '!LICENSE'
  23. - '!CODEOWNERS'
  24. - '!.git*'
  25. jobs:
  26. test:
  27. strategy:
  28. matrix:
  29. os: [ubuntu-latest, macos-latest]
  30. build_mode: [fastbuild, opt]
  31. runs-on: ${{ matrix.os }}
  32. steps:
  33. # Checkout the pull request head or the branch.
  34. - name: Checkout pull request
  35. if: github.event_name == 'pull_request_target'
  36. uses: actions/checkout@v3
  37. with:
  38. ref: ${{ github.event.pull_request.head.sha }}
  39. - name: Checkout branch
  40. if: github.event_name != 'pull_request_target'
  41. uses: actions/checkout@v3
  42. # Setup Python and related tools.
  43. - uses: actions/setup-python@v4
  44. with:
  45. # Match the min version listed in docs/project/contribution_tools.md
  46. python-version: '3.9'
  47. # On macOS we need Go and to use it to install Bazelisk.
  48. - uses: actions/setup-go@v3
  49. if: matrix.os == 'macos-latest'
  50. - name: Install bazelisk
  51. if: matrix.os == 'macos-latest'
  52. run: |
  53. go get github.com/bazelbuild/bazelisk
  54. echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
  55. # Setup to the latest LLVM and Clang release.
  56. #
  57. # Ideally we would use the pre-installed versions in the image, but the
  58. # debian packages for LLVM-15 currently don't work for fastbuild.
  59. #
  60. # For now, we rely on Homebrew to manage installing a correctly built
  61. # toolchain. We also take some care to be as resilient as possible to
  62. # issues fetching and installing the toolchain.
  63. - name: Install Clang/LLVM using brew
  64. env:
  65. HOMEBREW_NO_INSTALL_CLEANUP: 1
  66. HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
  67. run: |
  68. echo '*** Updating brew'
  69. brew update
  70. echo '*** Installing LLVM deps'
  71. brew install --force-bottle --only-dependencies llvm
  72. echo '*** Installing LLVM itself'
  73. brew install --force-bottle --force --verbose llvm
  74. echo '*** brew info llvm'
  75. brew info llvm
  76. echo '*** brew config'
  77. brew config
  78. echo '*** Updating PATH'
  79. echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
  80. # Print the various tool paths and versions to help in debugging.
  81. - name: Print tool debugging info
  82. run: |
  83. echo '*** PATH'
  84. echo $PATH
  85. echo '*** bazelisk'
  86. which bazelisk
  87. bazelisk --version
  88. echo '*** python'
  89. which python
  90. python --version
  91. echo '*** clang'
  92. which clang
  93. clang --version
  94. echo '*** clang++'
  95. which clang++
  96. clang++ --version
  97. # Extract our access key for our build cache.
  98. - name: Extract access key
  99. env:
  100. GCP_BUILDS_SERVICE_ACCOUNT: ${{ secrets.GCP_BUILDS_SERVICE_ACCOUNT }}
  101. run: |
  102. echo "$GCP_BUILDS_SERVICE_ACCOUNT" \
  103. | base64 -d > $HOME/gcp-builds-service-account.json
  104. # Add our bazel configuration and print basic info to ease debugging.
  105. - name: Configure Bazel and print info
  106. run: |
  107. cat >user.bazelrc <<EOF
  108. # Enable remote cache for our CI.
  109. build --remote_cache=https://storage.googleapis.com/carbon-builds-github-${{ matrix.os }}
  110. build --google_credentials=$HOME/gcp-builds-service-account.json
  111. # General build options.
  112. build --verbose_failures
  113. test --test_output=errors
  114. EOF
  115. bazelisk info
  116. # Build all targets first to isolate build failures.
  117. - name: Build (${{ matrix.build_mode }})
  118. env:
  119. # 'libtool_check_unique failed to generate' workaround.
  120. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  121. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  122. run: bazelisk build -c ${{ matrix.build_mode }} //...:all
  123. # Run all test targets.
  124. - name: Test (${{ matrix.build_mode }})
  125. env:
  126. # 'libtool_check_unique failed to generate' workaround.
  127. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  128. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  129. run: bazelisk test -c ${{ matrix.build_mode }} //...:all