tests.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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@v2
  37. with:
  38. ref: ${{ github.event.pull_request.head.sha }}
  39. submodules: true
  40. - name: Checkout branch
  41. if: github.event_name != 'pull_request_target'
  42. uses: actions/checkout@v2
  43. with:
  44. submodules: true
  45. # Setup Python and related tools.
  46. - uses: actions/setup-python@v2
  47. with:
  48. # Match the min version listed in docs/project/contribution_tools.md
  49. python-version: '3.9'
  50. # On macOS we need Go and to use it to install Bazelisk.
  51. - uses: actions/setup-go@v2
  52. if: matrix.os == 'macos-latest'
  53. - name: Install bazelisk
  54. if: matrix.os == 'macos-latest'
  55. run: |
  56. go get github.com/bazelbuild/bazelisk
  57. echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
  58. # Setup to the latest LLVM and Clang release on Linux runners.
  59. #
  60. # Ideally we would use the pre-installed versions in the image, but the
  61. # debian packages for LLVM-12 are broken due to several bugs:
  62. # https://bugs.llvm.org/show_bug.cgi?id=43604
  63. # https://bugs.llvm.org/show_bug.cgi?id=46321
  64. #
  65. # For now, we rely on Homebrew to manage installing a correctly built
  66. # toolchain. We also take some care to be as resilient as possible to
  67. # issues fetching and installing the toolchain.
  68. - name: Setup LLVM and Clang on Ubuntu
  69. if: matrix.os == 'ubuntu-latest'
  70. run: |
  71. brew update
  72. brew install --force-bottle --only-dependencies llvm
  73. brew install --force-bottle --force --verbose llvm
  74. brew info llvm
  75. brew config
  76. echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
  77. # Just add the Homebrew installed LLVM to the path on macOS, the image has
  78. # LLVM-12 pre-installed.
  79. - name: Setup LLVM and Clang on macOS
  80. if: matrix.os == 'macos-latest'
  81. run: |
  82. echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
  83. # Print the various tool paths and versions to help in debugging.
  84. - name: Print tool debugging info
  85. run: |
  86. echo $PATH
  87. which bazelisk
  88. bazelisk --version
  89. which python
  90. python --version
  91. which clang
  92. clang --version
  93. which clang++
  94. clang++ --version
  95. which clang-format
  96. clang-format --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