Files
carbon-lang/.github/workflows/tests.yaml
T
Jon Ross-Perkins 9be6939ee9 Fix LLVM compilation issues (#2198)
We've been having issues with asan builds on linux. This change should fix all of that. A build run can be found at:
https://github.com/carbon-language/carbon-lang/actions/runs/3093378863/jobs/5005683059

(currently in progress, but I'm expecting it to succeed at this point)

It may be that the issues with asan builds were actually related to caching. That is, maybe the brew build command didn't change enough between v14 and v15 that the cache hits were still an issue. We did notice this with 15.0.0 versus 15.0.1 include paths (that is, bazel wasn't happy using the cached results of a 15.0.0 build due to the skew in include paths). In order to address this, I've added CACHE_VERSION to the remote_cache setup. I've also set up corresponding buckets in Cloud.

However, I'm also switching Linux to llvm-15 and apt. I'd originally been looking at this because the issues were linux-specific, and we've previously had linux-specific issues with Homebrew. Although it may have been the cache all along, I would prefer to keep this setup (if nothing else, it made the caching issues more obvious, even though we were still confused by the include path manifestation).
2022-09-20 14:21:02 -07:00

151 lines
5.0 KiB
YAML

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: test
on:
push:
branches: [trunk]
paths:
# Conservatively run the tests. However, skip them if the only paths in
# the pull request match files that we know don't impact the build.
- '**'
- '!**/*.md'
- '!LICENSE'
- '!CODEOWNERS'
- '!.git*'
pull_request_target:
paths:
# Conservatively run the tests. However, skip them if the only paths in
# the pull request match files that we know don't impact the build.
- '**'
- '!**/*.md'
- '!LICENSE'
- '!CODEOWNERS'
- '!.git*'
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
build_mode: [fastbuild, opt]
runs-on: ${{ matrix.os }}
steps:
# Checkout the pull request head or the branch.
- name: Checkout pull request
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout branch
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v3
# Setup Python and related tools.
- uses: actions/setup-python@v4
with:
# Match the min version listed in docs/project/contribution_tools.md
python-version: '3.9'
# On macOS we need Go and to use it to install Bazelisk.
- uses: actions/setup-go@v3
if: matrix.os == 'macos-latest'
- name: Install bazelisk
if: matrix.os == 'macos-latest'
run: |
go get github.com/bazelbuild/bazelisk
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
# On macOS, use Homebrew to install a recent LLVM and Clang.
- name: Setup LLVM and Clang (macOS)
if: matrix.os == 'macos-latest'
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
echo '*** Updating brew'
brew update
echo '*** Installing LLVM deps'
brew install --force-bottle --only-dependencies llvm
echo '*** Installing LLVM itself'
brew install --force-bottle --force --verbose llvm
echo '*** brew info llvm'
brew info llvm
echo '*** brew config'
brew config
echo '*** Updating PATH'
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
# On Ubuntu, use apt.llvm.org to install a recent LLVM and Clang.
- name: Setup LLVM and Clang (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 15 all
rm llvm.sh
echo "/usr/lib/llvm-15/bin" >> $GITHUB_PATH
# Print the various tool paths and versions to help in debugging.
- name: Print tool debugging info
run: |
echo '*** PATH'
echo $PATH
echo '*** bazelisk'
which bazelisk
bazelisk --version
echo '*** python'
which python
python --version
echo '*** clang'
which clang
clang --version
echo '*** clang++'
which clang++
clang++ --version
# Extract our access key for our build cache.
- name: Extract access key
env:
GCP_BUILDS_SERVICE_ACCOUNT: ${{ secrets.GCP_BUILDS_SERVICE_ACCOUNT }}
run: |
echo "$GCP_BUILDS_SERVICE_ACCOUNT" \
| base64 -d > $HOME/gcp-builds-service-account.json
# Add our bazel configuration and print basic info to ease debugging.
- name: Configure Bazel and print info
env:
# Add a cache version for changes that bazel won't otherwise detect,
# like llvm version changes.
CACHE_VERSION: 1
run: |
cat >user.bazelrc <<EOF
# Enable remote cache for our CI.
build --remote_cache=https://storage.googleapis.com/carbon-builds-github-v${CACHE_VERSION}-${{ matrix.os }}
build --google_credentials=$HOME/gcp-builds-service-account.json
# General build options.
build --verbose_failures
test --test_output=errors
EOF
bazelisk info
# Build all targets first to isolate build failures.
- name: Build (${{ matrix.build_mode }})
env:
# 'libtool_check_unique failed to generate' workaround.
# https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
run: bazelisk build -c ${{ matrix.build_mode }} //...:all
# Run all test targets.
- name: Test (${{ matrix.build_mode }})
env:
# 'libtool_check_unique failed to generate' workaround.
# https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
run: bazelisk test -c ${{ matrix.build_mode }} //...:all