Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/gha/gcs_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def main(argv):
for artifact in artifacts:
dest = _local_path_to_gcs_uri(gcs_prefix, artifact, testapp_dir)
logging.info("Creating %s", dest)
subprocess.run([gcs.GSUTIL, "cp", artifact, dest], check=True)
subprocess.run([gcs.GCLOUD, "storage", "cp", artifact, dest], check=True)
logging.info("Finished uploading to %s", gcs_prefix)
logging.info(
"Use 'gsutil cp <gs_uri> <local_path>' to copy an artifact locally.\n"
"Use 'gsutil -m cp -r %s <local_path>' to copy everything.", gcs_prefix)
"Use 'gcloud storage cp <gs_uri> <local_path>' to copy an artifact locally.\n"
"Use 'gcloud storage cp --recursive %s <local_path>' to copy everything.", gcs_prefix)


def _local_path_to_gcs_uri(gcs_prefix, path, testapp_dir):
Expand Down
6 changes: 3 additions & 3 deletions scripts/gha/integration_testing/ftl_gha_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import re
from retry import retry

GSUTIL = shutil.which("gsutil")
GCLOUD = shutil.which("gcloud")

def validate(test_summary):
if not test_summary:
Expand Down Expand Up @@ -77,7 +77,7 @@ def _get_testapp_log_text_from_gcs(gcs_path):
@retry(subprocess.CalledProcessError, tries=10, delay=5, backoff=1.5)
def _gcs_list_dir(gcs_path):
"""Recursively returns a list of contents for a directory on GCS."""
args = [GSUTIL, "ls", "-r", gcs_path]
args = [GCLOUD, "storage", "ls", "--recursive", gcs_path]
logging.info("Listing GCS contents: %s", " ".join(args))
try:
result = subprocess.run(args=args, capture_output=True, text=True, check=True)
Expand All @@ -97,7 +97,7 @@ def _gcs_list_dir(gcs_path):
@retry(subprocess.CalledProcessError, tries=10, delay=5, backoff=1.5)
def _gcs_read_file(gcs_path):
"""Extracts the contents of a file on GCS."""
args = [GSUTIL, "cat", gcs_path]
args = [GCLOUD, "storage", "cat", gcs_path]
logging.info("Reading GCS file: %s", " ".join(args))
try:
result = subprocess.run(args=args, capture_output=True, text=True, check=True)
Expand Down
18 changes: 7 additions & 11 deletions scripts/gha/integration_testing/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# Note: this kind of thing (among others) could likely be simplified by using
# the gCloud Python API instead of the command line tools.
GCLOUD = shutil.which("gcloud")
GSUTIL = shutil.which("gsutil")

PROJECT_ID = "games-auto-release-testing"

Expand Down Expand Up @@ -56,7 +55,7 @@ def get_unique_gcs_id():


def relative_path_to_gs_uri(path):
"""Converts a relative GCS path to a GS URI understood by gsutil.
"""Converts a relative GCS path to a GS URI understood by gcloud storage.

This will prepend the gs prefix and project id to the path, i.e.
path -> gs://<project_id>/results_dir
Expand Down Expand Up @@ -93,21 +92,18 @@ def authorize_gcs(key_file):
def get_gsutil_tips():
"""Returns a human readable string with tips on accessing a GCS bucket."""
return "\n".join((
"GCS Advice: Install the Google Cloud SDK to access the gsutil tool.",
"Use 'gsutil ls <gs_uri>' to list contents of a directory on GCS.",
"Use 'gsutil cp <gs_uri> <local_path>' to copy an artifact.",
"Use 'gsutil -m cp -r <gs_uri> <local_path>' to copy a directory."
"GCS Advice: Install the Google Cloud SDK to access the gcloud storage tool.",
"Use 'gcloud storage ls <gs_uri>' to list contents of a directory on GCS.",
"Use 'gcloud storage cp <gs_uri> <local_path>' to copy an artifact.",
"Use 'gcloud storage cp --recursive <gs_uri> <local_path>' to copy a directory."
))


def _verify_gcloud_sdk_command_line_tools():
"""Verifies the presence of the gCloud SDK's command line tools."""
logging.info("Looking for gcloud and gsutil tools...")
logging.info("Looking for gcloud tools...")
if not GCLOUD:
logging.error("gcloud not on path")
if not GSUTIL:
logging.error("gsutil not on path")
if not GCLOUD or not GSUTIL:
if not GCLOUD:
raise RuntimeError("Could not find required gCloud SDK tool(s)")
subprocess.run([GCLOUD, "version"], check=True)
subprocess.run([GSUTIL, "version"], check=True)
Loading