Skip to content

Commit

Permalink
ci: API booster tests. (envoyproxy#9453)
Browse files Browse the repository at this point in the history
Run API booster unit and golden tests under the bazel.api target.

Signed-off-by: Harvey Tuch <htuch@google.com>
  • Loading branch information
htuch committed Dec 26, 2019
1 parent 9732e0c commit 3876cda
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ executors:
description: "A regular build executor based on ubuntu image"
docker:
# NOTE: Update this from https://github.com/envoyproxy/envoy-build-tools/blob/master/toolchains/rbe_toolchains_config.bzl#L7
- image: envoyproxy/envoy-build-ubuntu@sha256:3ca8acc35fdb57ab26e1bb5f9488f37095f45acd77a12602510410dbefa00b58
- image: envoyproxy/envoy-build-ubuntu@sha256:3788a87461f2b3dc8048ad0ce5df40438a56e0a8f1a4ab0f61b4ef0d8c11ff1f
resource_class: xlarge
working_directory: /source

Expand Down
1 change: 1 addition & 0 deletions bazel/setup_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build:clang --action_env=PATH=${PATH}
build:clang --action_env=CC=clang
build:clang --action_env=CXX=clang++
build:clang --action_env=LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config
build:clang --repo_env=LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config
build:clang --linkopt=-L$(llvm-config --libdir)
build:clang --linkopt=-Wl,-rpath,$(llvm-config --libdir)
Expand Down
3 changes: 2 additions & 1 deletion ci/build_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function cleanup() {
cleanup
trap cleanup EXIT

bazel/setup_clang.sh /opt/llvm
export LLVM_ROOT=/opt/llvm
bazel/setup_clang.sh "${LLVM_ROOT}"

[[ "${BUILD_REASON}" != "PullRequest" ]] && BAZEL_EXTRA_TEST_OPTIONS+=" --nocache_test_results --test_output=all"

Expand Down
5 changes: 5 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ elif [[ "$CI_TARGET" == "bazel.api" ]]; then
echo "Testing API..."
bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c fastbuild @envoy_api//test/... @envoy_api//tools/... \
@envoy_api//tools:tap2pcap_test
echo "Testing API boosting (unit tests)..."
bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c fastbuild @envoy_dev//clang_tools/api_booster/...
echo "Testing API boosting (golden C++ tests)..."
# We use custom BAZEL_BUILD_OPTIONS here; the API booster isn't capable of working with libc++ yet.
LLVM_CONFIG="${LLVM_ROOT}"/bin/llvm-config BAZEL_BUILD_OPTIONS="--config=clang" python3.8 ./tools/api_boost/api_boost_test.py
exit 0
elif [[ "$CI_TARGET" == "bazel.coverage" ]]; then
setup_clang_toolchain
Expand Down
9 changes: 7 additions & 2 deletions tools/api_boost/api_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
import multiprocessing as mp
import pathlib
import re
import shlex
import subprocess as sp

# Detect API #includes.
API_INCLUDE_REGEX = re.compile('#include "(envoy/.*)/[^/]+\.pb\.(validate\.)?h"')

# Needed for CI to pass down bazel options.
BAZEL_BUILD_OPTIONS = shlex.split(os.environ.get('BAZEL_BUILD_OPTIONS', ''))


# Obtain the directory containing a path prefix, e.g. ./foo/bar.txt is ./foo,
# ./foo/ba is ./foo, ./foo/bar/ is ./foo/bar.
Expand Down Expand Up @@ -123,13 +127,14 @@ def ApiBoostTree(target_paths,
'build',
'--strip=always',
'@envoy_dev//clang_tools/api_booster',
] + extra_api_booster_args,
] + BAZEL_BUILD_OPTIONS + extra_api_booster_args,
check=True)
sp.run([
'bazel',
'build',
'--strip=always',
] + dep_lib_build_targets, check=True)
] + BAZEL_BUILD_OPTIONS + dep_lib_build_targets,
check=True)

# Figure out where the LLVM include path is. We need to provide this
# explicitly as the api_booster is built inside the Bazel cache and doesn't
Expand Down
2 changes: 1 addition & 1 deletion tools/clang_tools/api_booster/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ApiBooster : public clang::ast_matchers::MatchFinder::MatchCallback,
const clang::SourceManager& source_manager) {
auto* direct_callee = call_expr.getDirectCallee();
if (direct_callee != nullptr) {
const std::unordered_map<std::string, int> ValidateNameToArg = {
const std::unordered_map<std::string, uint32_t> ValidateNameToArg = {
{"loadFromYamlAndValidate", 1},
{"loadFromFileAndValidate", 1},
{"downcastAndValidate", 0},
Expand Down
1 change: 0 additions & 1 deletion tools/clang_tools/support/BUILD.prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ cc_library(
linkopts = [
"-lcurses",
"-lpthread",
"-lz",
],
deps = [
":llvm_demangle",
Expand Down
3 changes: 2 additions & 1 deletion tools/clang_tools/support/clang_tools.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
def clang_tools_cc_binary(name, copts = [], tags = [], **kwargs):
def clang_tools_cc_binary(name, copts = [], tags = [], deps = [], **kwargs):
native.cc_binary(
name = name,
copts = copts + [
"-fno-exceptions",
"-fno-rtti",
],
tags = tags + ["manual"],
deps = deps + ["@envoy//bazel/foreign_cc:zlib"],
**kwargs
)

Expand Down

0 comments on commit 3876cda

Please sign in to comment.