Skip to content

Add linux-asan and {linux,macOS,windows}-debug to the github test workflow #4129

Add linux-asan and {linux,macOS,windows}-debug to the github test workflow

Add linux-asan and {linux,macOS,windows}-debug to the github test workflow #4129

Workflow file for this run

name: Tests
on:
pull_request:
paths-ignore:
- 'doc/**'
push:
branches:
- main
jobs:
test:
strategy:
matrix:
os: [
{ "name" : "Linux", image : "ubuntu-20.04" },
{ "name" : "macOS", image : "macos-latest" },
{ "name" : "Windows", image : "windows-2022" }
]
config: [
{"suffix": "", "bazel-args": "" },
{"suffix": "dbg", "bazel-args": "-c dbg" }
]
include:
- os: { "name": "Linux", "image": "ubuntu-20.04" }
config: {"suffix": "asan", "bazel-args": "--config=asan" }
fail-fast: false
runs-on: ${{ matrix.os.image }}
name: test (${{ matrix.os.name }}${{ matrix.config.suffix}})
steps:
- uses: actions/checkout@v3
- name: Cache
id: cache
uses: actions/cache@v3
with:
path: ~/bazel-disk-cache
key: bazel-disk-cache-${{ matrix.os.name }}${{ matrix.config.suffix}}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }}
# Intentionally not reusing an older cache entry using a key prefix, bazel frequently
# ends up with a larger cache at the end when starting with an available cache entry,
# resulting in a snowballing cache size and cache download/upload times.
- name: Setup Linux
if: runner.os.name == 'Linux'
# Install dependencies, including clang via through LLVM APT repository. Note that this
# will also install lldb and clangd alongside dependencies, which can be removed with
# `sudo apt-get remove -y lldb-14 clangd-14; sudo apt-get autoremove -y` if space is
# limited.
# libunwind, libc++abi1 and libc++1 should be automatically installed as dependencies of
# libc++, but this appears to cause errors so they are also being explicitly installed.
# Since the GitHub runner image comes with a number of preinstalled packages, we don't need
# to use APT much otherwise.
run: |
export DEBIAN_FRONTEND=noninteractive
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
sudo apt-get install -y libunwind-14 libc++abi1-14 libc++1-14 libc++-14-dev libclang-rt-14-dev
echo "build:linux --action_env=CC=/usr/lib/llvm-14/bin/clang --action_env=CXX=/usr/lib/llvm-14/bin/clang++" >> .bazelrc
echo "build:linux --host_action_env=CC=/usr/lib/llvm-14/bin/clang --host_action_env=CXX=/usr/lib/llvm-14/bin/clang++" >> .bazelrc
sed -i -e "s%llvm-symbolizer%/usr/lib/llvm-14/bin/llvm-symbolizer%" .bazelrc
- name: Setup macOS
if: runner.os.name == 'macOS'
# We want to symbolize stacks for crashes on CI. Xcode is currently based on LLVM 15
# and the macos-12 image has llvm@15 installed:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
run: |
export LLVM_SYMBOLIZER=$(brew --prefix llvm@15)/bin/llvm-symbolizer
sed -i -e "s%llvm-symbolizer%${LLVM_SYMBOLIZER}%" .bazelrc
- name: Setup Windows
if: runner.os.name == 'Windows'
# Set a custom output dir and disable generating debug information on Windows. By default,
# bazel generates huge amounts of debug information on Windows which slows down the build
# and takes up an excessive amount of cache space.
run: |
[System.IO.File]::WriteAllLines((Join-Path -Path $env:USERPROFILE -ChildPath '.bazelrc'), 'startup --output_user_root=C:/tmp')
[System.IO.File]::WriteAllLines((Join-Path -Path $env:USERPROFILE -ChildPath '.bazelrc'), 'build:windows --config=windows_no_dbg')
# Work around bazel clang 16 include path bug (https://github.com/bazelbuild/bazel/issues/17863)
Move-Item -Path "C:\Program Files\LLVM\lib\clang\16" -Destination "C:\Program Files\LLVM\lib\clang\16.0.6"
- name: Bazel build
# timestamps are no longer being added here, the GitHub logs include timestamps (Use
# 'Show timestamps' on the web interface)
run: |
bazelisk build ${{ matrix.config.bazel-args }} --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --verbose_failures //...
- name: Bazel tests
run: |
bazelisk test ${{ matrix.config.bazel-args }} --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --verbose_failures --keep_going --test_output=errors //...
- name: Report disk usage
if: always()
shell: bash
run: |
BAZEL_OUTPUT_BASE=$(bazel info --ui_event_filters=-WARNING output_base)
BAZEL_REPOSITORY_CACHE=$(bazel info --ui_event_filters=-WARNING repository_cache)
echo "Bazel cache usage statistics"
du -hs -t 1 ~/bazel-disk-cache/* $BAZEL_REPOSITORY_CACHE
echo "Bazel output usage statistics"
du -hs -t 1 $BAZEL_OUTPUT_BASE
echo "Workspace usage statistics"
du -hs -t 1 $GITHUB_WORKSPACE