Skip to content

Commit

Permalink
remove noxfile from owlbot control
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Jul 17, 2024
1 parent fb59297 commit 6ecd9f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 142 deletions.
3 changes: 3 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def docfx(session):
os.path.join("docs", ""),
os.path.join("docs", "_build", "html", ""),
)
# Customization: Add extra sections to the table of contents for the Classic vs Async clients
session.install("pyyaml")
session.run("python", "docs/scripts/patch_devsite_toc.py")


@nox.session(python="3.12")
Expand Down
143 changes: 1 addition & 142 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,148 +95,7 @@ def get_staging_dirs(
],
)

s.move(templated_files, excludes=[".coveragerc", "README.rst", ".github/release-please.yml"])

# ----------------------------------------------------------------------------
# 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)
num_replacements = s.replace([path], text, replacement)
if num_replacements != 1:
raise ValueError(f"Expected to find '{text}' once in {path}, but found it {num_replacements} times.")

system_emulated_session = """
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
def system_emulated(session):
import subprocess
import signal
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", "bigtable"])
hostport = "localhost:8789"
session.env["BIGTABLE_EMULATOR_HOST"] = hostport
p = subprocess.Popen(
["gcloud", "beta", "emulators", "bigtable", "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="()"
)

conformance_session = """
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
def conformance(session):
TEST_REPO_URL = "https://github.com/googleapis/cloud-bigtable-clients-test.git"
CLONE_REPO_DIR = "cloud-bigtable-clients-test"
# install dependencies
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
install_unittest_dependencies(session, "-c", constraints_path)
with session.chdir("test_proxy"):
# download the conformance test suite
clone_dir = os.path.join(CURRENT_DIRECTORY, CLONE_REPO_DIR)
if not os.path.exists(clone_dir):
print("downloading copy of test repo")
session.run("git", "clone", TEST_REPO_URL, CLONE_REPO_DIR, external=True)
session.run("bash", "-e", "run_tests.sh", external=True)
"""

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

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


s.replace(
"noxfile.py",
"""\
@nox.session\(python=DEFAULT_PYTHON_VERSION\)
def lint_setup_py\(session\):
""",
'''\
@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""
session.install("-e", ".")
session.install("mypy", "types-setuptools", "types-protobuf", "types-mock", "types-requests")
session.install("google-cloud-testutils")
session.run(
"mypy",
"-p",
"google.cloud.bigtable.data",
"--check-untyped-defs",
"--warn-unreachable",
"--disallow-any-generics",
"--exclude",
"tests/system/v2_client",
"--exclude",
"tests/unit/v2_client",
)
@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
''',
)

# add customization to docfx
docfx_postprocess = """
# Customization: Add extra sections to the table of contents for the Classic vs Async clients
session.install("pyyaml")
session.run("python", "docs/scripts/patch_devsite_toc.py")
"""

place_before(
"noxfile.py",
'@nox.session(python="3.12")\n'
"@nox.parametrize(\n"
' "protobuf_implementation",\n'
' ["python", "upb", "cpp"],\n'
')\n'
"def prerelease_deps(session, protobuf_implementation):",
docfx_postprocess,
)

s.move(templated_files, excludes=[".coveragerc", "README.rst", ".github/release-please.yml", "noxfile.py"])

# ----------------------------------------------------------------------------
# Customize gapics to include PooledBigtableGrpcAsyncIOTransport
Expand Down

0 comments on commit 6ecd9f7

Please sign in to comment.