mirror of https://github.com/grpc/grpc.git
[bazelify tests] Add "concurrent_bazel.sh" wrapper to enable parallel invocations of bazel (#34568)
(I had to first solve a problem with "dubious file ownership" error that was happening inside the grpc_repo_archive action when using the concurrent wrapper). Example: ``` tools/docker_runners/examples/concurrent_bazel.sh --bazelrc=tools/remote_build/linux.bazelrc test --genrule_strategy=remote,local --workspace_status_command=tools/bazelify_tests/workspace_status_cmd.sh //tools/bazelify_tests/test:runtests_csharp_linux_dbg ```pull/34613/head
parent
8391f19a22
commit
14f5d4768d
6 changed files with 66 additions and 2 deletions
@ -0,0 +1,10 @@ |
|||||||
|
#================= |
||||||
|
# Setup git to access working directory across docker boundary. |
||||||
|
# This avoids the "fatal: detected dubious ownership in repository XYZ" |
||||||
|
# git error. Using "--system" makes the setting work |
||||||
|
# for all users or even current user is not properly defined |
||||||
|
# (which can happen e.g. inside execution environment |
||||||
|
# of a bazel action) |
||||||
|
|
||||||
|
RUN git config --system --add safe.directory '*' |
||||||
|
RUN git config --system protocol.file.allow always |
@ -0,0 +1,42 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# Copyright 2021 The gRPC Authors |
||||||
|
# |
||||||
|
# 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 wrapper allows running concurrent instances of bazel build/test by running |
||||||
|
# bazel under a docker container. |
||||||
|
# This is especially useful for running bazel RBE builds, since inside |
||||||
|
# the container, bazel won't have access to local build cache. |
||||||
|
# Access to the local workspace is provided by mounting the workspace |
||||||
|
# as a volume to the docker container. That also means that any changes |
||||||
|
# in the workspace will be visible to the bazel instance running inside |
||||||
|
# the container (but also this is a similar scenario to making changes |
||||||
|
# to local files when bazel is running normally). |
||||||
|
|
||||||
|
# Usage: |
||||||
|
# tools/docker_runners/examples/concurrent_bazel.sh ANY_NORMAL_BAZEL_FLAGS_HERE |
||||||
|
|
||||||
|
set -ex |
||||||
|
|
||||||
|
# change to grpc repo root |
||||||
|
cd "$(dirname "$0")/../../.." |
||||||
|
|
||||||
|
# use the default docker image used for bazel builds |
||||||
|
export DOCKERFILE_DIR=tools/dockerfile/test/bazel |
||||||
|
|
||||||
|
# Bazel RBE uses application default credentials from localhost to authenticate with RBE servers. Use a trick to make the credentails accessible from inside the docker container." |
||||||
|
APPLICATION_DEFAULT_CREDENTIALS_DIR="$HOME/.config/gcloud" |
||||||
|
export DOCKER_EXTRA_ARGS="-v=${APPLICATION_DEFAULT_CREDENTIALS_DIR}:/application_default_credentials:ro -e=GOOGLE_APPLICATION_CREDENTIALS=/application_default_credentials/application_default_credentials.json" |
||||||
|
|
||||||
|
# Run bazel inside a docker container (local git workspace will be mounted to the container) |
||||||
|
tools/docker_runners/run_in_docker.sh bazel "$@" |
@ -1 +1 @@ |
|||||||
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel:d64f53cefe4fe5908e00130a7a0dbe6253d9f0b8@sha256:d3291d3129469bd4bdd58b5dd81eb6c5668548a4d6e6c8e952fb372d1874b078 |
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel:c8658dbcb51352d5e9c5d9f15282835e45d5ce80@sha256:023fdfd072e278d4129f2c8f8564f6697e767c9847aae8c9411ea853f3faaa6f |
Loading…
Reference in new issue