diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 8a6490a7..508ba98e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:5581906b957284864632cde4e9c51d1cc66b0094990b27e689132fe5cd036046 -# created: 2024-03-05 + digest: sha256:25de45b58e52021d3a24a6273964371a97a4efeefe6ad3845a64e697c63b6447 +# created: 2025-04-14T14:34:43.260858345Z diff --git a/noxfile.py b/noxfile.py index 625b0e39..9825e03c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -21,7 +21,6 @@ import os import pathlib import re -import re import shutil from typing import Dict, List import warnings diff --git a/owlbot.py b/owlbot.py index d34a5a5c..3b2884f3 100644 --- a/owlbot.py +++ b/owlbot.py @@ -65,219 +65,6 @@ "sqlalchemy_bigquery/requirements.py", ) -s.replace( - ["noxfile.py"], - r"[\"']google[\"']", - '"sqlalchemy_bigquery"', -) - -s.replace( - ["noxfile.py"], - r"import shutil", - "import re\nimport shutil", -) - -s.replace( - ["noxfile.py"], - "LINT_PATHS = \[", - "LINT_PATHS = [\"third_party\", " -) - -s.replace( - ["noxfile.py"], - "--cov=google", - "--cov=sqlalchemy_bigquery", -) - -s.replace( - ["noxfile.py"], - """os.path.join("tests", "unit"),""", - """os.path.join("tests", "unit"), - os.path.join("third_party", "sqlalchemy_bigquery_vendored"),""", -) - -s.replace( - ["noxfile.py"], - "\+ SYSTEM_TEST_EXTRAS", - "", -) - - -s.replace( - ["noxfile.py"], - """"protobuf", - # dependency of grpc""", - """"protobuf", - "sqlalchemy", - # dependency of grpc""", -) - - -s.replace( - ["noxfile.py"], - r"def unit\(session, protobuf_implementation\)", - "def unit(session, protobuf_implementation, install_extras=True)", -) - - -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) - - -place_before( - "noxfile.py", - "nox.options.error_on_missing_interpreters = True", - "nox.options.stop_on_first_error = True", -) - - -install_logic = """ - if install_extras and session.python in ["3.11", "3.12"]: - install_target = ".[geography,alembic,tests,bqstorage]" - elif install_extras: - install_target = ".[all]" - else: - install_target = "." - session.install("-e", install_target, "-c", constraints_path) -""" - -s.replace( - ["noxfile.py"], - r"# TODO\(https://github.com/googleapis/synthtool/issues/1976\):", - install_logic + "\n" + "# TODO(https://github.com/googleapis/synthtool/issues/1976):", -) - - -# Maybe we can get rid of this when we don't need pytest-rerunfailures, -# which we won't need when BQ retries itself: -# https://github.com/googleapis/python-bigquery/pull/837 -compliance = ''' -@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1]) -def compliance(session): - """Run the SQLAlchemy dialect-compliance system tests""" - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance") - - if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false": - session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping") - if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": - session.install("pyopenssl") - if not os.path.exists(system_test_folder_path): - session.skip("Compliance tests were not found") - - session.install( - "mock", - "pytest", - "pytest-rerunfailures", - "google-cloud-testutils", - "-c", - constraints_path, - ) - if session.python == "3.8": - extras = "[tests,alembic]" - elif session.python in ["3.11", "3.12"]: - extras = "[tests,geography]" - else: - extras = "[tests]" - session.install("-e", f".{extras}", "-c", constraints_path) - - session.run("python", "-m", "pip", "freeze") - - session.run( - "py.test", - "-vv", - f"--junitxml=compliance_{session.python}_sponge_log.xml", - "--reruns=3", - "--reruns-delay=60", - "--only-rerun=Exceeded rate limits", - "--only-rerun=Already Exists", - "--only-rerun=Not found", - "--only-rerun=Cannot execute DML over a non-existent table", - "--only-rerun=Job exceeded rate limits", - system_test_folder_path, - *session.posargs, - # To suppress the "Deprecated API features detected!" warning when - # features not compatible with 2.0 are detected, use a value of "1" - env={ - "SQLALCHEMY_SILENCE_UBER_WARNING": "1", - }, - ) - - -''' - -place_before( - "noxfile.py", - "@nox.session(python=DEFAULT_PYTHON_VERSION)\n" "def cover(session):", - compliance, - escape="()", -) - -s.replace(["noxfile.py"], '"alabaster"', '"alabaster", "geoalchemy2", "shapely"') - - -system_noextras = ''' -@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system_noextras(session): - """Run the system test suite.""" - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. - if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": - session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Install pyopenssl for mTLS testing. - if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": - session.install("pyopenssl") - - system_test_exists = os.path.exists(system_test_path) - system_test_folder_exists = os.path.exists(system_test_folder_path) - # Sanity check: only run tests if found. - if not system_test_exists and not system_test_folder_exists: - session.skip("System tests were not found") - - global SYSTEM_TEST_EXTRAS_BY_PYTHON - SYSTEM_TEST_EXTRAS_BY_PYTHON = False - install_systemtest_dependencies(session, "-c", constraints_path) - - # Run py.test against the system tests. - if system_test_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if system_test_folder_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) - - -''' - - -place_before( - "noxfile.py", - "@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])\n" "def compliance(session):", - system_noextras, - escape="()[]", -) - # Add DB config for SQLAlchemy dialect test suite. # https://github.com/googleapis/python-bigquery-sqlalchemy/issues/89 @@ -288,15 +75,6 @@ def system_noextras(session): """, ) - -# Make sure build includes all necessary files. -s.replace( - ["MANIFEST.in"], - re.escape("recursive-include google"), - """recursive-include third_party/sqlalchemy_bigquery_vendored * -recursive-include sqlalchemy_bigquery""", -) - # ---------------------------------------------------------------------------- # Samples templates # ----------------------------------------------------------------------------