Skip to content

Commit

Permalink
test: add session with prerelease dependencies (#428)
Browse files Browse the repository at this point in the history
* test: add session with prerelease dependencies

* fix owlbot

* add kokoro configs

* match whitespace

* remove extra whitespace

* escape in replacement

* 🦉 Updates from OwlBot

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

* move nox session to avoid duplicates

* escape more parens

* escape asterix

* missing comma

* don't remove indent

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
tswast and gcf-owl-bot[bot] authored Nov 30, 2021
1 parent 2180836 commit 928e47b
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .kokoro/continuous/prerelease.cfg
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"
}
7 changes: 7 additions & 0 deletions .kokoro/presubmit/prerelease.cfg
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"
}
84 changes: 84 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import absolute_import
import os
import pathlib
import re
import shutil

import nox
Expand Down Expand Up @@ -167,6 +168,89 @@ def system(session):
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def prerelease(session):
session.install(
"--extra-index-url",
"https://pypi.fury.io/arrow-nightlies/",
"--prefer-binary",
"--pre",
"--upgrade",
"pyarrow",
)
session.install(
"--extra-index-url",
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
"--prefer-binary",
"--pre",
"--upgrade",
"pandas",
)
session.install(
"--prefer-binary",
"--pre",
"--upgrade",
"google-api-core",
"google-cloud-bigquery",
"google-cloud-bigquery-storage",
"google-cloud-core",
"google-resumable-media",
"grpcio",
)
session.install(
"freezegun",
"google-cloud-datacatalog",
"google-cloud-storage",
"google-cloud-testutils",
"IPython",
"mock",
"psutil",
"pytest",
"pytest-cov",
)

# 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
)
]

# 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", "-m", "pip", "freeze")

# Run all tests, except a few samples tests which require extra dependencies.
session.run(
"py.test",
"--quiet",
f"--junitxml=prerelease_unit_{session.python}_sponge_log.xml",
os.path.join("tests", "unit"),
)
session.run(
"py.test",
"--quiet",
f"--junitxml=prerelease_system_{session.python}_sponge_log.xml",
os.path.join("tests", "system"),
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):
"""Run the final coverage report.
Expand Down
99 changes: 99 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""This script is used to synthesize generated parts of this library."""

import pathlib
import re

import synthtool as s
from synthtool import gcp
Expand Down Expand Up @@ -55,14 +56,112 @@
# Fixup files
# ----------------------------------------------------------------------------

s.replace(
["noxfile.py"],
r"import pathlib\s+import shutil",
"import pathlib\nimport re\nimport shutil",
)

s.replace(
["noxfile.py"], r"[\"']google[\"']", '"pandas_gbq"',
)


s.replace(
["noxfile.py"], "--cov=google", "--cov=pandas_gbq",
)

s.replace(
["noxfile.py"],
r"@nox.session\(python=DEFAULT_PYTHON_VERSION\)\s+def cover\(session\):",
r"""@nox.session(python=DEFAULT_PYTHON_VERSION)
def prerelease(session):
session.install(
"--extra-index-url",
"https://pypi.fury.io/arrow-nightlies/",
"--prefer-binary",
"--pre",
"--upgrade",
"pyarrow",
)
session.install(
"--extra-index-url",
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
"--prefer-binary",
"--pre",
"--upgrade",
"pandas",
)
session.install(
"--prefer-binary",
"--pre",
"--upgrade",
"google-api-core",
"google-cloud-bigquery",
"google-cloud-bigquery-storage",
"google-cloud-core",
"google-resumable-media",
"grpcio",
)
session.install(
"freezegun",
"google-cloud-datacatalog",
"google-cloud-storage",
"google-cloud-testutils",
"IPython",
"mock",
"psutil",
"pytest",
"pytest-cov",
)
# 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
)
]
# 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", "-m", "pip", "freeze")
# Run all tests, except a few samples tests which require extra dependencies.
session.run(
"py.test",
"--quiet",
f"--junitxml=prerelease_unit_{session.python}_sponge_log.xml",
os.path.join("tests", "unit"),
)
session.run(
"py.test",
"--quiet",
f"--junitxml=prerelease_system_{session.python}_sponge_log.xml",
os.path.join("tests", "system"),
)
@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):""",
re.MULTILINE,
)

s.replace(
[".github/header-checker-lint.yml"], '"Google LLC"', '"pandas-gbq Authors"',
)
Expand Down

0 comments on commit 928e47b

Please sign in to comment.