Skip to content

Commit

Permalink
chore: add prerelease nox session (#281)
Browse files Browse the repository at this point in the history
* chore(python): add missing import for prerelease testing

Source-Link: googleapis/synthtool@d2871d9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b2dc5f80edcf5d4486c39068c9fa11f7f851d9568eea4dcba130f994ea9b5e97

* check samples failure

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* lint

* check samples failure

* add 30 seconds to request timestamp

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Jun 21, 2022
1 parent 810b899 commit 2b2c2b6
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-retail/.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:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32
# created: 2022-05-05T22:08:23.383410683Z
digest: sha256:b2dc5f80edcf5d4486c39068c9fa11f7f851d9568eea4dcba130f994ea9b5e97
# created: 2022-06-12T16:09:31.61859086Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "prerelease_deps"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "prerelease_deps"
}
65 changes: 65 additions & 0 deletions packages/google-cloud-retail/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import os
import pathlib
import re
import shutil
import warnings

Expand Down Expand Up @@ -325,3 +326,67 @@ def docfx(session):
os.path.join("docs", ""),
os.path.join("docs", "_build", "html", ""),
)


@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
def prerelease_deps(session):
"""Run all tests with prerelease versions of dependencies installed."""

prerel_deps = [
"protobuf",
"googleapis-common-protos",
"google-auth",
"grpcio",
"grpcio-status",
"google-api-core",
"proto-plus",
# dependencies of google-auth
"cryptography",
"pyasn1",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--upgrade", dep)

# Remaining dependencies
other_deps = ["requests"]
session.install(*other_deps)

session.install(*UNIT_TEST_STANDARD_DEPENDENCIES)
session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES)

# Because we test minimum dependency versions on the minimum Python
# version, the first version we test with in the unit tests sessions has a
# constraints file containing all dependencies and extras.
with open(
CURRENT_DIRECTORY
/ "testing"
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
encoding="utf-8",
) as constraints_file:
constraints_text = constraints_file.read()

# Ignore leading whitespace and comment lines.
deps = [
match.group(1)
for match in re.finditer(
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
)
]

# Don't overwrite prerelease packages.
deps = [dep for dep in deps if dep not in prerel_deps]
# We use --no-deps to ensure that pre-release versions aren't overwritten
# by the version ranges in setup.py.
session.install(*deps)
session.install("--no-deps", "-e", ".[all]")

# Print out prerelease package versions
session.run(
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
)
session.run("python", "-c", "import grpc; print(grpc.__version__)")

session.run("py.test", "tests/unit")
session.run("py.test", "tests/system")
session.run("py.test", "samples/snippets")
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
+ product_id
)

# The request timestamp
current_date = datetime.datetime.now()


# add fulfillment request
def get_add_fulfillment_request(
Expand Down Expand Up @@ -70,6 +67,9 @@ def add_fulfillment_places(product_name: str, timestamp, place_id):


create_product(product_id)

# The request timestamp
current_date = datetime.datetime.now() + datetime.timedelta(seconds=30)
print(f"------add fulfilment places with current date: {current_date}-----")
add_fulfillment_places(product_name, current_date, "store2")
get_product(product_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_product_with_inventory_info(product_name: str) -> Product:
# set inventory request
def get_set_inventory_request(product_name: str) -> SetInventoryRequest:
# The request timestamp
request_time = datetime.datetime.now()
request_time = datetime.datetime.now() + datetime.timedelta(seconds=30)
set_mask = FieldMask(
paths=["price_info", "availability", "fulfillment_info", "available_quantity"]
)
Expand Down

0 comments on commit 2b2c2b6

Please sign in to comment.