tests.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. run: |
  67. brew update
  68. brew install --force-bottle --only-dependencies llvm
  69. brew install --force-bottle --force --verbose llvm
  70. brew info llvm
  71. brew config
  72. echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
  73. # Print the various tool paths and versions to help in debugging.
  74. - name: Print tool debugging info
  75. run: |
  76. echo $PATH
  77. which bazelisk
  78. bazelisk --version
  79. which python
  80. python --version
  81. which clang
  82. clang --version
  83. which clang++
  84. clang++ --version
  85. # Extract our access key for our build cache.
  86. - name: Extract access key
  87. env:
  88. GCP_BUILDS_SERVICE_ACCOUNT: ${{ secrets.GCP_BUILDS_SERVICE_ACCOUNT }}
  89. run: |
  90. echo "$GCP_BUILDS_SERVICE_ACCOUNT" \
  91. | base64 -d > $HOME/gcp-builds-service-account.json
  92. # Add our bazel configuration and print basic info to ease debugging.
  93. - name: Configure Bazel and print info
  94. run: |
  95. cat >user.bazelrc <<EOF
  96. # Enable remote cache for our CI.
  97. build --remote_cache=https://storage.googleapis.com/carbon-builds-github-${{ matrix.os }}
  98. build --google_credentials=$HOME/gcp-builds-service-account.json
  99. # General build options.
  100. build --verbose_failures
  101. test --test_output=errors
  102. EOF
  103. bazelisk info
  104. # Build all targets first to isolate build failures.
  105. - name: Build (${{ matrix.build_mode }})
  106. env:
  107. # 'libtool_check_unique failed to generate' workaround.
  108. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  109. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  110. run: bazelisk build -c ${{ matrix.build_mode }} //...:all
  111. # Run all test targets.
  112. - name: Test (${{ matrix.build_mode }})
  113. env:
  114. # 'libtool_check_unique failed to generate' workaround.
  115. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  116. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  117. run: bazelisk test -c ${{ matrix.build_mode }} //...:all