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