From 7f221d8d2a27238bee9885ce0b83510f5574cb2e Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 28 Nov 2018 15:34:27 -0800 Subject: [PATCH] build: introduce remote bazel caching (#27358) This PR introduces: 1. Google Cloud Store bucket which contains build artifacts 2. Documentation on how to enable remote caching in development Each team member should download a service key. More convenient ways of authentication would be more obscure and prevent us from doing identity tracking of the produced artifacts. PR Close #27358 --- .bazelrc | 8 ++++++++ .gitignore | 4 ++++ docs/BAZEL.md | 19 +++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index c87a7fa67a..11a739f85a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,11 @@ +# Load any settings specific to the current user +try-import .bazelrc.user +################################ +# 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 # ############################### diff --git a/.gitignore b/.gitignore index 2576aaf76f..038b705638 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ yarn-error.log # rollup-test output /modules/rollup-test/dist/ + +# User specific bazel settings +.bazelrc.user + diff --git a/docs/BAZEL.md b/docs/BAZEL.md index cca592d60f..cb79f58f8a 100644 --- a/docs/BAZEL.md +++ b/docs/BAZEL.md @@ -165,8 +165,23 @@ Of course, non-hermeticity in an action can cause problems. At worst, you can fetch a broken artifact from the cache, making your build non-reproducible. For this reason, we are careful to implement our Bazel rules to depend only on their inputs. -Currently we only use remote caching on CircleCI. -We could enable it for developer builds as well, which would make initial builds much faster for developers by fetching already-built artifacts from the cache. +Currently we only use remote caching on CircleCI and we let Angular core developers enable remote caching to speed up their builds. + +### Remote cache in development + +To enable remote caching for your build: + +1. Go to the service accounts for the ["internal" project](https://console.cloud.google.com/iam-admin/serviceaccounts?project=internal-200822) +1. Select "Angular local dev", click on "Edit", scroll to the bottom, and click "Create key" +1. When the pop-up shows, select "JSON" for "Key type" and click "Create" +1. Save the key in a secure location +1. Create a file called `.bazelrc.user` in the root directory of the workspace, and add the following content: + +``` +build --config=angular-team --google_credentials=[ABSOLUTE_PATH_TO_SERVICE_KEY] +``` + +### Remote cache for Circle CI This feature is experimental, and developed by the CircleCI team with guidance from Angular. Contact Alex Eagle with questions.