gradle/gradle-build-action

Caching build artifacts in order to split large CI job into multiple smaller jobs?

gotson opened this issue · 1 comments

gotson commented

Hello,

i have a question regarding the best practice to split a large CI job that is composed of multiple executions of gradle-build-action, or of steps that effectively depend on the artifacts generated by Gradle.

Would gradle-build-action cache the jar produced by the jar task for instance ?

If not, could i cache it myself by tweaking the gradle-build-action configuration, or by using actions/cache ? And if I were to do so by using actions/cache, would subsequent executions of gradle-build-action in a different workflow/job consider the restored cache as enough not to trigger the dependent tasks again ?

bigdaz commented

The gradle-build-action will save and restore content in the Gradle User Home directory. When you run a jar task the output is saved in the Project build directory, and so won't be saved by this action.

However, the Gradle Local Build Cache is stored in the Gradle User Home, and so will be saved and restored by this action. All .class files and other expensive outputs are saved in the build cache (assuming it's enabled). Note that the actual jar file outputs are not saved in the build cache, since these are normally inexpensive to recreate from the underlying .class files.

So while you could theoretically save the build directory using actions/cache, I think you're better off enabling the Gradle Build Cache and leveraging the built-in support of this action.