-
Notifications
You must be signed in to change notification settings - Fork 148
Add Google Cloud SDK #36
Add Google Cloud SDK #36
Conversation
Thanks for the PR! A note: please don't change the |
# --- https://firebase.google.com/docs/test-lab/command-line | ||
|
||
# Install the Google Cloud SDK. | ||
ENV HOME / |
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.
please don't change the HOME
env
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.
# Install the Google Cloud SDK. | ||
ENV HOME / | ||
ENV CLOUDSDK_PYTHON_SITEPACKAGES 1 | ||
RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip && unzip google-cloud-sdk.zip && rm google-cloud-sdk.zip |
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.
the SDK is available as an official apt package, it's usually better to use that. See the apt-get (Debian and Ubuntu only)
section at https://cloud.google.com/sdk/downloads?hl=sr#linux
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.
Apt provides no control over the configuration, for example installing only the beta components. These steps are from the official Docker image (where they also don't install via apt).
I will test to see if the apt install contains the necessary components.
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.
Apt provides no control over the configuration, for example installing only the beta components.
AFAIK the apt versions include every component - or do you mean that there are components which are not available in the APT version?
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.
AFAIK the apt versions include every component
No, certain components are broken out into dedicated packages.
Optionally install any of these additional components:
google-cloud-sdk-app-engine-python
google-cloud-sdk-app-engine-java
google-cloud-sdk-datastore-emulator
google-cloud-sdk-pubsub-emulator
google-cloud-sdk-bigtable-emulator
kubectl
I don't see one for beta
which is required for testing. I'll know for sure in a bit once I finish exploring the package.
Update: beta is installed by default.
https://github.com/bitrise-docker/android/issues/35#issuecomment-262027376
Error for the first build:
|
I'm seeing the errors also. I'll post an update once I've confirmed this is working. |
&& sudo apt-get install -y -qq google-cloud-sdk | ||
|
||
RUN /usr/bin/gcloud config set --installation component_manager/disable_update_check true | ||
RUN sed -i -- 's/\"disable_updater\": false/\"disable_updater\": true/g' /usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/config.json |
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.
is this required even if you run gcloud config set --installation component_manager/disable_update_check true
?
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.
Isn't gcloud config set --installation component_manager/disable_update_check true
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.
# Disable updater completely.
# Running `gcloud components update` doesn't really do anything in a union FS.
# Changes are lost on a subsequent run.
RUN sed -i -- 's/\"disable_updater\": false/\"disable_updater\": true/g' /google-cloud-sdk/lib/googlecloudsdk/core/config.json
I also manually confirmed that gcloud config set never updates the config.json file.
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.
Makes sense, thank you!
# --- https://firebase.google.com/docs/test-lab/command-line | ||
# --- https://cloud.google.com/sdk/downloads?hl=sr#linux | ||
|
||
ENV CLOUD_SDK_REPO="cloud-sdk-xenial" |
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.
CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
would be better, without that we'll have to update this variable from xenial
when we update the base Ubuntu version
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.
Back ticks should work, we use it here for example: https://github.com/bitrise-docker/bitrise-base/blob/master/Dockerfile#L95
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.
E: Failed to fetch https://packages.cloud.google.com/apt/dists/cloud-sdk-$(lsb_release/-c/binary-amd64/Packages 404 Not Found
Ok, this is ready for review.
|
|
||
ENV CLOUD_SDK_REPO="cloud-sdk-xenial" | ||
|
||
RUN echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \ |
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.
I think, as $CLOUD_SDK_REPO
is not used anywhere else, we could remove the ENV line and instead include
cloud-sdk-`lsb_release -c -s`
here directly, like:
RUN echo "deb https://packages.cloud.google.com/apt cloud-sdk-`lsb_release -c -s` main"
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.
great, I will make this update.
I think I've addressed all the feedback. Let me know if I missed anything. |
@@ -23,6 +23,7 @@ ver_line="$(gradle --version | grep 'Gradle ')" ; echo "* Gradle: $ver_line" | |||
ver_line="$(mvn --version | grep 'Apache Maven')" ; echo "* Maven: $ver_line" | |||
ver_line="$(fastlane --version | grep 'fastlane ')" ; echo "* Fastlane: $ver_line" | |||
ver_line="$( javac -version 2>&1 )" ; echo "* Java: $ver_line" | |||
gcloud version # Lists all gcloud components |
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.
as this isn't a one liner, please move it into a separate section like https://github.com/bitrise-docker/android/pull/36/files#diff-1311e47d25cde7d83a0381e5c2b5d06eR32
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
Looks good - hopefully the tests will pass (a full round of test takes ~35 mins right now, as it does a full, clean |
Tests passed. |
LGTM, thank you @bootstraponline ! Release Schedule: as usual, the Android stack will be updated/released during the weekend, your changes will be available at the end of this week. Thanks for the contribution, and Happy Building! :) 🎉 |
@bootstraponline I made a couple of minor (style) changes, for easier future maintenance - if you have the time feel free to 👍 / 👎 the PR: #37 |
+1ed. Thanks for the awesome contribution process. It's great to have rapid feedback & a fast deploy cycle. |
Thanks for the PR! ;) Btw technically your change is now available in the |
@viktorbenei hey does
|
That seems like a network config issue on your Mac @bootstraponline - I don't have a VM/machine with the pre release image yet. |
It works fine outside of the VM so yeah probably Docker is being strange. Hopefully it's not an issue on the production deploy. |
It shouldn't be, but we'll see - feel free to add additional tests to the |
(Additional full test builds are performed on the alpha images before release, first ones on Friday before the "feature lock down") |
I submitted #38 which runs the network check in |
Merged ;) |
My Android Firebase tests are passing on bitrise. For now I added the install steps from the Dockerfile directly to a workflow. It takes about ~33 seconds to install the It might be nice to have documentation then Google can link people to Bitrise like they do for circle ci. |
Awesome idea, and thanks for the links @bootstraponline ! I think this could be encapsulated into a Step too, to make it easy to setup & run tests. Feel free to submit a step if you have the time ;) |
I encapsulated the logic into an internal Fastlane Ruby step. :) I tested a bash version as well before porting to Ruby. Might be helpful for someone who wants to write a Bitrise Step. set -euxo pipefail
mkdir -p ~/.gradle
# remove old daemons
rm -rf ~/.gradle/daemon
echo "org.gradle.jvmargs=-Xmx2560M" > ~/.gradle/gradle.properties
./gradlew :app:assembleDebug :app:assembleDebugAndroidTest > /dev/null
# todo: remove this after Dockerfile deploy next week
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
export DEBIAN_FRONTEND="noninteractive"
echo "deb https://packages.cloud.google.com/apt cloud-sdk-`lsb_release -c -s` main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update -qq
sudo apt-get install -y -qq google-cloud-sdk > /dev/null
# now auth to gcloud
echo $GCLOUD_KEY | base64 --decode > "$HOME/gcloudkey.json"
gcloud config set project "$GCLOUD_PROJECT"
gcloud auth activate-service-account --key-file "$HOME/gcloudkey.json" "$GCLOUD_USER"
# run the test!
export APP_APK="/bitrise/src/my/app/build/outputs/apk/app-debug.apk"
export TEST_APK="/bitrise/src/my/app/build/outputs/apk/app-debug-androidTest.apk"
# ensure we don't have old logs
rm -rf gcloud.log
unbuffer \
gcloud beta test android run \
--type instrumentation \
--app "$APP_APK" \
--test "$TEST_APK" \
--results-bucket my-named-bucket \
--device-ids Nexus9 \
--os-version-ids 25 \
--locales en \
--orientations portrait \
--timeout 25m \
2>&1 | tee gcloud.log
# todo: parse gcloud.log for results bucket link
# and download artifacts with gsutil |
Thanks @bootstraponline - I created a Bitrise Contrib ticket for this, and linked your comment/code ;) - bitrise-io/bitrise-contrib#29 |
Fix https://github.com/bitrise-docker/android/issues/35