3
3
set -exu -o pipefail
4
4
cat /VERSION
5
5
6
- BASE_DIR=$( pwd)
6
+ BASE_DIR=" $( pwd) "
7
7
8
- # Set up APK size and dex count statuses
9
-
10
- gsutil cp gs://grpc-testing-secrets/github_credentials/oauth_token.txt ~ /
11
-
12
- function set_status_to_fail_on_error {
13
- cd $BASE_DIR /github/grpc-java
14
-
15
- # TODO(ericgribkoff) Remove once merged
16
- git checkout $KOKORO_GITHUB_PULL_REQUEST_COMMIT
8
+ # Build Cronet
17
9
18
- ./buildscripts/set_github_status.py \
19
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
20
- --state error \
21
- --description " Failed to calculate DEX count" \
22
- --context android/dex_diff --oauth_file ~ /oauth_token.txt
23
- ./buildscripts/set_github_status.py \
24
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
25
- --state error \
26
- --description " Failed to calculate APK size" \
27
- --context android/apk_diff --oauth_file ~ /oauth_token.txt
28
- }
29
- trap set_status_to_fail_on_error ERR
10
+ cd " $BASE_DIR /github/grpc-java/cronet"
11
+ ./cronet_deps.sh
12
+ ../gradlew --include-build .. build
30
13
31
- $BASE_DIR /github/grpc-java/buildscripts/set_github_status.py \
32
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
33
- --state pending \
34
- --description " Waiting for DEX count to be reported" \
35
- --context android/dex_diff --oauth_file ~ /oauth_token.txt
36
- $BASE_DIR /github/grpc-java/buildscripts/set_github_status.py \
37
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
38
- --state pending \
39
- --description " Waiting for APK size to be reported" \
40
- --context android/apk_diff --oauth_file ~ /oauth_token.txt
41
14
42
15
43
- # Build Cronet
44
16
45
- cd $BASE_DIR /github/grpc-java/cronet
46
- ./cronet_deps.sh
47
- ../gradlew --include-build .. build
48
17
49
18
50
19
# Install gRPC and codegen for the Android examples
51
20
# (a composite gradle build can't find protoc-gen-grpc-java)
52
21
53
- cd $BASE_DIR /github/grpc-java
22
+ cd " $BASE_DIR /github/grpc-java"
54
23
55
24
export GRADLE_OPTS=-Xmx512m
56
25
export PROTOBUF_VERSION=3.5.1
@@ -69,53 +38,91 @@ cd ./examples/android/clientcache
69
38
./gradlew build
70
39
cd ../routeguide
71
40
./gradlew build
41
+ cd ../helloworld
42
+ ./gradlew build
72
43
73
44
74
- # Build and collect APK size and dex count stats for the helloworld example
45
+ # Skip APK size and dex count comparisons for non-PR builds
75
46
76
- cd ../helloworld
77
- ./gradlew build
47
+ if [[ -z " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " ]]; then
48
+ echo " Skipping APK size and dex count"
49
+ exit 0
50
+ fi
51
+
52
+
53
+ # Set up APK size and dex count statuses
54
+
55
+ SET_GITHUB_STATUS=" $TMPDIR /set_github_status.py"
56
+ cp " $BASE_DIR /github/grpc-java/buildscripts/set_github_status.py" " $SET_GITHUB_STATUS "
57
+
58
+ gsutil cp gs://grpc-testing-secrets/github_credentials/oauth_token.txt ~ /
59
+
60
+ function set_status_to_fail_on_error {
61
+ " $SET_GITHUB_STATUS " \
62
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
63
+ --state error \
64
+ --description " Failed to calculate DEX count" \
65
+ --context android/dex_diff --oauth_file ~ /oauth_token.txt
66
+ " $SET_GITHUB_STATUS " \
67
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
68
+ --state error \
69
+ --description " Failed to calculate APK size" \
70
+ --context android/apk_diff --oauth_file ~ /oauth_token.txt
71
+ }
72
+ trap set_status_to_fail_on_error ERR
73
+
74
+ exit 1
75
+
76
+ " $SET_GITHUB_STATUS " \
77
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
78
+ --state pending \
79
+ --description " Waiting for DEX count to be reported" \
80
+ --context android/dex_diff --oauth_file ~ /oauth_token.txt
81
+ " $SET_GITHUB_STATUS " \
82
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
83
+ --state pending \
84
+ --description " Waiting for APK size to be reported" \
85
+ --context android/apk_diff --oauth_file ~ /oauth_token.txt
86
+
87
+ # Collect APK size and dex count stats for the helloworld example
78
88
79
89
read -r ignored new_dex_count < \
80
- <( ${ANDROID_HOME} /tools/bin/apkanalyzer dex references app/build/outputs/apk/release/app-release-unsigned.apk)
90
+ <( " ${ANDROID_HOME} /tools/bin/apkanalyzer" dex references app/build/outputs/apk/release/app-release-unsigned.apk)
81
91
82
- new_apk_size=$( stat --printf=%s app/build/outputs/apk/release/app-release-unsigned.apk)
92
+ new_apk_size=" $( stat --printf=%s app/build/outputs/apk/release/app-release-unsigned.apk) "
83
93
84
94
85
95
# Get the APK size and dex count stats using the target branch
86
96
87
97
sudo apt-get install -y jq
88
- target_branch=$( curl -s https://api.github.com/repos/grpc/grpc-java/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
98
+ target_branch=" $( curl -s https://api.github.com/repos/grpc/grpc-java/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) "
89
99
90
100
cd $BASE_DIR /github/grpc-java
91
- git checkout $target_branch
101
+ git checkout " $target_branch "
92
102
./gradlew install
93
103
cd examples/android/helloworld/
94
104
./gradlew build
95
105
96
106
read -r ignored old_dex_count < \
97
- <( ${ANDROID_HOME} /tools/bin/apkanalyzer dex references app/build/outputs/apk/release/app-release-unsigned.apk)
107
+ <( " ${ANDROID_HOME} /tools/bin/apkanalyzer" dex references app/build/outputs/apk/release/app-release-unsigned.apk)
98
108
99
- old_apk_size=$( stat --printf=%s app/build/outputs/apk/release/app-release-unsigned.apk)
109
+ old_apk_size=" $( stat --printf=%s app/build/outputs/apk/release/app-release-unsigned.apk) "
100
110
101
- dex_count_delta=$(( new_dex_count- old_dex_count))
111
+ dex_count_delta=" $(( new_dex_count- old_dex_count)) "
102
112
103
- apk_size_delta=$(( new_apk_size- old_apk_size))
113
+ apk_size_delta=" $(( new_apk_size- old_apk_size)) "
104
114
105
115
106
116
# Update the statuses with the deltas
107
117
108
- # TODO(ericgribkoff) Remove checkout once merged
109
- git checkout $KOKORO_GITHUB_PULL_REQUEST_COMMIT
110
-
111
- ../../../buildscripts/set_github_status.py \
112
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
118
+ " $SET_GITHUB_STATUS " \
119
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
113
120
--state success \
114
- --description " New DEX reference count: $new_dex_count (delta: $dex_count_delta )" \
121
+ --description " New DEX reference count: $( printf " %'d " " $ new_dex_count" ) (delta: $( printf " %'d " " $ dex_count_delta" ) )" \
115
122
--context android/dex_diff --oauth_file ~ /oauth_token.txt
116
123
117
- ../../../buildscripts/set_github_status.py \
118
- --sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \
124
+ " $SET_GITHUB_STATUS " \
125
+ --sha1 " $KOKORO_GITHUB_PULL_REQUEST_COMMIT " \
119
126
--state success \
120
- --description " New APK size in bytes: $new_apk_size (delta: $apk_size_delta )" \
127
+ --description " New APK size in bytes: $( printf " %'d " " $ new_apk_size" ) (delta: $( printf " %'d " " $ apk_size_delta" ) )" \
121
128
--context android/apk_diff --oauth_file ~ /oauth_token.txt
0 commit comments