Skip to content

Commit

Permalink
bazel/ci: Prepare repo for using Engflow RBE
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Sep 23, 2024
1 parent 94a3b43 commit 4ed3710
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 29 deletions.
33 changes: 24 additions & 9 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ startup --host_jvm_args=-Xmx3g
fetch --color=yes
run --color=yes

common:rbe-envoy-engflow --color=yes

build --color=yes
build --jobs=HOST_CPUS-1
build --workspace_status_command="bash bazel/get_workspace_status"
Expand Down Expand Up @@ -43,10 +45,6 @@ build:windows --action_env=PATH --host_action_env=PATH
# Requires setting `BAZEL_VOLATILE_DIRTY` in the env.
build --action_env=BAZEL_VOLATILE_DIRTY --host_action_env=BAZEL_VOLATILE_DIRTY

# Prevent stamped caches from busting (eg in PRs)
# Requires setting `BAZEL_FAKE_SCM_REVISION` in the env.
build --action_env=BAZEL_FAKE_SCM_REVISION --host_action_env=BAZEL_FAKE_SCM_REVISION

build --test_summary=terse

build:docs-ci --action_env=DOCS_RST_CHECK=1 --host_action_env=DOCS_RST_CHECK=1
Expand Down Expand Up @@ -515,19 +513,36 @@ build:rbe-engflow --bes_timeout=3600s
build:rbe-engflow --bes_upload_mode=fully_async
build:rbe-engflow --nolegacy_important_outputs

build:cache-envoy-engflow --google_default_credentials=false
# RBE (Engflow Envoy)
build:common-envoy-engflow --google_default_credentials=false
build:common-envoy-engflow --credential_helper=*.engflow.com=%workspace%/bazel/engflow-bazel-credential-helper.sh
build:common-envoy-engflow --grpc_keepalive_time=30s

build:cache-envoy-engflow --remote_cache=grpcs://morganite.cluster.engflow.com
build:cache-envoy-engflow --remote_timeout=3600s
build:cache-envoy-engflow --credential_helper=*.engflow.com=%workspace%/bazel/engflow-bazel-credential-helper.sh
build:cache-envoy-engflow --grpc_keepalive_time=30s
build:bes-envoy-engflow --bes_backend=grpcs://morganite.cluster.engflow.com/
build:bes-envoy-engflow --bes_results_url=https://morganite.cluster.engflow.com/invocation/
build:bes-envoy-engflow --bes_timeout=3600s
build:bes-envoy-engflow --bes_upload_mode=fully_async
build:rbe-envoy-engflow --config=cache-envoy-engflow
build:rbe-envoy-engflow --config=bes-envoy-engflow
build:bes-envoy-engflow --nolegacy_important_outputs
build:rbe-envoy-engflow --remote_executor=grpcs://morganite.cluster.engflow.com
build:rbe-envoy-engflow --remote_default_exec_properties=container-image=docker://gcr.io/envoy-ci/envoy-build@sha256:7adc40c09508f957624c4d2e0f5aeecb73a59207ee6ded53b107eac828c091b2
build:rbe-envoy-engflow --jobs=200
build:rbe-envoy-engflow --define=engflow_rbe=true

build:remote-envoy-engflow --config=common-envoy-engflow
build:remote-envoy-engflow --config=cache-envoy-engflow
build:remote-envoy-engflow --config=bes-envoy-engflow
build:remote-envoy-engflow --config=rbe-envoy-engflow

# This should not normally be used its for generating profile data
build:remote-uncached-envoy-engflow --config=common-envoy-engflow
build:remote-uncached-envoy-engflow --config=bes-envoy-engflow
build:remote-uncached-envoy-engflow --config=rbe-envoy-engflow
build:remote-uncached-envoy-engflow --action_env=UNCACHED=UNCACHED6
build:remote-uncached-envoy-engflow --test_env=UNCACHED=UNCACHED6
build:remote-uncached-envoy-engflow --host_action_env=UNCACHED=UNCACHED6
# build:remote-uncached-envoy-engflow --noremote_accept_cached

