Skip to content

Commit c7d582e

Browse files
authored
apk-size: report clear error message when "sdk" string cannot be parsed (#7206)
This PR fixes an obscure error that I cannot reproduce. The error occurred during a github actions workflow and looked like this: ``` [I] fireci.gradle: FAILURE: Build failed with an exception. [I] fireci.gradle: [I] fireci.gradle: * Where: [I] fireci.gradle: Script '/home/runner/work/firebase-android-sdk/firebase-android-sdk/health-metrics/apk-size/app/configure.gradle' line: 27 [I] fireci.gradle: [I] fireci.gradle: * What went wrong: [I] fireci.gradle: A problem occurred evaluating script. [I] fireci.gradle: > Index 1 out of bounds for length 1 ``` https://github.com/firebase/firebase-android-sdk/actions/runs/16633221757/job/47122970800 With this fix, the error is clearer: ``` $ cd health-metrics/apk-size $ ./gradlew -Psdks=foobar1,foobar2 tasks FAILURE: Build failed with an exception. * Where: Script 'health-metrics/apk-size/app/configure.gradle' line: 30 * What went wrong: A problem occurred evaluating script. > Invalid SDK format: 'foobar1'. Expected format: 'groupId:artifactId:version' (sdks: 'foobar1,foobar2') ```
1 parent 99d6162 commit c7d582e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ci/fireci/fireciplugins/binary_size.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def binary_size(pull_request, log, metrics_service_url, access_token):
5555
affected_artifacts, all_artifacts = _parse_artifacts()
5656
artifacts = affected_artifacts if pull_request else all_artifacts
5757
sdks = ','.join(artifacts)
58+
if not sdks:
59+
_logger.info(
60+
"No sdks found whose binary size to measure ("
61+
"pull_request=%s affected_artifacts=%s all_artifacts=%s)",
62+
pull_request, affected_artifacts, all_artifacts
63+
)
64+
return
5865

5966
workdir = 'health-metrics/apk-size'
6067
process = gradle.run('assemble', '--continue', gradle.P('sdks', sdks), workdir=workdir, check=False)

health-metrics/apk-size/app/configure.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ repositories {
2424
if (project.hasProperty('sdks')) {
2525
project.android {
2626
sdks.split(',').each { sdk ->
27-
def (groupId, artifactId, version) = sdk.split(':')
27+
def sdkParts = sdk.split(':')
28+
if (sdkParts.size() != 3) {
29+
throw new GradleException(
30+
"Invalid SDK format: '${sdk}'. " +
31+
"Expected format: 'groupId:artifactId:version' (sdks: '${sdks}')"
32+
)
33+
}
34+
def (groupId, artifactId, version) = sdkParts
2835
productFlavors.create(artifactId) {
2936
dimension 'firebase'
3037
}

0 commit comments

Comments
 (0)