From 1611afed904eede84aa82ab5671858731b064c91 Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Fri, 6 Oct 2023 20:19:33 +0100 Subject: [PATCH] Additional github runner configurations Adds debug and address-sanitizer build configurations to the test workflow. At the time of writing these are advisory. Temporarily drop benchmarks from asan and debug builds for github runner limits. --- .bazelrc | 20 ++++++++ .github/workflows/test.yml | 97 ++++++++++++++++++++++---------------- 2 files changed, 76 insertions(+), 41 deletions(-) diff --git a/.bazelrc b/.bazelrc index 68ba9d26595..2fb57a6f4d4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -80,6 +80,14 @@ build:sanitizer-common --copt="-fno-omit-frame-pointer" --copt="-mno-omit-leaf-f build:asan --config=sanitizer-common build:asan --copt="-fsanitize=address" --linkopt="-fsanitize=address" build:asan --test_env=ASAN_OPTIONS=abort_on_error=true +# Exclude benchmarks from asan build due to large size (exceed github runner limits) +build:asan -- -//src/workerd/tests:bench-api-headers +build:asan -//src/workerd/tests:bench-global-scope +build:asan -//src/workerd/tests:bench-json +build:asan -//src/workerd/tests:bench-kj-headers +build:asan -//src/workerd/tests:bench-mimetype +build:asan -//src/workerd/tests:bench-regex +build:asan -//src/workerd/tests:bench-tools # # Linux and macOS @@ -194,3 +202,15 @@ build:windows --per_file_copt='external/v8/src/objects/swiss-name-dictionary\.cc # enable clang coverage: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html build:clang-coverage --copt="-fprofile-instr-generate" --linkopt="-fprofile-instr-generate" build:clang-coverage --copt="-fcoverage-mapping" --linkopt="-fcoverage-mapping" + +# Debug +build:debug -c dbg +# Exclude benchmarks from debug build build due to large size (exceed github runner limits) +# Each benchmark debug binary is over 900MB. +build:debug -- -//src/workerd/tests:bench-api-headers +build:debug -//src/workerd/tests:bench-global-scope +build:debug -//src/workerd/tests:bench-json +build:debug -//src/workerd/tests:bench-kj-headers +build:debug -//src/workerd/tests:bench-mimetype +build:debug -//src/workerd/tests:bench-regex +build:debug -//src/workerd/tests:bench-tools diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ea032ba95f..a74333b2fd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,17 +12,36 @@ jobs: test: strategy: matrix: - os: [ubuntu-20.04, macos-latest, windows-2022] + os: + [ + { "name" : "linux", image : "ubuntu-20.04" }, + { "name" : "macOS", image : "macos-latest" }, + { "name" : "windows", image : "windows-2022" } + ] + config: + [ + # Default build: no suffix or additional bazel arguments + {"suffix": "", "bazel-args": "" }, + # Debug build + {"suffix": "-debug", "bazel-args": "--config=debug" } + ] include: - - os-name: linux - os: ubuntu-20.04 - - os-name: macOS - os: macos-latest - - os-name: windows - os: windows-2022 + # ASAN on Linux only here + - os: { "name": "linux", "image": "ubuntu-20.04" } + config: { "suffix": "-asan", "bazel-args": "--config=asan" } + # macOS needs local spawn strategy for debug symbols to work properly. + - os: { "name": "linux", "image": "ubuntu-20.04" } + config: { "suffix": "-debug", "bazel-args": "--config=debug --spawn_strategy=local" } + # Windows has a custom non-debug bazel config + - os: { "name" : "windows", image : "windows-2022" } + config: { "suffix": "", "bazel-args": "--config=windows_no_dbg" } + exclude: + # Don't build with the matrix generated no-debug bazel config for Windows + - os: { "name" : "windows", image : "windows-2022" } + config: { "suffix": "", "bazel-args": "" } fail-fast: false - runs-on: ${{ matrix.os }} - name: test (${{ matrix.os-name }}) + runs-on: ${{ matrix.os.image }} + name: test (${{ matrix.os.name }}${{ matrix.config.suffix}}) steps: - uses: actions/checkout@v3 - name: Cache @@ -30,12 +49,12 @@ jobs: uses: actions/cache@v3 with: path: ~/bazel-disk-cache - key: bazel-disk-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} + key: bazel-disk-cache-${{ matrix.os.name }}-${{ runner.arch }}${{ matrix.config.suffix}}-${{ 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 == 'Linux' + if: matrix.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 @@ -45,50 +64,46 @@ jobs: # 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 - 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 + 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 == 'macOS' + if: matrix.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 + 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 == '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. + if: matrix.os.name == 'windows' + # Set a custom output dir and disable generating debug information on Windows. 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" + [System.IO.File]::WriteAllLines((Join-Path -Path $env:USERPROFILE -ChildPath '.bazelrc'), 'startup --output_user_root=C:/tmp') + # 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 --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --verbose_failures //... + 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 --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 //... + 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 - + 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