Files
carbon-lang/.github/workflows/tests.yaml
T
Jon Ross-Perkins e45ab50e5b Switch testing to pre-installed versions of clang-14 (#2402)
We keep seeing fragility installing software, with both brew (e.g., the recent python issues) and apt.llvm.org (currently flaky).

At this point, images for both ubuntu and macos have versions of llvm-14 that seem to successfully compile:
https://github.com/carbon-language/carbon-lang/actions/runs/3474670746/jobs/5808098087

Although we may want to figure out a way to resume running llvm-15 so that we can see compatibility issues, this seems preferable for baseline testing in order to reduce maintenance churn.

In addition to the above changes, this also configures cancellation more precisely, and stops installing bazel/bazelisk (it should already be preinstalled).
2022-11-17 08:54:44 -08:00

145 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*'
# Cancel previous workflows on the PR when there are multiple fast commits.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
matrix:
# At present, these images are newer than "latest". We use them to test
# against more recent tooling versions.
# https://github.com/actions/runner-images
os: [ubuntu-22.04, macos-12]
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'
# Use LLVM 14 following:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
- name: Setup LLVM and Clang (macOS)
if: matrix.os == 'macos-12'
run: |
echo "$(brew --prefix llvm@14)/bin" >> $GITHUB_PATH
# Use LLVM 14 following:
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
- name: Setup LLVM and Clang (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
echo "/usr/lib/llvm-14/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
# We need to replace the `.` with a `_` for the build cache.
- name: Setup LLVM and Clang (macOS)
if: matrix.os == 'macos-12'
run: |
echo "os_for_cache=macos-12" >> $GITHUB_ENV
- name: Setup LLVM and Clang (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
echo "os_for_cache=ubuntu-22_04" >> $GITHUB_ENV
# 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}-${{ env.os_for_cache }}
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