Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: use GCS remote cache #4050

Merged
merged 12 commits into from
Aug 12, 2018
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
- image: *envoy-build-image
resource_class: xlarge
working_directory: /source
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- checkout
Expand All @@ -21,6 +23,8 @@ jobs:
- image: *envoy-build-image
resource_class: xlarge
working_directory: /source
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- run: echo $CIRCLE_SHA1
Expand All @@ -33,6 +37,8 @@ jobs:
- image: *envoy-build-image
resource_class: xlarge
working_directory: /source
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- checkout
Expand Down Expand Up @@ -64,6 +70,8 @@ jobs:
- run: ci/filter_example_mirror.sh
ipv6_tests:
machine: true
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- checkout
Expand All @@ -90,6 +98,8 @@ jobs:
- image: *envoy-build-image
resource_class: xlarge
working_directory: /source
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- checkout
Expand Down Expand Up @@ -136,6 +146,8 @@ jobs:
mac:
macos:
xcode: "9.3.0"
environment:
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/envoy-circleci-bazel-cache/
steps:
- run: sudo ntpdate -vu time.apple.com
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
Expand Down
1 change: 1 addition & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [[ "$1" == "fix_format" || "$1" == "check_format" ]]; then
build_setup_args="-nofetch"
fi

. "$(dirname "$0")"/setup_gcs_cache.sh
. "$(dirname "$0")"/build_setup.sh $build_setup_args

echo "building using ${NUM_CPUS} CPUs"
Expand Down
1 change: 1 addition & 0 deletions ci/do_circle_ci_ipv6_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ echo "disk space at beginning of build:"
df -h

docker run -t -i -v "$ENVOY_BUILD_DIR":/build -v "$ENVOY_SRCDIR":/source \
--env GCP_SERVICE_ACCOUNT_KEY --env BAZEL_REMOTE_CACHE \
envoyproxy/envoy-build:"$ENVOY_BUILD_SHA" /bin/bash -c "cd /source && ci/do_ci.sh $TEST_TYPE"

4 changes: 3 additions & 1 deletion ci/mac_ci_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

BAZEL_BUILD_OPTIONS="--curses=no --show_task_finish --verbose_failures"
. "$(dirname "$0")"/setup_gcs_cache.sh

BAZEL_BUILD_OPTIONS="--curses=no --show_task_finish --verbose_failures ${BAZEL_BUILD_EXTRA_OPTIONS}"
# TODO(zuercher): remove --flaky_test_attempts when https://github.com/envoyproxy/envoy/issues/2428
# is resolved.
BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_output=all --flaky_test_attempts=integration@2"
Expand Down
34 changes: 34 additions & 0 deletions ci/setup_gcs_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

if [[ ! -z "${BAZEL_REMOTE_CACHE}" ]]; then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove superfluous blank lines here and below.

if [[ ! -z "${GCP_SERVICE_ACCOUNT_KEY}" ]]; then

# mktemp will create a tempfile with u+rw permission minus umask, it will not be readable by all
# users by default.
GCP_SERVICE_ACCOUNT_KEY_FILE=$(mktemp -t gcp_service_account.XXXXXX.json)

gcp_service_account_cleanup() {
echo "Deleting service account key file..."
rm -rf "${GCP_SERVICE_ACCOUNT_KEY_FILE}"
}

trap gcp_service_account_cleanup EXIT

echo "${GCP_SERVICE_ACCOUNT_KEY}" | base64 --decode > "${GCP_SERVICE_ACCOUNT_KEY_FILE}"

export BAZEL_BUILD_EXTRA_OPTIONS="${BAZEL_BUILD_EXTRA_OPTIONS} \
--remote_http_cache=${BAZEL_REMOTE_CACHE} \
--google_credentials=${GCP_SERVICE_ACCOUNT_KEY_FILE}"
echo "Set up bazel read/write HTTP cache at ${BAZEL_REMOTE_CACHE}."
else
export BAZEL_BUILD_EXTRA_OPTIONS="${BAZEL_BUILD_EXTRA_OPTIONS} \
--remote_http_cache=${BAZEL_REMOTE_CACHE} --noremote_upload_local_results"
echo "Set up bazel read only HTTP cache at ${BAZEL_REMOTE_CACHE}."
fi

else
echo "No remote cache bucket is set, skipping setup remote cache."
fi