Skip to content

Commit

Permalink
Disable bwc distribution caching in master branch (#46686)
Browse files Browse the repository at this point in the history
This commit disables caching of BWC snapshot distributions in the "trunk" (aka master) branch.
Since the previous major release branches move quickly we rarely get cache hits for these 
tasks, and the artifacts themselves are very large. This means the overhead here is high and
savings basically zero. We conditionally disable task output caching in this scenario in CI to 
avoid excessive build cache overhead as well as causing too much turn in the cache itself which
would lead to lots of cache entry evictions.
  • Loading branch information
mark-vieira authored Sep 18, 2019
1 parent 33ed38e commit deef0d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void apply(Project project) {
ext.set("gradleJavaVersion", Jvm.current().getJavaVersion());
ext.set("gitRevision", gitRevision(project.getRootProject().getRootDir()));
ext.set("buildDate", ZonedDateTime.now(ZoneOffset.UTC));
ext.set("isCi", System.getenv("JENKINS_URL") != null);
});
}

Expand Down
8 changes: 7 additions & 1 deletion distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,14 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased
Task bwcTask = createRunBwcGradleTask(buildBwcTaskName(projectName)) {
inputs.file("${project.buildDir}/refspec")
outputs.files(projectArtifact)
outputs.cacheIf { true }
outputs.cacheIf("BWC distribution caching is disabled on 'master' branch") {
// Don't bother caching in 'master' since the BWC branches move too quickly to make this cost worthwhile
project.ext.isCi && System.getenv('GIT_BRANCH')?.endsWith("master") == false
}
args ":${projectDir.replace('/', ':')}:assemble"
if (project.gradle.startParameter.buildCacheEnabled) {
args "--build-cache"
}
doLast {
if (projectArtifact.exists() == false) {
throw new InvalidUserDataException("Building ${bwcVersion} didn't generate expected file ${projectArtifact}")
Expand Down

0 comments on commit deef0d9

Please sign in to comment.