1
- name : ' Set up Gradle and some task(s) with caching'
2
- description : ' This action performs common steps for a Gradle task.'
1
+ name : ' Set up Gradle and some task(s) with caching'
2
+ description : ' This action performs common steps for a Gradle task.'
3
3
4
- inputs :
5
- task :
6
- description : ' Gradle command line arguments (supports multi-line input)'
7
- required : true
8
- build-root-directory :
9
- description : ' Path to the root directory of the build'
10
- required : false
11
- java-version :
12
- description : ' The Java version to set up.'
13
- default : ' 17'
14
- distribution :
15
- description : ' The JDK distribution to use.'
16
- default : ' zulu'
17
- restore-cache-key :
18
- description : ' The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
19
- default : ' null'
20
- write-cache-key :
21
- description : ' The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
22
- default : ' null'
4
+ inputs :
5
+ task :
6
+ description : ' Gradle command line arguments (supports multi-line input)'
7
+ required : true
8
+ build-root-directory :
9
+ description : ' Path to the root directory of the build'
10
+ required : false
11
+ java-version :
12
+ description : ' The Java version to set up.'
13
+ default : ' 17'
14
+ distribution :
15
+ description : ' The JDK distribution to use.'
16
+ default : ' zulu'
17
+ restore-cache-key :
18
+ description : ' The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
19
+ default : ' null'
20
+ write-cache-key :
21
+ description : ' The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
22
+ default : ' null'
23
23
24
- runs :
25
- using : ' composite'
26
- steps :
24
+ runs :
25
+ using : ' composite'
26
+ steps :
27
27
28
- - name : Set up JDK
29
- uses : actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
30
- with :
31
- distribution : ${{inputs.distribution}}
32
- java-version : ${{inputs.java-version}}
28
+ - name : Set up JDK
29
+ uses : actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
30
+ with :
31
+ distribution : ${{inputs.distribution}}
32
+ java-version : ${{inputs.java-version}}
33
33
34
- - name : Set Gradle Args for runner OS
35
- id : gradle-args
36
- uses : ./.github/actions/gradle-args
34
+ - name : Set Gradle Args for runner OS
35
+ id : gradle-args
36
+ uses : ./.github/actions/gradle-args
37
37
38
- - name : Gradle build action
39
- uses : gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3
40
- with :
41
- cache-read-only : false
42
- gradle-home-cache-cleanup : true
38
+ - name : Gradle build action
39
+ uses : gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3
40
+ with :
41
+ cache-read-only : false
42
+ gradle-home-cache-cleanup : true
43
43
44
44
# Calculate all the hashes for keys just one time.
45
45
# These should only be referenced before the actual task action, since that action
46
46
# may generate changes and we want the final cache key to reflect its current state.
47
- - name : Calculate hashes
48
- id : hashes
47
+ - name : Calculate hashes
48
+ id : hashes
49
49
shell : bash
50
- run : |
50
+ run : |
51
51
echo "lib_versions=${{ hashFiles('**/libs.versions.toml') }}" >> $GITHUB_OUTPUT
52
52
echo "gradle_props=${{ hashFiles('**/gradle.properties') }}" >> $GITHUB_OUTPUT
53
53
echo "gradle_kts=${{ hashFiles('**/*.gradle.kts') }}" >> $GITHUB_OUTPUT
@@ -56,74 +56,74 @@ runs :
56
56
# Attempt to restore from the write-cache-key, or fall back to a partial match for the write key.
57
57
# Skipped if the write-cache-key wasn't set.
58
58
# This step's "cache_hit" output will only be true if an exact match was found.
59
- - name : restore cache for ${{inputs.write-cache-key}}
60
- id : restore-write-cache
61
- if : inputs.write-cache-key != 'null'
62
- uses : actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
63
- with :
64
- path : |
59
+ - name : restore cache for ${{inputs.write-cache-key}}
60
+ id : restore-write-cache
61
+ if : inputs.write-cache-key != 'null'
62
+ uses : actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
63
+ with :
64
+ path : |
65
65
~/.gradle/caches/build-cache-1
66
66
~/.konan
67
67
./**/build/**/!(*.dex)
68
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 : |
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
71
${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}
72
72
${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}
73
73
${{runner.os}}-${{inputs.write-cache-key}}-${{steps.hashes.outputs.lib_versions}}
74
74
${{runner.os}}-${{inputs.write-cache-key}}
75
75
76
76
# Attempt to restore from the restore-cache-key, or fall back to a partial match for the restore key.
77
77
# Skipped if the restore-cache-key wasn't set, or if the write-cache-key restore had an exact match.
78
- - name : restore cache for ${{inputs.restore-cache-key}}
79
- if : inputs.restore-cache-key != 'null' && steps.restore-write-cache.outputs.cache-hit != 'true'
80
- uses : actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
81
- with :
82
- path : |
78
+ - name : restore cache for ${{inputs.restore-cache-key}}
79
+ if : inputs.restore-cache-key != 'null' && steps.restore-write-cache.outputs.cache-hit != 'true'
80
+ uses : actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
81
+ with :
82
+ path : |
83
83
~/.gradle/caches/build-cache-1
84
84
~/.konan
85
85
./**/build/**/!(*.dex)
86
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 : |
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
89
${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}-${{steps.hashes.outputs.gradle_kts}}
90
90
${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}-${{steps.hashes.outputs.gradle_props}}
91
91
${{runner.os}}-${{inputs.restore-cache-key}}-${{steps.hashes.outputs.lib_versions}}
92
92
${{runner.os}}-${{inputs.restore-cache-key}}
93
93
94
- - uses : gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2
94
+ - uses : gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2
95
95
96
96
# Run the actual task. Note that this still uses gradle-build-action for more fine-grained caching.
97
- - name : Run ${{inputs.task}}
98
- uses : gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3
99
- with :
97
+ - name : Run ${{inputs.task}}
98
+ uses : gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3
99
+ with :
100
100
# These arguments need to be on a single line. If they're defined with wrapping (using `|`),
101
101
# something along the way to the actual CLI invocation gets confused and the jvmargs list
102
102
# winds up getting parsed as a single argument.
103
- arguments : ${{steps.gradle-args.outputs.gradle-property-args}} ${{inputs.task}} '-Dorg.gradle.jvmargs=${{steps.gradle-args.outputs.gradle-jvm-args}}'
104
- cache-read-only : false
105
- build-root-directory : ${{inputs.build-root-directory}}
106
- gradle-home-cache-cleanup : true
103
+ arguments : ${{steps.gradle-args.outputs.gradle-property-args}} ${{inputs.task}} '-Dorg.gradle.jvmargs=${{steps.gradle-args.outputs.gradle-jvm-args}}'
104
+ cache-read-only : false
105
+ build-root-directory : ${{inputs.build-root-directory}}
106
+ gradle-home-cache-cleanup : true
107
107
108
108
# Save the build cache to `write-cache-key`.
109
109
# Skip if we already had an exact match, or if the key is not set, or if this is a Windows runner.
110
110
# Windows runners are welcome to *read* the cross-OS cache, but the directories get weird if
111
111
# they try to write to it.
112
- - name : save the '${{inputs.write-cache-key}}' cache
113
- uses : actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
114
- id : save-write-cache-key
115
- if : inputs.write-cache-key != 'null' && steps.restore-write-cache.outputs.cache-hit != 'true'
116
- with :
117
- path : |
112
+ - name : save the '${{inputs.write-cache-key}}' cache
113
+ uses : actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
114
+ id : save-write-cache-key
115
+ if : inputs.write-cache-key != 'null' && steps.restore-write-cache.outputs.cache-hit != 'true'
116
+ with :
117
+ path : |
118
118
~/.gradle/caches/build-cache-1
119
119
~/.konan
120
120
./**/build/**/!(*.dex)
121
121
./**/.gradle
122
- key : ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}-${{hashFiles('**/*.gradle.kts')}}-${{hashFiles('**/src/**/*.kt')}}
122
+ key : ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}-${{hashFiles('**/*.gradle.kts')}}-${{hashFiles('**/src/**/*.kt')}}
123
123
124
- - name : Upload heap dump
125
- if : failure()
126
- uses : actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
127
- with :
128
- name : heap-dump
129
- path : ${{github.workspace}}/**/*{.hprof,.log}
124
+ - name : Upload heap dump
125
+ if : failure()
126
+ uses : actions/upload-artifact@v4
127
+ with :
128
+ name : heap-dump
129
+ path : ${{github.workspace}}/**/*{.hprof,.log}
0 commit comments