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
This commit is contained in:
Joey Perrott 2019-06-21 15:13:39 -07:00 committed by Kara Erickson
parent 00ecfc7f9a
commit e8d0265c1e
2 changed files with 16 additions and 9 deletions

View File

@ -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 # # 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 --remote_instance_name=projects/internal-200822/instances/default_instance
build:remote --project_id=internal-200822 build:remote --project_id=internal-200822
# Do not accept remote cache. # Remote caching
# We need to understand the security risks of using prior build artifacts. 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 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 Event Service Configuration
build:remote --bes_backend=buildeventservice.googleapis.com build:remote --bes_backend=buildeventservice.googleapis.com

View File

@ -58,7 +58,17 @@ var_5: &setup_bazel_remote_execution
# cause decryption failures based on the openssl version. https://stackoverflow.com/a/39641378/4317734 # 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 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 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 # Settings common to each job
var_6: &job_defaults var_6: &job_defaults