Skip to content

Commit

Permalink
Configure remote builds to use EngFlow (#11887)
Browse files Browse the repository at this point in the history
This allows us to use EngFlow's remote build grid to
execute our builds. Once we hook this up into our CI
actions, this will lead to significantly faster CI
runs.
  • Loading branch information
shs96c authored May 3, 2023
1 parent 69e67ae commit d530584
Show file tree
Hide file tree
Showing 21 changed files with 1,892 additions and 25 deletions.
44 changes: 44 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ build --flag_alias=headless=//common:headless

# Set the default java toolchain

build --java_language_version=11
build --java_runtime_version=remotejdk_11
build --tool_java_language_version=11
build --tool_java_runtime_version=remotejdk_11

# We target java 8 by default

Expand Down Expand Up @@ -75,3 +77,45 @@ test:windows --test_env="PROGRAMFILES(X86)"="C:\\Program Files (x86)"
test --test_timeout=1800

test:node_debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results

# The RBE to use
build:remote --bes_results_url=https://gypsum.cluster.engflow.com/invocation
build:remote --bes_backend=grpcs://gypsum.cluster.engflow.com
build:remote --remote_executor=grpcs://gypsum.cluster.engflow.com
build:remote --remote_cache=grpcs://gypsum.cluster.engflow.com

# The number of cores available
build:remote -j 50

# Build Without The Bytes
build:remote --remote_download_outputs=minimal

build:remote --define=EXECUTOR=remote
build:remote --experimental_inmemory_dotd_files
build:remote --experimental_inmemory_jdeps_files
build:remote --remote_timeout=3600
build:remote --spawn_strategy=remote,local
#build:remote --nolegacy_important_outputs
build:remote --incompatible_strict_action_env=true

build:remote --crosstool_top=//common/remote-build/cc:toolchain
build:remote --extra_execution_platforms=//common/remote-build:platform
build:remote --extra_toolchains=//common/remote-build:cc-toolchain
build:remote --host_platform=//common/remote-build:platform
build:remote --platforms=//common/remote-build:platform

# The Docker images are running Linux
build:remote --cpu=k8
build:remote --host_cpu=k8

build:remote --disk_cache=

build:remote --incompatible_enable_cc_toolchain_resolution
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
test:remote --test_env=DISPLAY=:99.0
test:remote --test_tag_filters=-edge,-safari,-remote

# Env vars we can hard code
build:remote --action_env=HOME=/home/dev
build:remote --action_env=PATH=/bin:/usr/bin:/usr/local/bin
test:remote --test_env=HOME=/home/dev
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ bazel-testlogs
/.vscode/
/.scannerwork/
/.bazelrc.local

# Engflow
*.crt
*.key
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ default_python_version = "3.8"
python_register_multi_toolchains(
name = "python",
default_version = default_python_version,
ignore_root_user_error = True,
python_versions = [
"3.8",
"3.9",
Expand Down
6 changes: 4 additions & 2 deletions common/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ COMMON_TAGS = [
chrome_data = select({
"@selenium//common:use_pinned_linux_chrome": [
"@linux_chromedriver//:chromedriver",
"@linux_chrome//:chrome-linux",
"@linux_chrome//:files",
"@linux_chrome//:chrome-linux/chrome",
],
"@selenium//common:use_pinned_macos_chrome": [
"@mac_chromedriver//:chromedriver",
Expand All @@ -29,7 +30,8 @@ edge_data = select({
firefox_data = select({
"@selenium//common:use_pinned_linux_firefox": [
"@linux_geckodriver//:geckodriver",
"@linux_firefox//:firefox",
"@linux_firefox//:files",
"@linux_firefox//:firefox/firefox",
],
"@selenium//common:use_pinned_macos_firefox": [
"@mac_geckodriver//:geckodriver",
Expand Down
49 changes: 49 additions & 0 deletions common/remote-build/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen
# and should not be modified directly.

package(default_visibility = ["//visibility:public"])

toolchain(
name = "cc-toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
toolchain = "//common/remote-build/cc:cc-compiler-k8",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

platform(
name = "platform",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
exec_properties = {
"container-image": "docker://docker.io/shs96c/selenium-remote-build@sha256:314b60a3c2b82f512c0f3fdba0aed8983f2b9bfdf2901a4f41511abdfd6dd74a",
"OSFamily": "Linux",
"dockerReuse": "True",
"dockerRunAsRoot": "False",
"dockerUseEntrypoint": "True",
"sandboxAllowed": "False",
},
parents = ["@local_config_platform//:host"],
)
149 changes: 149 additions & 0 deletions common/remote-build/cc/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Copyright 2016 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This becomes the BUILD file for @local_config_cc// under non-BSD unixes.

load(":cc_toolchain_config.bzl", "cc_toolchain_config")
load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config")
load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")

package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

cc_library(
name = "malloc",
)

filegroup(
name = "empty",
srcs = [],
)

filegroup(
name = "cc_wrapper",
srcs = ["cc_wrapper.sh"],
)

filegroup(
name = "compiler_deps",
srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths"],
)

# This is the entry point for --crosstool_top. Toolchains are found
# by lopping off the name of --crosstool_top and searching for
# the "${CPU}" entry in the toolchains attribute.
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"k8|gcc": ":cc-compiler-k8",
"k8": ":cc-compiler-k8",
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
},
)

cc_toolchain(
name = "cc-compiler-k8",
toolchain_identifier = "local",
toolchain_config = ":local",
all_files = ":compiler_deps",
ar_files = ":compiler_deps",
as_files = ":compiler_deps",
compiler_files = ":compiler_deps",
dwp_files = ":empty",
linker_files = ":compiler_deps",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
module_map = None,
)

cc_toolchain_config(
name = "local",
cpu = "k8",
compiler = "gcc",
toolchain_identifier = "local",
host_system_name = "local",
target_system_name = "local",
target_libc = "local",
abi_version = "local",
abi_libc_version = "local",
cxx_builtin_include_directories = ["/usr/lib/gcc/x86_64-linux-gnu/9/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/include/c++/9",
"/usr/include/x86_64-linux-gnu/c++/9",
"/usr/include/c++/9/backward"],
tool_paths = {"ar": "/usr/bin/ar",
"ld": "/usr/bin/ld",
"llvm-cov": "None",
"llvm-profdata": "None",
"cpp": "/usr/bin/cpp",
"gcc": "/usr/bin/gcc",
"dwp": "/usr/bin/dwp",
"gcov": "/usr/bin/gcov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
"strip": "/usr/bin/strip"},
compile_flags = ["-fstack-protector",
"-Wall",
"-Wunused-but-set-parameter",
"-Wno-free-nonheap-object",
"-fno-omit-frame-pointer"],
opt_compile_flags = ["-g0",
"-O2",
"-D_FORTIFY_SOURCE=1",
"-DNDEBUG",
"-ffunction-sections",
"-fdata-sections"],
dbg_compile_flags = ["-g"],
cxx_flags = ["-std=c++0x"],
link_flags = ["-fuse-ld=gold",
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B/usr/bin",
"-pass-exit-codes"],
link_libs = ["-lstdc++",
"-lm"],
opt_link_flags = ["-Wl,--gc-sections"],
unfiltered_compile_flags = ["-fno-canonical-system-headers",
"-Wno-builtin-macro-redefined",
"-D__DATE__=\"redacted\"",
"-D__TIMESTAMP__=\"redacted\"",
"-D__TIME__=\"redacted\""],
coverage_compile_flags = ["--coverage"],
coverage_link_flags = ["--coverage"],
supports_start_end_lib = True,
)

# Android tooling requires a default toolchain for the armeabi-v7a cpu.
cc_toolchain(
name = "cc-compiler-armeabi-v7a",
toolchain_identifier = "stub_armeabi-v7a",
toolchain_config = ":stub_armeabi-v7a",
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
)

armeabi_cc_toolchain_config(name = "stub_armeabi-v7a")
2 changes: 2 additions & 0 deletions common/remote-build/cc/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT EDIT: automatically generated WORKSPACE file for cc_autoconf rule
workspace(name = "local_config_cc")
82 changes: 82 additions & 0 deletions common/remote-build/cc/armeabi_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""A Starlark cc_toolchain configuration rule"""

load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"tool_path",
)

def _impl(ctx):
toolchain_identifier = "stub_armeabi-v7a"
host_system_name = "armeabi-v7a"
target_system_name = "armeabi-v7a"
target_cpu = "armeabi-v7a"
target_libc = "armeabi-v7a"
compiler = "compiler"
abi_version = "armeabi-v7a"
abi_libc_version = "armeabi-v7a"
cc_target_os = None
builtin_sysroot = None
action_configs = []

supports_pic_feature = feature(name = "supports_pic", enabled = True)
supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
features = [supports_dynamic_linker_feature, supports_pic_feature]

cxx_builtin_include_directories = []
artifact_name_patterns = []
make_variables = []

tool_paths = [
tool_path(name = "ar", path = "/bin/false"),
tool_path(name = "cpp", path = "/bin/false"),
tool_path(name = "dwp", path = "/bin/false"),
tool_path(name = "gcc", path = "/bin/false"),
tool_path(name = "gcov", path = "/bin/false"),
tool_path(name = "ld", path = "/bin/false"),
tool_path(name = "llvm-profdata", path = "/bin/false"),
tool_path(name = "nm", path = "/bin/false"),
tool_path(name = "objcopy", path = "/bin/false"),
tool_path(name = "objdump", path = "/bin/false"),
tool_path(name = "strip", path = "/bin/false"),
]

return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
features = features,
action_configs = action_configs,
artifact_name_patterns = artifact_name_patterns,
cxx_builtin_include_directories = cxx_builtin_include_directories,
toolchain_identifier = toolchain_identifier,
host_system_name = host_system_name,
target_system_name = target_system_name,
target_cpu = target_cpu,
target_libc = target_libc,
compiler = compiler,
abi_version = abi_version,
abi_libc_version = abi_libc_version,
tool_paths = tool_paths,
make_variables = make_variables,
builtin_sysroot = builtin_sysroot,
cc_target_os = cc_target_os,
)

armeabi_cc_toolchain_config = rule(
implementation = _impl,
attrs = {},
provides = [CcToolchainConfigInfo],
)
13 changes: 13 additions & 0 deletions common/remote-build/cc/builtin_include_directory_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This file is generated by cc_configure and contains builtin include directories
that /usr/bin/gcc reported. This file is a dependency of every compilation action and
changes to it will be reflected in the action cache key. When some of these
paths change, Bazel will make sure to rerun the action, even though none of
declared action inputs or the action commandline changes.

/usr/lib/gcc/x86_64-linux-gnu/9/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
/usr/include/c++/9
/usr/include/x86_64-linux-gnu/c++/9
/usr/include/c++/9/backward
Loading

0 comments on commit d530584

Please sign in to comment.