#############################################################################
# debug: Various Bazel debugging flags
Expand Down
5 changes: 5 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,11 @@ alias(
}),
)

config_setting(
name = "engflow_rbe",
define_values = {"engflow_rbe": "true"},
)

selects.config_setting_group(
name = "apple",
match_any = [
Expand Down
12 changes: 0 additions & 12 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_depende
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains")
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
load("@rules_rust//rust:defs.bzl", "rust_common")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains", "rust_repository_set")

Expand Down Expand Up @@ -53,8 +51,6 @@ def envoy_dependency_imports(go_version = GO_VERSION, jq_version = JQ_VERSION, y
"wasm32-wasi",
],
)
crate_universe_dependencies()
crates_repositories()
shellcheck_dependencies()
proxy_wasm_rust_sdk_dependencies()
rules_fuzzing_dependencies(
Expand Down Expand Up @@ -200,11 +196,3 @@ def envoy_download_go_sdks(go_version):
goarch = "arm64",
version = go_version,
)

def crates_repositories():
crates_repository(
name = "dynamic_modules_rust_sdk_crate_index",
cargo_lockfile = "//source/extensions/dynamic_modules/sdk/rust:Cargo.lock",
lockfile = Label("//source/extensions/dynamic_modules/sdk/rust:Cargo.Bazel.lock"),
manifests = ["//source/extensions/dynamic_modules/sdk/rust:Cargo.toml"],
)
7 changes: 7 additions & 0 deletions bazel/envoy_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def envoy_cc_binary(
data = [],
testonly = 0,
visibility = None,
engflow_pool = None,
exec_properties = None,
external_deps = [],
repository = "",
stamp = 1,
Expand All @@ -27,6 +29,10 @@ def envoy_cc_binary(
tags = [],
features = [],
linkstatic = True):
exec_properties = exec_properties or {} | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
linker_inputs = envoy_exported_symbols_input()

if not linkopts:
Expand All @@ -42,6 +48,7 @@ def envoy_cc_binary(
data = data,
additional_linker_inputs = linker_inputs,
copts = envoy_copts(repository),
exec_properties = exec_properties,
linkopts = linkopts,
testonly = testonly,
linkstatic = linkstatic,
Expand Down
8 changes: 7 additions & 1 deletion bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def envoy_cc_library(
hdrs = [],
copts = [],
visibility = None,
engflow_pool = None,
exec_properties = None,
external_deps = [],
tcmalloc_dep = None,
repository = "",
Expand All @@ -112,7 +114,10 @@ def envoy_cc_library(
linkopts = []):
if tcmalloc_dep:
deps += tcmalloc_external_deps(repository)

exec_properties = exec_properties or {} | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
# If alwayslink is not specified, allow turning it off via --define=library_autolink=disabled
# alwayslink is defaulted on for envoy_cc_extensions to ensure the REGISTRY macros work.
if alwayslink == None:
Expand All @@ -132,6 +137,7 @@ def envoy_cc_library(
textual_hdrs = textual_hdrs,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] +
envoy_pch_deps(repository, "//source/common/common:common_pch"),
exec_properties = exec_properties,
alwayslink = alwayslink,
linkstatic = envoy_linkstatic(),
strip_include_prefix = strip_include_prefix,
Expand Down
27 changes: 26 additions & 1 deletion bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ def envoy_cc_fuzz_test(
name,
corpus,
dictionaries = [],
engflow_pool = None,
exec_properties = None,
repository = "",
size = "medium",
deps = [],
tags = [],
**kwargs):
exec_properties = exec_properties or {} | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
if not (corpus.startswith("//") or corpus.startswith(":") or corpus.startswith("@")):
corpus_name = name + "_corpus_files"
native.filegroup(
Expand All @@ -97,6 +103,7 @@ def envoy_cc_fuzz_test(
test_lib_name = name + "_lib"
envoy_cc_test_library(
name = test_lib_name,
exec_properties = exec_properties,
deps = deps + envoy_stdlib_deps() + [
repository + "//test/fuzz:fuzz_runner_lib",
repository + "//test/test_common:test_version_linkstamp",
Expand All @@ -121,6 +128,7 @@ def envoy_cc_fuzz_test(
"//conditions:default": ["$(locations %s)" % corpus_name],
}),
data = [corpus_name],
exec_properties = exec_properties,
# No fuzzing on macOS or Windows
deps = select({
"@envoy//bazel:apple": [repository + "//test:dummy_main"],
Expand Down Expand Up @@ -163,9 +171,13 @@ def envoy_cc_test(
size = "medium",
flaky = False,
env = {},
engflow_pool = None,
exec_properties = {}):
coverage_tags = tags + ([] if coverage else ["nocoverage"])

exec_properties = exec_properties or {} | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
native.cc_test(
name = name,
srcs = srcs,
Expand Down Expand Up @@ -199,6 +211,8 @@ def envoy_cc_test_library(
srcs = [],
hdrs = [],
data = [],
engflow_pool = None,
exec_properties = {},
external_deps = [],
deps = [],
repository = "",
Expand All @@ -207,6 +221,10 @@ def envoy_cc_test_library(
copts = [],
alwayslink = 1,
**kargs):
exec_properties = exec_properties | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
disable_pch = kargs.pop("disable_pch", True)
_envoy_cc_test_infrastructure_library(
name,
Expand Down Expand Up @@ -267,13 +285,20 @@ def envoy_benchmark_test(
name,
benchmark_binary,
data = [],
engflow_pool = None,
exec_properties = {},
tags = [],
repository = "",
**kargs):
exec_properties = exec_properties | select({
repository + "//bazel:engflow_rbe": {"Pool": engflow_pool} if engflow_pool else {},
"//conditions:default": {},
})
native.sh_test(
name = name,
srcs = [repository + "//bazel:test_for_benchmark_wrapper.sh"],
data = [":" + benchmark_binary] + data,
exec_properties = exec_properties,
args = ["%s/%s" % (native.package_name(), benchmark_binary)],
tags = tags + ["nocoverage"],
**kargs
Expand Down
3 changes: 2 additions & 1 deletion bazel/get_workspace_status
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ then
exit 0
fi

if [[ -n "$BAZEL_FAKE_SCM_REVISION" ]]; then
if [[ -e ".BAZEL_FAKE_SCM_REVISION" ]]; then
BAZEL_FAKE_SCM_REVISION="$(cat .BAZEL_FAKE_SCM_REVISION)"
echo "BUILD_SCM_REVISION $BAZEL_FAKE_SCM_REVISION"
echo "ENVOY_BUILD_SCM_REVISION $BAZEL_FAKE_SCM_REVISION"
echo "STABLE_BUILD_SCM_REVISION $BAZEL_FAKE_SCM_REVISION"
Expand Down
8 changes: 3 additions & 5 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1453,11 +1453,9 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_desc = "Bazel rust rules (used by Wasm)",
project_url = "https://github.com/bazelbuild/rules_rust",
version = "0.51.0",
sha256 = "042acfb73469b2d1848fe148d81c3422c61ea47a9e1900f1c9ec36f51e8e7193",
# Note: rules_rust should point to the releases, not archive to avoid the hassle of bootstrapping in crate_universe.
# This is described in https://bazelbuild.github.io/rules_rust/crate_universe.html#setup, otherwise bootstrap
# is required which in turn requires a system CC toolchains, not the bazel controlled ones.
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-v{version}.tar.gz"],
strip_prefix = "rules_rust-{version}",
sha256 = "44ffa703f95fe693c15fefb58432ad009379848d24012338a3c2eb9951b371e7",
urls = ["https://github.com/bazelbuild/rules_rust/archive/{version}.tar.gz"],
use_category = [
"controlplane",
"dataplane_core",
Expand Down

0 comments on commit 4ed3710

Please sign in to comment.