-
Notifications
You must be signed in to change notification settings - Fork 3.9k
buildscripts: Add Kokoro-based CI for Android APK stats #3984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple comments for future consideration. The build scripts LGTM
mkdir -p reports | ||
echo '<html><head></head><body>' > reports/kokoro_index.html | ||
echo '<h1>'${KOKORO_JOB_NAME}', build '#${KOKORO_BUILD_NUMBER}'</h1>' >> reports/kokoro_index.html | ||
echo '<h2><a href="https://kokoro2.corp.google.com/job/'${KOKORO_JOB_PATH}'/'${KOKORO_BUILD_NUMBER}'/">Kokoro build dashboard (internal only)</a></h2>' >> reports/kokoro_index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up: we might be moved from kokoro2 in the future. Just saying so that if this link stops working, you'll know the reason this link broke the last time for us last time.
echo '<html><head></head><body>' > reports/kokoro_index.html | ||
echo '<h1>'${KOKORO_JOB_NAME}', build '#${KOKORO_BUILD_NUMBER}'</h1>' >> reports/kokoro_index.html | ||
echo '<h2><a href="https://kokoro2.corp.google.com/job/'${KOKORO_JOB_PATH}'/'${KOKORO_BUILD_NUMBER}'/">Kokoro build dashboard (internal only)</a></h2>' >> reports/kokoro_index.html | ||
echo '<h2><a href="https://sponge.corp.google.com/invocation?id='${KOKORO_BUILD_ID}'&searchFor=">Test result dashboard (internal only)</a></h2>' >> reports/kokoro_index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely also be switched to a result storage site that is publicly accessible.
404210a
to
5719fde
Compare
a62a4f1
to
5a30417
Compare
5a30417
to
4a8f791
Compare
@ejona86 This change is now redone as an addition to our existing Cronet Kokoro build (which I'll rename to simply Edit: The second commit can be ignored and will be dropped before merging. It introduces an artificial change to core that increases the APK size and dex count to demo the new status messages. |
4a8f791
to
babed13
Compare
babed13
to
927bc75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't finish, but sending what I have.
buildscripts/kokoro/cronet.sh
Outdated
../../../buildscripts/set_github_status.py \ | ||
--sha1 $KOKORO_GITHUB_PULL_REQUEST_COMMIT \ | ||
--state success \ | ||
--description "New APK size in bytes: $new_apk_size (delta: $apk_size_delta)" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make these easier to read? Probably $(printf "%'d" "$new_apk_size")
to add thousands separator would be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -105,6 +106,8 @@ | |||
static final Status SUBCHANNEL_SHUTDOWN_STATUS = | |||
Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked"); | |||
|
|||
private final Gson gson = new Gson(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - this is a demo commit so the status messages on this PR show non-zero increases.
buildscripts/kokoro/cronet.sh
Outdated
|
||
# Set up APK size and dex count statuses | ||
|
||
gsutil cp gs://grpc-testing-secrets/github_credentials/oauth_token.txt ~/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the code needs to handle KOKORO_GITHUB_PULL_REQUEST_COMMIT being unset. This script can be run on master/release branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
buildscripts/kokoro/cronet.sh
Outdated
@@ -3,6 +3,119 @@ | |||
set -exu -o pipefail | |||
cat /VERSION | |||
|
|||
cd ./github/grpc-java/cronet | |||
BASE_DIR=$(pwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote all variables when used. Quote commands (like "$(pwd)"
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
buildscripts/kokoro/cronet.sh
Outdated
cd $BASE_DIR/github/grpc-java | ||
|
||
# TODO(ericgribkoff) Remove once merged | ||
git checkout $KOKORO_GITHUB_PULL_REQUEST_COMMIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unfortunate. I don't think it's something I'd want us to remove (rather, I want us to always use the most recent version of the script.) Maybe there's an alternative, like copying the script some place else...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
buildscripts/kokoro/cronet.sh
Outdated
|
||
|
||
# Install gRPC and codegen for the Android examples | ||
# (a composite gradle build can't find protoc-gen-grpc-java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this have been caused by d4b11e5 (i.e., it is no longer a problem)? I know I saw the problem earlier, but I don't see it any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's still a problem. The Gradle composite build documentation's section on current limitations says "Native builds are not supported. (Binary dependencies are not yet supported for native builds)." Although I'm not entirely sure this is the reason for the failure to find protoc-gen-grpc-java, as I'm not sure it applies to the direction of the dependency on a native build here.
buildscripts/kokoro/cronet.sh
Outdated
# Get the APK size and dex count stats using the target branch | ||
|
||
sudo apt-get install -y jq | ||
target_branch=$(curl -s https://api.github.com/repos/grpc/grpc-java/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing JSON... that's unfortunate. I wonder if we could look at the merge commit parents. Also, it should probably be .base.sha
since the ref may be different from when the clone was done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to compare to the latest master (or whatever branching the PR is targeting), regardless of when they created their branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to compare against the base this commit was built from. That is fixed at the start of the build. However, master can change over time, even during our build. If there is a merge commit, we could do git rev-parse HEAD^
(or more unlikely HEAD^2
, depending on how the merge was done). If there's no merge commit... maybe we could use git merge-base
... But I sort of expect to see merge commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I was assuming that the base branch (e.g., master) was already in the local repo at the start of the build. That is not always the case, so if the checkout ends up pulling from the remote repository, using the base branch name could indeed end up pulling in changes that didn't exist when the build began.
It turns out that Github already creates the merge commit for you, and that can be used to build and test the PR: it's not quite documentation, but it appears to match reality: https://stackoverflow.com/questions/42626068/how-do-i-list-all-remote-refs
As far I can tell there will never be more than two parents of the merge commit, so we don't need to worry about HEAD^2
.
cc @matt-kwong The curl -s https://api.github.com/repos/grpc/grpc-java/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref
approach was copied from what grpc/grpc was doing. It looks like there might be a simpler and more correct alternative in git rev-parse
(Also, it is possible to change the target branch for a PR mid-build via Github's web UI, so the value being parsed from the JSON here could be different than what was used for the merge commit)
9afb599
to
9849d88
Compare
9849d88
to
bbda65b
Compare
This reverts commit 927bc75.
1c0504b
to
e7f8b1a
Compare
4605090
to
e8d8c96
Compare
buildscripts/kokoro/cronet.sh
Outdated
trap set_status_to_fail_on_error ERR | ||
|
||
|
||
"$SET_GITHUB_STATUS" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting these statuses is pretty late. You've already done a full build, you just have a small incremental build left. These should either be earlier or removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. If this fails the main build status will be reported as failure anyway, so the extra statuses for apk size and dex count are unnecessary.
Internal change is cl/182328214.The first commit just pulls in some prerequisite build updates from #3975 to allow the gradle dexcount and apksize plugins to work.Edit: now incorporating the APK stat diffs into the existing cronet kokoro job, see comment below.