From beca17255432d7e9502f94a85c4477a237730798 Mon Sep 17 00:00:00 2001 From: Stephan Altmueller Date: Mon, 7 May 2018 10:23:42 -0400 Subject: Add datastore emulator to gcloud asset Bug: skia: Change-Id: I2f0986e0ae3057e0a7fca479c0f3e062f10c3eba Reviewed-on: https://skia-review.googlesource.com/126205 Commit-Queue: Stephan Altmueller Reviewed-by: Ben Wagner --- infra/bots/assets/gcloud_linux/VERSION | 2 +- infra/bots/assets/gcloud_linux/create.py | 17 +++++++++++++++-- infra/bots/assets/gcloud_linux/create_and_upload.py | 7 +++++-- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'infra/bots') diff --git a/infra/bots/assets/gcloud_linux/VERSION b/infra/bots/assets/gcloud_linux/VERSION index 62f9457511..9a037142aa 100644 --- a/infra/bots/assets/gcloud_linux/VERSION +++ b/infra/bots/assets/gcloud_linux/VERSION @@ -1 +1 @@ -6 \ No newline at end of file +10 \ No newline at end of file diff --git a/infra/bots/assets/gcloud_linux/create.py b/infra/bots/assets/gcloud_linux/create.py index a37374f462..2c66bb2c97 100755 --- a/infra/bots/assets/gcloud_linux/create.py +++ b/infra/bots/assets/gcloud_linux/create.py @@ -19,18 +19,31 @@ import subprocess # scripting gcloud and also for updates. BASE_URL = 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/%s' GCLOUD_BASE_NAME='google-cloud-sdk' -GCLOUD_ARCHIVE = '%s-191.0.0-linux-x86_64.tar.gz' % GCLOUD_BASE_NAME +GCLOUD_ARCHIVE = '%s-200.0.0-linux-x86_64.tar.gz' % GCLOUD_BASE_NAME GCLOUD_URL = BASE_URL % GCLOUD_ARCHIVE def create_asset(target_dir): """Create the asset.""" + target_dir = os.path.abspath(target_dir) subprocess.check_call(['curl', GCLOUD_URL, '-o', GCLOUD_ARCHIVE]) # Extract the arcive to the target directory and remove it. subprocess.check_call(['tar', '-xzf', GCLOUD_ARCHIVE, '--strip-components=1', '-C', target_dir]) - subprocess.check_call(['rm', GCLOUD_ARCHIVE]) + + # Substitute the HOME directory in the environment so we don't overwrite + # an existing gcloud configuration in $HOME/.config/gcloud + env = os.environ.copy() + env["HOME"] = target_dir + gcloud_exe = os.path.join(target_dir, 'bin', 'gcloud') + subprocess.check_call([gcloud_exe, 'components', + 'install', 'beta', 'cloud-datastore-emulator', + '--quiet'], env=env) + subprocess.check_call([gcloud_exe, 'components','update', '--quiet'], env=env) + + # Remove the tarball. + os.remove(GCLOUD_ARCHIVE) def main(): parser = argparse.ArgumentParser() diff --git a/infra/bots/assets/gcloud_linux/create_and_upload.py b/infra/bots/assets/gcloud_linux/create_and_upload.py index cc81ec5c00..92b5a3105e 100755 --- a/infra/bots/assets/gcloud_linux/create_and_upload.py +++ b/infra/bots/assets/gcloud_linux/create_and_upload.py @@ -11,6 +11,7 @@ import argparse import common +import shutil import os import subprocess import sys @@ -24,12 +25,14 @@ def main(): with utils.tmp_dir(): cwd = os.getcwd() + workdir = os.path.join(cwd, "workdir") create_script = os.path.join(common.FILE_DIR, 'create.py') upload_script = os.path.join(common.FILE_DIR, 'upload.py') try: - subprocess.check_call(['python', create_script, '-t', cwd]) - cmd = ['python', upload_script, '-t', cwd] + os.mkdir(workdir) + subprocess.check_call(['python', create_script, '-t', workdir]) + cmd = ['python', upload_script, '-t', workdir] if args.gsutil: cmd.extend(['--gsutil', args.gsutil]) subprocess.check_call(cmd) -- cgit v1.2.3