A build cache lets a build skip work another build already did. The forge hosts the cache itself, in each repository’s own storage and under the same permissions as its code, and speaks the protocols the build tools already use: Gradle’s HTTP build cache and sccache’s WebDAV backend. Nothing else needs to run.
In a job
The runner serves the cache to each job inside the job’s sandbox, at an address on the sandbox’s own loopback, and puts the two addresses in the program’s environment:
| Variable | For |
|---|---|
FORGE_GRADLE_CACHE |
Gradle’s HTTP build cache, by its URL |
SCCACHE_WEBDAV_ENDPOINT |
sccache, which reads this variable itself for a WebDAV backend |
A test program points its build tool at them. A job’s build reads and writes the cache. The forge takes an upload only from a runner that still holds the job, and only into that job’s scope.
Who reads what
- Scopes, as GitHub Actions scopes a cache to its branch. A job of an open change writes that change’s own scope, which only its later jobs read, before
main’s. Only the jobs ofmain’s landings write the scope everyone reads. Code that has not landed never poisons a build someone else takes. - Only runners write. People and agents read; their own builds stay on their machines.
- Restricted as its sources. Gradle’s and sccache’s protocols store an entry by its key alone, and say nothing of the files that made it. So an entry is readable only by someone who may read every one of the repository’s folders: in a repository with no restricted folder, by every reader. Anyone else’s every lookup is a miss.
- Each read is recorded, once a day for each reader and the commit its entry was built from, as a checkout records the commit it read.
How entries live
- Written once. The first complete entry for a key stays, as an Actions cache entry does; a second upload of it is dropped.
- Evicted after seven days unused, and past ten gigabytes the least recently used first: GitHub’s limits for a repository’s caches. A read refreshes its entry’s time at most once a day.
- Emptied by a purge. An entry built from a tree that held purged contents may hold them too, so a purge empties the cache, and refuses any upload from a job given before it.
An upload the forge refuses, or one too large, is answered as if it were stored and then dropped, because Gradle turns its remote cache off at any other answer.
On your own machine
af cache serves main’s cache to builds on your machine, read-only, at a local address, and prints the variables that point Gradle and sccache at it. It serves until you stop it. It refuses every upload with 403, which sccache takes as a cache to read only, so your local builds never write the shared cache.
$ af cache
...Not yet
- Bazel’s Remote Execution API, whose actions name their input files. With it, an entry could be as restricted as exactly the files that made it, instead of every folder.
Next
- Jobs and results: the jobs whose builds write the cache.
af cachein the reference.