-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
222 lines (199 loc) · 7.84 KB
/
action.yml
File metadata and controls
222 lines (199 loc) · 7.84 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#file: noinspection YAMLSchemaValidation
name: "gradle-task-run"
description: ""
inputs:
gradle-flags:
description: "Set of options we will pass to ./gradlew"
example: '["--continue", "--stacktrace"]'
required: "true"
default: "[]"
gradle-tasks:
description: "Set of tasks to be executed by ./gradlew"
example: '["assembleDebug", "check"]'
required: "true"
gradle-version:
description: "Version of Gradle to run build and cache results with"
required: "true"
default: ""
gradle-encryption-key:
description: "Encryption key used for this project"
required: "true"
gradle-home-directory:
description: "The directory to use for Gradle User Home"
required: "true"
default: "~/.gradle"
gradle-project-directory:
description: "The directory in which the Gradle project exists"
required: "true"
default: "."
reuse-configuration-cache:
description: "Whether to allow Configuration Cache reuse"
required: "true"
reuse-build-cache:
description: "Whether to allow Gradle Build Cache reuse"
required: "false"
default: true
malloc-replacement:
description: "Which implementation to replace malloc with"
required: "true"
default: "jemalloc"
debug:
description: "Whether to show debug logging"
required: "true"
default: false
shell:
description: "The shell to use for any steps that use shells"
default: "bash"
required: "true"
optional-suffix:
description: "Optional suffix to add to file names"
required: "true"
default: ""
outputs:
gradle-home-project-cache-hit:
value: ${{ steps.gradle-home-project.outputs.cache-hit }}
cache-gradle-home-cache-hit:
value: ${{ steps.cache-gradle-home.outputs.cache-hit }}
cache-gradle-build-cache-hit:
value: ${{ steps.cache-gradle-build.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: "Install JDK"
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: "Set up jemalloc"
if: ${{ inputs.malloc-replacement == 'jemalloc' }}
uses: kaeawc/setup-jemalloc@v0.0.3
- name: "Set up tcmalloc"
if: ${{ inputs.malloc-replacement == 'tcmalloc' }}
uses: kaeawc/setup-tcmalloc@v0.0.1
- name: "Sanitize artifact name"
id: sanitize-name
shell: ${{ inputs.shell }}
if: success() || failure()
run: |
# Remove or replace non-alphanumeric characters (keeping hyphens and underscores)
sanitized_name=$(echo "${{ inputs.gradle-tasks }}" | sed 's/[^a-zA-Z0-9_-]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//')
echo "sanitized_name=$sanitized_name" >> $GITHUB_OUTPUT
echo "Sanitized name: $sanitized_name"
- name: "Print Java Flags & version"
if: ${{ inputs.debug == 'true' }}
shell: ${{ inputs.shell }}
run: |
java -XX:+UseParallelGC -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal -version
- name: "Evaluate Gradle version & flags"
id: eval_gradle
shell: ${{ inputs.shell }}
run: |
if [ "${{ inputs.gradle-version }}" == "" ]; then
echo "Reading Gradle version from Gradle wrapper properties file."
grep "distributionUrl" gradle/wrapper/gradle-wrapper.properties | sed -E 's/.*gradle-([0-9.]+)-(all|bin).zip/\1/' > /tmp/gradle_version.txt
echo 'export version="$(cat /tmp/gradle_version.txt)' >> $GITHUB_OUTPUT
else
echo "Reading custom Gradle version provided to action."
echo 'export version="${{ inputs.gradle-version }}"' >> $GITHUB_OUTPUT
fi
# Note that we do not attempt to visually align JVM args - spaces included in kotlin.daemon.jvmargs causes the Kotlin compiler daemon to not run and fallback to Gradle in-process
export GRADLE_FLAGS="
--continue
--stacktrace
$(if [ "${{ inputs.reuse-configuration-cache }}" == "true" ]; then echo ""; else echo "--no-configuration-cache -Dorg.gradle.unsafe.isolated-projects=false"; fi;)
$(if [ "${{ inputs.reuse-build-cache }}" == "true" ]; then echo ""; else echo "--no-build-cache --rerun-tasks"; fi;)
$(echo "${{ inputs.gradle-flags }}" | jq ".[]" -M -r)
-Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
"
# Remove any newlines or tabs from GRADLE_FLAGS
export GRADLE_FLAGS="${GRADLE_FLAGS//[$'\t\r\n']}"
# Write temporary file for checksum
echo "$GRADLE_FLAGS" > /tmp/gradle_flags.txt
echo "Printing evaluated Gradle flags"
echo "GRADLE_FLAGS: $GRADLE_FLAGS"
- name: "Hash Gradle Tasks"
uses: pplanel/hash-calculator-action@v1.3.2
id: gradle-task-hash
with:
input: ${{ inputs.gradle-tasks }}
method: MD5
- name: "Debug cache key inputs"
shell: ${{ inputs.shell }}
run: |
echo "reuse-build-cache: ${{ inputs.reuse-build-cache }}"
echo "Task hash is ${{ steps.gradle-task-hash.outputs.digest }}"
echo "gradle-flags: ${{ inputs.gradle-flags }}"
echo "gradle-tasks: ${{ inputs.gradle-tasks }}"
echo "gradle-version: ${{ steps.eval_gradle.outputs.version }}"
echo "gradle-home-directory: ${{ inputs.gradle-home-directory }}"
echo "gradle-project-directory: ${{ inputs.gradle-project-directory }}"
echo "reuse-configuration-cache: ${{ inputs.reuse-configuration-cache }}"
echo "reuse-build-cache: ${{ inputs.reuse-build-cache }}"
echo "debug: ${{ inputs.debug }}"
echo "shell: ${{ inputs.shell }}"
echo "ANDROID_HOME: $ANDROID_HOME"
- name: "Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: ${{ steps.eval_gradle.outputs.version }}
cache-encryption-key: ${{ inputs.gradle-encryption-key }}
cache-cleanup: "on-success"
cache-disabled: ${{ inputs.reuse-build-cache == 'false' }}
validate-wrappers: true
- name: "Restore Android SDK Cache"
id: cache-android-sdk
uses: actions/cache/restore@v4
with:
path: |
~/.android
~/.config
key: v4-${{ runner.os }}-android-sdk
- name: Setup Android SDK
if: steps.cache-android-sdk.outputs.cache-hit != 'true'
uses: android-actions/setup-android@v3.2.2
- name: "Save Android SDK Cache"
uses: actions/cache/save@v4
if: steps.cache-android-sdk.outputs.cache-hit != 'true'
with:
path: |
~/.android
~/.config
key: v4-${{ runner.os }}-android-sdk
- name: "Add Android platform tools to PATH"
shell: ${{ inputs.shell }}
run: echo "$ANDROID_HOME/platform-tools" >> "$GITHUB_PATH"
- name: "Run Tasks via Gradle"
shell: ${{ inputs.shell }}
run: |
export GRADLE_FLAGS=$(cat /tmp/gradle_flags.txt)
./gradlew ${{ inputs.gradle-tasks }} $GRADLE_FLAGS
- name: "Check if any JUnit tests reports were created"
id: junit-reports-exist
if: always() # always run even if the previous step fails
uses: andstor/file-existence-action@v3
with:
files: "**/build/test-results/testDebugUnitTest/TEST-*.xml"
- name: "Publish Test Report"
uses: mikepenz/action-junit-report@v4
if: steps.junit-reports-exist.outputs.files_exists == 'true'
with:
report_paths: '**/build/test-results/testDebugUnitTest/TEST-*.xml'
- name: "Rename Configuration Cache HTML Report"
shell: ${{ inputs.shell }}
if: success() || failure()
run: |
mkdir -p build/reports/configuration-cache
html_file=$(find build/reports/configuration-cache -type f -name "*.html" | head -n 1)
if [[ -n "$html_file" ]]; then
echo "Found Config Cache HTML Report"
mv "$html_file" build/reports/config-cache-report.html
else
touch build/reports/config-cache-report.html
fi
- name: "Store Config Cache Report"
uses: actions/upload-artifact@v4.4.0
if: success()
with:
name: config-cache-report-${{ steps.sanitize-name.outputs.sanitized_name }}
path: |
build/reports/config-cache-report.html