8000 fix: CI broken by removal of py.path by clundin25 · Pull Request #1194 · googleapis/google-auth-library-python · GitHub
[go: up one dir, main page]

Skip to content

fix: CI broken by removal of py.path #1194

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

Merged
merged 8 commits into from
Dec 1, 2022
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
32 changes: 18 additions & 14 deletions system_tests/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
"""

import os
import pathlib
import subprocess
import shutil
import tempfile

from nox.command import which
import nox
import py.path

HERE = os.path.abspath(os.path.dirname(__file__))
LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE))
Expand Down Expand Up @@ -59,16 +61,18 @@
CLOUD_SDK_ROOT = os.environ.get("CLOUD_SDK_ROOT")

if CLOUD_SDK_ROOT is not None:
CLOUD_SDK_ROOT = py.path.local(CLOUD_SDK_ROOT)
CLOUD_SDK_ROOT.ensure(dir=True) # Makes sure the directory exists.
CLOUD_SDK_ROOT = pathlib.Path(CLOUD_SDK_ROOT)
if not CLOUD_SDK_ROOT.exists() or not CLOUD_SDK_ROOT.is_dir():
print("{} did not exist! Please set the CLOUD_SDK_ROOT environment variable to a directory that exists".format(CLOUD_SDK_ROOT))
exit(1)
else:
CLOUD_SDK_ROOT = py.path.local.mkdtemp()
CLOUD_SDK_ROOT = pathlib.Path(tempfile.mkdtemp())

# The full path the cloud sdk install directory
CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.join("google-cloud-sdk")
CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.joinpath("google-cloud-sdk")

# The full path to the gcloud cli executable.
GCLOUD = str(CLOUD_SDK_INSTALL_DIR.join("bin", "gcloud"))
GCLOUD = str(CLOUD_SDK_INSTALL_DIR.joinpath("bin", "gcloud"))

# gcloud requires Python 2 and doesn't work on 3, so we need to tell it
# where to find 2 when we're running in a 3 environment.
Expand All @@ -90,26 +94,26 @@ def install_cloud_sdk(session):
# This set the $PATH for the subprocesses so they can find the gcloud
# executable.
session.env["PATH"] = (
str(CLOUD_SDK_INSTALL_DIR.join("bin")) + os.pathsep + os.environ["PATH"]
str(CLOUD_SDK_INSTALL_DIR.joinpath("bin")) + os.pathsep + os.environ["PATH"]
)

# If gcloud cli executable already exists, just update it.
if py.path.local(GCLOUD).exists():
if pathlib.Path(GCLOUD).exists():
session.run(GCLOUD, "components", "update", "-q")
return

tar_path = CLOUD_SDK_ROOT.join(CLOUD_SDK_DIST_FILENAME)
tar_path = CLOUD_SDK_ROOT.joinpath(CLOUD_SDK_DIST_FILENAME)

# Download the release.
session.run("wget", CLOUD_SDK_DOWNLOAD_URL, "-O", str(tar_path), silent=True)

# Extract the release.
session.run("tar", "xzf", str(tar_path), "-C", str(CLOUD_SDK_ROOT))
session.run(tar_path.remove)
tar_path.unlink()

# Run the install script.
session.run(
str(CLOUD_SDK_INSTALL_DIR.join("install.sh")),
str(CLOUD_SDK_INSTALL_DIR.joinpath("install.sh")),
"--usage-reporting",
"false",
"--path-update",
Expand All @@ -123,10 +127,10 @@ def install_cloud_sdk(session):
def copy_credentials(credentials_path):
"""Copies credentials into the SDK root as the application default
credentials."""
dest = CLOUD_SDK_ROOT.join("application_default_credentials.json")
dest = CLOUD_SDK_ROOT.joinpath("application_default_credentials.json")
if dest.exists():
dest.remove()
py.path.local(credentials_path).copy(dest)
dest.unlink()
shutil.copyfile(pathlib.Path(credentials_path), dest)


def configure_cloud_sdk(session, application_default_credentials, project=False):
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
0