From e8d0265c1e542976bbf54836bb5471e769cff5f3 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 21 Jun 2019 15:13:39 -0700 Subject: [PATCH] ci: enable remote build caching for CI jobs (#31204) Enables remote caching for CI jobs. This configuration: always reads from build cache on CI only write to build cache for local builds for non-PR CI run PR Close #31204 --- .bazelrc | 13 +++++-------- .circleci/config.yml | 12 +++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.bazelrc b/.bazelrc index 308a20e2ce..d7e732067b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,9 +1,3 @@ -################################ -# Settings for Angular team members only -################################ -# To enable this feature check the "Remote caching" section in docs/BAZEL.md. -build:angular-team --remote_http_cache=https://storage.googleapis.com/angular-team-cache - ############################### # Typescript / Angular / Sass # ############################### @@ -137,9 +131,12 @@ build:remote --platforms=//tools:rbe_ubuntu1604-angular build:remote --remote_instance_name=projects/internal-200822/instances/default_instance build:remote --project_id=internal-200822 -# Do not accept remote cache. -# We need to understand the security risks of using prior build artifacts. +# Remote caching +build:remote --remote_cache=remotebuildexecution.googleapis.com +# By default, do not accept remote cache, to be set to true for CI based on environment build:remote --remote_accept_cached=false +# By default, do not upload local results to cache, to be set to true for CI based on environment +build:remote --remote_upload_local_results=false # Build Event Service Configuration build:remote --bes_backend=buildeventservice.googleapis.com diff --git a/.circleci/config.yml b/.circleci/config.yml index 175ad78e81..a137860ffa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,7 +58,17 @@ var_5: &setup_bazel_remote_execution # cause decryption failures based on the openssl version. https://stackoverflow.com/a/39641378/4317734 openssl aes-256-cbc -d -in .circleci/gcp_token -md md5 -k "$CI_REPO_NAME" -out /home/circleci/.gcp_credentials echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV - sudo bash -c "echo 'build --config=remote' >> /etc/bazel.bazelrc" + touch .bazelrc.user + sudo bash -c "echo -e 'build --config=remote\n' >> .bazelrc.user" + sudo bash -c "echo -e 'build:remote --remote_accept_cached=true\n' >> .bazelrc.user" + echo "Reading from remote cache for bazel remote jobs." + if [[ "$CI_PULL_REQUEST" == "false" ]]; then + sudo bash -c "echo -e 'build:remote --remote_upload_local_results=true\n' >> .bazelrc.user" + echo "Uploading local build results to remote cache." + else + sudo bash -c "echo -e 'build:remote --remote_upload_local_results=false\n' >> .bazelrc.user" + echo "Not uploading local build results to remote cache." + fi # Settings common to each job var_6: &job_defaults