parent
bf7de745ac
commit
6816da50cf
14 changed files with 246 additions and 33 deletions
@ -0,0 +1,75 @@ |
|||||||
|
name: 'Docker Bazel Run' |
||||||
|
description: 'Run a Bazel-based docker image for Protobuf CI testing' |
||||||
|
inputs: |
||||||
|
credentials: |
||||||
|
required: true |
||||||
|
description: The GCP credentials to use for reading the docker image |
||||||
|
type: string |
||||||
|
bazel-cache: |
||||||
|
required: true |
||||||
|
description: > |
||||||
|
A unique path for the Bazel cache. This will trigger the generation |
||||||
|
of a BAZEL_CACHE environment variable inside the container that provides |
||||||
|
the appropriate flags for any bazel command. |
||||||
|
type: string |
||||||
|
version: |
||||||
|
required: false |
||||||
|
description: A pinned Bazel version to use |
||||||
|
default: '5.1.1' |
||||||
|
type: string |
||||||
|
bazel: |
||||||
|
required: false |
||||||
|
description: The Bazel command to run |
||||||
|
type: string |
||||||
|
bash: |
||||||
|
required: false |
||||||
|
description: > |
||||||
|
A bash command to run. $BAZEL_FLAGS and $BAZEL_STARTUP_FLAGS will be |
||||||
|
available to use for bazel runs. |
||||||
|
type: string |
||||||
|
|
||||||
|
runs: |
||||||
|
using: 'composite' |
||||||
|
steps: |
||||||
|
- name: Authenticate |
||||||
|
id: auth |
||||||
|
uses: ./.github/actions/internal/gcloud-auth |
||||||
|
with: |
||||||
|
credentials: ${{ inputs.credentials }} |
||||||
|
|
||||||
|
- name: Setup Runner |
||||||
|
uses: ./.github/actions/internal/setup-runner |
||||||
|
|
||||||
|
- name: Setup Bazel |
||||||
|
id: bazel |
||||||
|
uses: ./.github/actions/internal/bazel-setup |
||||||
|
with: |
||||||
|
credentials-file: ${{ steps.auth.outputs.credentials-file }} |
||||||
|
bazel-cache: ${{ inputs.bazel-cache }} |
||||||
|
|
||||||
|
- name: Validate inputs |
||||||
|
if: ${{ (inputs.bash && inputs.bazel) || (!inputs.bash && !inputs.bazel) }} |
||||||
|
shell: bash |
||||||
|
run: echo "Invalid specification of both non-Bazel and Bazel command"; exit 1 |
||||||
|
|
||||||
|
- name: Output Bazel version |
||||||
|
env: |
||||||
|
USE_BAZEL_VERSION: ${{ inputs.version }} |
||||||
|
shell: bash |
||||||
|
run: bazelisk version |
||||||
|
|
||||||
|
- name: Run Bash |
||||||
|
env: |
||||||
|
USE_BAZEL_VERSION: ${{ inputs.version }} |
||||||
|
if: ${{ inputs.bash }} |
||||||
|
run: ${{ inputs.bash }} |
||||||
|
shell: bash |
||||||
|
|
||||||
|
- name: Run Bazel |
||||||
|
env: |
||||||
|
USE_BAZEL_VERSION: ${{ inputs.version }} |
||||||
|
if: ${{ !inputs.bash }} |
||||||
|
run: > |
||||||
|
bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }} |
||||||
|
${{ inputs.bazel }} ${{ steps.bazel.outputs.bazel-flags }} |
||||||
|
shell: bash |
@ -0,0 +1,59 @@ |
|||||||
|
name: Setup Bazel |
||||||
|
description: Setup a Bazel environment for Protobuf CI testing |
||||||
|
inputs: |
||||||
|
credentials-file: |
||||||
|
required: true |
||||||
|
description: The GCP credentials file to use for caching |
||||||
|
type: string |
||||||
|
bazel-cache: |
||||||
|
required: true |
||||||
|
description: A unique path for the Bazel cache. |
||||||
|
type: string |
||||||
|
|
||||||
|
outputs: |
||||||
|
bazel-flags: |
||||||
|
description: Bazel flags that should be sent to all Bazel invocations |
||||||
|
value: ${{ steps.output.outputs.bazel-flags }} |
||||||
|
bazel-startup-flags: |
||||||
|
description: Bazel startup flags that should be sent to all Bazel invocations |
||||||
|
value: ${{ steps.output.outputs.bazel-startup-flags }} |
||||||
|
|
||||||
|
runs: |
||||||
|
using: 'composite' |
||||||
|
steps: |
||||||
|
- name: Initialize Windows startup flags |
||||||
|
if: runner.os == 'Windows' |
||||||
|
shell: bash |
||||||
|
run: echo "BAZEL_STARTUP_FLAGS=--output_user_root=C:/tmp --windows_enable_symlinks" >> $GITHUB_ENV |
||||||
|
|
||||||
|
- name: Initialize Bazel flags |
||||||
|
shell: bash |
||||||
|
run: echo "BAZEL_FLAGS=--keep_going --test_output=errors --test_timeout=600" >> $GITHUB_ENV |
||||||
|
|
||||||
|
- name: Initialize Windows-specific Bazel flags |
||||||
|
if: runner.os == 'Windows' |
||||||
|
shell: bash |
||||||
|
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --enable_runfiles" >> $GITHUB_ENV |
||||||
|
|
||||||
|
- name: Configure Bazel caching |
||||||
|
# Skip bazel cache for local act runs due to issue with credential files |
||||||
|
# and nested docker images |
||||||
|
if: ${{ inputs.bazel-cache && !github.event.act_local_test }} |
||||||
|
shell: bash |
||||||
|
run: > |
||||||
|
echo "BAZEL_FLAGS=$BAZEL_FLAGS |
||||||
|
--google_credentials='${{ inputs.credentials-file }}' |
||||||
|
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/protobuf/gha/${{ inputs.bazel-cache }}" >> $GITHUB_ENV |
||||||
|
|
||||||
|
- name: Configure Bazel cache writing |
||||||
|
# External runs should never write to our caches. |
||||||
|
if: ${{ github.event_name != 'pull_request_target' && inputs.bazel-cache && !github.event.act_local_test }} |
||||||
|
shell: bash |
||||||
|
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --remote_upload_local_results" >> $GITHUB_ENV |
||||||
|
|
||||||
|
- name: Output Bazel flags |
||||||
|
id: output |
||||||
|
shell: bash |
||||||
|
run: | |
||||||
|
echo "bazel-flags=$BAZEL_FLAGS" >> $GITHUB_OUTPUT |
||||||
|
echo "bazel-startup-flags=$BAZEL_STARTUP_FLAGS" >> $GITHUB_OUTPUT |
@ -0,0 +1,17 @@ |
|||||||
|
name: Setup CI Runner |
||||||
|
# TODO(b/267357823) Consider moving this to it's own repository and include |
||||||
|
# a call to actions/checkout. |
||||||
|
description: Setup any platform-specific adjustments we need to make for CI |
||||||
|
runs: |
||||||
|
using: 'composite' |
||||||
|
steps: |
||||||
|
- name: Fix Windows line breaks |
||||||
|
if: runner.os == 'Windows' |
||||||
|
shell: bash |
||||||
|
run: find . -type f -print0 | xargs -0 d2u 2>/dev/null |
||||||
|
|
||||||
|
- name: Install bazelrc files |
||||||
|
shell: bash |
||||||
|
run: | |
||||||
|
cp ci/*.bazelrc . |
||||||
|
cp -f ${{ runner.os }}.bazelrc .bazelrc |
@ -0,0 +1,3 @@ |
|||||||
|
import common.bazelrc |
||||||
|
|
||||||
|
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 |
@ -0,0 +1,2 @@ |
|||||||
|
import common.bazelrc |
||||||
|
|
@ -0,0 +1,33 @@ |
|||||||
|
build:dbg --compilation_mode=dbg |
||||||
|
|
||||||
|
build:opt --compilation_mode=opt |
||||||
|
|
||||||
|
build:san-common --config=dbg --strip=never --copt=-O0 --copt=-fno-omit-frame-pointer |
||||||
|
|
||||||
|
build:asan --config=san-common --copt=-fsanitize=address --linkopt=-fsanitize=address |
||||||
|
build:asan --copt=-DADDRESS_SANITIZER=1 |
||||||
|
# ASAN hits ODR violations with shared linkage due to rules_proto. |
||||||
|
build:asan --dynamic_mode=off |
||||||
|
|
||||||
|
build:msan --config=san-common --copt=-fsanitize=memory --linkopt=-fsanitize=memory |
||||||
|
build:msan --copt=-fsanitize-memory-track-origins |
||||||
|
build:msan --copt=-fsanitize-memory-use-after-dtor |
||||||
|
build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1 |
||||||
|
build:msan --copt=-DMEMORY_SANITIZER=1 |
||||||
|
|
||||||
|
# Use our instrumented LLVM libc++ in Kokoro. |
||||||
|
build:kokoro-msan --config=msan |
||||||
|
build:kokoro-msan --linkopt=-L/opt/libcxx_msan/lib |
||||||
|
build:kokoro-msan --linkopt=-Wl,-rpath,/opt/libcxx_msan/lib |
||||||
|
build:kokoro-msan --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ |
||||||
|
|
||||||
|
|
||||||
|
build:tsan --config=san-common --copt=-fsanitize=thread --linkopt=-fsanitize=thread |
||||||
|
build:tsan --copt=-DTHREAD_SANITIZER=1 |
||||||
|
|
||||||
|
build:ubsan --config=san-common --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined |
||||||
|
build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 |
||||||
|
build:ubsan --copt=-DUNDEFINED_SANITIZER=1 |
||||||
|
# Workaround for the fact that Bazel links with $CC, not $CXX |
||||||
|
# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748 |
||||||
|
build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr |
@ -0,0 +1,3 @@ |
|||||||
|
import common.bazelrc |
||||||
|
|
||||||
|
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 |
Loading…
Reference in new issue