You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ci: enable bazel remote caching on CircleCI (angular#21784)
This should cause Bazel builds to be incremental, only re-building parts of Angular affected by changes since the last build.
It also fixes a potential version skew, where CI was running the Bazel linter binaries in the ngcontainer docker image, but developers built them using the versions in WORKSPACE
PR Closeangular#21784
Copy file name to clipboardExpand all lines: docs/BAZEL.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,30 @@ Apple+Shift+D on Mac) and click on the green play icon next to the configuration
112
112
- Open chrome at: [http://localhost:9876/debug.html](http://localhost:9876/debug.html)
113
113
- Open chrome inspector
114
114
115
+
## Remote cache
116
+
117
+
Bazel supports fetching action results from a cache, allowing a clean build to pick up artifacts from prior builds.
118
+
This makes builds incremental, even on CI.
119
+
It works because Bazel assigns a content-based hash to all action inputs, which is used as the cache key for the action outputs.
120
+
Thanks the the hermeticity property, we can skip executing an action if the inputs hash is already present in the cache.
121
+
122
+
Of course, non-hermeticity in an action can cause problems.
123
+
At worst, you can fetch a broken artifact from the cache, making your build non-reproducible.
124
+
For this reason, we are careful to implement our Bazel rules to depend only on their inputs.
125
+
126
+
Currently we only use remote caching on CircleCI.
127
+
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.
128
+
129
+
This feature is experimental, and developed by the CircleCI team with guidance from Angular.
130
+
Contact Alex Eagle with questions.
131
+
132
+
*How it's configured*:
133
+
134
+
1. In `.circleci/config.yml`, each CircleCI job downloads a proxy binary, which is built from https://github.com/notnoopci/bazel-remote-proxy. The download is done by running `.circleci/setup_cache.sh`. When the feature graduates from experimental, this proxy will be installed by default on every CircleCI worker, and this step will not be needed.
135
+
1. Next, each job runs the `setup-bazel-remote-cache` anchor. This starts up the proxy running in the background. In the CircleCI UI, you'll see this step continues running while later steps run, and you can see logging from the proxy process.
136
+
1. Bazel must be configured to connect to the proxy on a local port. This configuration lives in `.circleci/bazel.rc` and is enabled because we overwrite the system Bazel settings in /etc/bazel.bazelrc with this file.
137
+
1. Each `bazel` command in `.circleci/config.yml` picks up and uses the caching flags.
0 commit comments