Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different cache keys for save & restore steps when using Gradle's precompiled script plugins #14

Open
1 task done
adamdanielczyk opened this issue May 10, 2023 · 1 comment

Comments

@adamdanielczyk
Copy link
Contributor

Troubleshooting

  • I've searched discuss.bitrise.io for possible solutions.
  • Which version of the step is effected? 1.1.4
  • Is the issue reproducible with the latest version? YES
  • Does the issue happen sporadically, or every time? EVERY TIME
  • Is the issue reproducible locally by following our local debug guide? YES

Useful information

Issue description

Our project is using Gradle's precompiled script plugins and it looks like cache keys for restore & save build steps differ.

The restore step's checksum is e1387f while save step's is 7e9d0b. Upon analysis, it looks like there is one additional file included in calculation of save step's checksum: buildlogic/build/kotlin-dsl/plugins-blocks/extracted/***.gradle.kts - this file is not present in VCS, probably is generated during compilation and should otherwise not be taken into account for checksum calculation.

However, it seems that including the original file buildlogic/src/main/kotlin/***.gradle.kts is correct, since that file's configuration could change the state of the cache.

The key template in use is the default one: {{ .OS }}-{{ .Arch }}-gradle-cache-{{ checksum "**/*.gradle*" "**/gradle-wrapper.properties" "gradle.properties" "gradle/libs.versions.toml" }}.

Bitrise info

@vshah23 vshah23 assigned ofalvai and unassigned ofalvai May 11, 2023
@adamdanielczyk
Copy link
Contributor Author

What we've ended up using is the following template in regular https://github.com/bitrise-steplib/bitrise-step-save-cache step:
{{ .OS }}-{{ .Arch }}-gradle-cache-{{ checksum "**/build.gradle*" "buildlogic/src/main/**" "**/settings.gradle*" "**/gradle-wrapper.properties" "**/gradle.properties" "**/libs.versions.toml" }}

  • **/build.gradle* - include all build.gradle files
  • buildlogic/src/main/** - include everything from buildlogic catalog, but disregard tests catalog. Including only buidlogic/src/main also avoids including buildlogic/build/... as reported in the bug above. In that catalog, we have a bunch of kt & kts files which can all affect the build cache - so it makes sense to include everything for checksum
  • **/settings.gradle* - include settings.gradle which was previously included by **/*.gradle*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants