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
4 changes: 2 additions & 2 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:710b70faff81151657d89db6e028c23a1051787598c8276bdd8eef25c92da8ab
# created: 2025-04-10T17:48:54.829145676Z
digest: sha256:25de45b58e52021d3a24a6273964371a97a4efeefe6ad3845a64e697c63b6447
# created: 2025-04-14T14:34:43.260858345Z
135 changes: 3 additions & 132 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def update_fixup_scripts(library):
)

for library in get_staging_dirs(default_version=firestore_default_version, sub_directory="firestore"):
s.move(library / f"google/cloud/firestore_{library.name}", excludes=[f"__init__.py", "**/gapic_version.py"])
s.move(library / f"google/cloud/firestore_{library.name}", excludes=[f"__init__.py", "**/gapic_version.py", "noxfile.py"])
s.move(library / f"tests/", f"tests")
update_fixup_scripts(library)
s.move(library / "scripts")

for library in get_staging_dirs(default_version=firestore_admin_default_version, sub_directory="firestore_admin"):
s.move(library / f"google/cloud/firestore_admin_{library.name}", excludes=[f"__init__.py", "**/gapic_version.py"])
s.move(library / f"google/cloud/firestore_admin_{library.name}", excludes=[f"__init__.py", "**/gapic_version.py", "noxfile.py"])
s.move(library / f"tests", f"tests")
update_fixup_scripts(library)
s.move(library / "scripts")
Expand Down Expand Up @@ -127,7 +127,7 @@ def update_fixup_scripts(library):
s.move(
library / f"google/cloud/bundle",
f"google/cloud/firestore_bundle",
excludes=["**/gapic_version.py"],
excludes=["**/gapic_version.py", "noxfile.py"],
)
s.move(library / f"tests", f"tests")

Expand All @@ -151,133 +151,6 @@ def update_fixup_scripts(library):

python.py_samples(skip_readmes=True)

# ----------------------------------------------------------------------------
# Customize noxfile.py
# ----------------------------------------------------------------------------

def place_before(path, text, *before_text, escape=None):
replacement = "\n".join(before_text) + "\n" + text
if escape:
for c in escape:
text = text.replace(c, '\\' + c)
s.replace([path], text, replacement)

system_emulated_session = """
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
def system_emulated(session):
import subprocess
import signal

try:
# https://github.com/googleapis/python-firestore/issues/472
# Kokoro image doesn't have java installed, don't attempt to run emulator.
subprocess.call(["java", "--version"])
except OSError:
session.skip("java not found but required for emulator support")

try:
subprocess.call(["gcloud", "--version"])
except OSError:
session.skip("gcloud not found but required for emulator support")

# Currently, CI/CD doesn't have beta component of gcloud.
subprocess.call(
["gcloud", "components", "install", "beta", "cloud-firestore-emulator",]
)

hostport = "localhost:8789"
session.env["FIRESTORE_EMULATOR_HOST"] = hostport

p = subprocess.Popen(
[
"gcloud",
"--quiet",
"beta",
"emulators",
"firestore",
"start",
"--host-port",
hostport,
]
)

try:
system(session)
finally:
# Stop Emulator
os.killpg(os.getpgid(p.pid), signal.SIGKILL)

"""

place_before(
"noxfile.py",
"@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\n"
"def system(session):",
system_emulated_session,
escape="()"
)

# add system_emulated + mypy nox session
s.replace("noxfile.py",
"""nox.options.sessions = \[
"unit",
"system",""",
"""nox.options.sessions = [
"unit",
"system_emulated",
"system",
"mypy",""",
)

s.replace(
"noxfile.py",
"""\"--quiet\",
f\"--junitxml=system_\{session.python\}_sponge_log.xml\",
system_test""",
"""\"--verbose\",
f\"--junitxml=system_{session.python}_sponge_log.xml\",
system_test""",
)

s.replace(
"noxfile.py",
"""\
BLACK_VERSION = "black\[jupyter\]==23.7.0"
""",
"""\
PYTYPE_VERSION = "pytype==2020.7.24"
BLACK_VERSION = "black[jupyter]==23.7.0"
""",
)

s.replace(
"noxfile.py",
"""\
@nox.session\(python=DEFAULT_PYTHON_VERSION\)
def lint_setup_py\(session\):
""",
'''\
@nox.session(python="3.7")
def pytype(session):
"""Verify type hints are pytype compatible."""
session.install(PYTYPE_VERSION)
session.run("pytype",)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""
session.install("-e", ".")
session.install("mypy", "types-setuptools")
# TODO: also verify types on tests, all of google package
session.run("mypy", "-p", "google.cloud.firestore", "--no-incremental")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
''',
)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)

s.replace(
Expand All @@ -289,5 +162,3 @@ def lint_setup_py(session):

# Setup service account credentials.""",
)

s.replace("noxfile.py", "\"pytest-asyncio\"", "\"pytest-asyncio==0.21.2\"")
Loading