@@ -41,6 +41,18 @@ runs :
4141 cache-read-only : false
4242 gradle-home-cache-cleanup : true
4343
44+ # Calculate all the hashes for keys just one time.
45+ # These should only be referenced before the actual task action, since that action
46+ # may generate changes and we want the final cache key to reflect its current state.
47+ - name : Calculate hashes
48+ id : hashes
49+ shell : bash
50+ run : |
51+ echo "lib_versions=${{ hashFiles('**/libs.versions.toml') }}" >> $GITHUB_OUTPUT
52+ echo "gradle_props=${{ hashFiles('**/gradle.properties') }}" >> $GITHUB_OUTPUT
53+ echo "gradle_kts=${{ hashFiles('**/*.gradle.kts') }}" >> $GITHUB_OUTPUT
54+ echo "src_kt=${{ hashFiles('**/src/**/*.kt') }}" >> $GITHUB_OUTPUT
55+
4456 # Attempt to restore from the write-cache-key, or fall back to a partial match for the write key.
4557 # Skipped if the write-cache-key wasn't set.
4658 # This step's "cache_hit" output will only be true if an exact match was found.
@@ -51,9 +63,15 @@ runs :
5163 with :
5264 path : |
5365 ~/.gradle/caches/build-cache-1
54- ./**/build/**
55- key : ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/*.gradle.kt*')}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}
56- restore-keys : ${{runner.os}}-${{inputs.write-cache-key}}
66+ ~/.konan
67+ ./**/build
68+ ./**/.gradle
69+ key : ${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}-${{steps.hashes.outputs.src_kt}}
70+ restore-keys : |
71+ ${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}
72+ ${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}
73+ ${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}
74+ ${{runner.os}}-${{inputs.write-cache-key}}
5775
5876 # Attempt to restore from the restore-cache-key, or fall back to a partial match for the restore key.
5977 # Skipped if the restore-cache-key wasn't set, or if the write-cache-key restore had an exact match.
@@ -63,9 +81,15 @@ runs :
6381 with :
6482 path : |
6583 ~/.gradle/caches/build-cache-1
66- ./**/build/**
67- key : ${{runner.os}}-${{inputs.restore-cache-key}}-${{hashFiles('**/*.gradle.kt*')}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}
68- restore-keys : ${{runner.os}}-${{inputs.restore-cache-key}}
84+ ~/.konan
85+ ./**/build
86+ ./**/.gradle
87+ key : ${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}-${{steps.hashes.outputs.src_kt}}
88+ restore-keys : |
89+ ${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}
90+ ${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}
91+ ${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}
92+ ${{runner.os}}-${{inputs.restore-cache-key}}
6993
7094 - uses : gradle/wrapper-validation-action@v1
7195
@@ -92,8 +116,10 @@ runs :
92116 with :
93117 path : |
94118 ~/.gradle/caches/build-cache-1
95- ./**/build/**
96- key : ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/*.gradle.kt*')}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}
119+ ~/.konan
120+ ./**/build
121+ ./**/.gradle
122+ key : ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}-${{hashFiles('**/*.gradle.kts')}}-${{hashFiles('**/src/**/*.kt')}}
97123
98124 - name : Upload heap dump
99125 if : failure()
0 commit comments