tests.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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-12 are broken due to several bugs:
  59. # https://bugs.llvm.org/show_bug.cgi?id=43604
  60. # https://bugs.llvm.org/show_bug.cgi?id=46321
  61. #
  62. # For now, we rely on Homebrew to manage installing a correctly built
  63. # toolchain. We also take some care to be as resilient as possible to
  64. # issues fetching and installing the toolchain.
  65. - name: Setup LLVM and Clang
  66. env:
  67. HOMEBREW_NO_INSTALL_CLEANUP: 1
  68. run: |
  69. brew update
  70. brew install --force-bottle --only-dependencies llvm
  71. brew install --force-bottle --force --verbose llvm
  72. brew info llvm
  73. brew config
  74. echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
  75. # Print the various tool paths and versions to help in debugging.
  76. - name: Print tool debugging info
  77. run: |
  78. echo $PATH
  79. which bazelisk
  80. bazelisk --version
  81. which python
  82. python --version
  83. which clang
  84. clang --version
  85. which clang++
  86. clang++ --version
  87. # Extract our access key for our build cache.
  88. - name: Extract access key
  89. env:
  90. GCP_BUILDS_SERVICE_ACCOUNT: ${{ secrets.GCP_BUILDS_SERVICE_ACCOUNT }}
  91. run: |
  92. echo "$GCP_BUILDS_SERVICE_ACCOUNT" \
  93. | base64 -d > $HOME/gcp-builds-service-account.json
  94. # Add our bazel configuration and print basic info to ease debugging.
  95. - name: Configure Bazel and print info
  96. run: |
  97. cat >user.bazelrc <<EOF
  98. # Enable remote cache for our CI.
  99. build --remote_cache=https://storage.googleapis.com/carbon-builds-github-${{ matrix.os }}
  100. build --google_credentials=$HOME/gcp-builds-service-account.json
  101. # General build options.
  102. build --verbose_failures
  103. test --test_output=errors
  104. EOF
  105. bazelisk info
  106. # Build all targets first to isolate build failures.
  107. - name: Build (${{ matrix.build_mode }})
  108. env:
  109. # 'libtool_check_unique failed to generate' workaround.
  110. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  111. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  112. run: bazelisk build -c ${{ matrix.build_mode }} //...:all
  113. # Run all test targets.
  114. - name: Test (${{ matrix.build_mode }})
  115. env:
  116. # 'libtool_check_unique failed to generate' workaround.
  117. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  118. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  119. run: bazelisk test -c ${{ matrix.build_mode }} //...:all