$ pwd
/Users/rebeccataylor/code/beccasaurus/google-cloud-python
$ git pull becca language-and-speech-samples
From github.com:beccasaurus/google-cloud-python
* branch language-and-speech-samples -> FETCH_HEAD
Already up to date.
$ git log --pretty=oneline --abbrev-commit | head -2
b7960f0e40 Add nox sessions to run the samples test suite.
8288759192 📝 Add samplegen info to CONTRIBUTING.rst
$ git show b7960f0e40
commit b7960f0e403d3baac89f2fc2e7df701f060b6ee6 (HEAD -> language-and-speech-samples)
Author: Rebecca Taylor <rebeccataylor@google.com>
Date: Tue Sep 3 20:13:25 2019 -0700
Add nox sessions to run the samples test suite.
diff --git a/language/noxfile.py b/language/noxfile.py
index a2eefbb676..cdfd0f5f76 100644
--- a/language/noxfile.py
+++ b/language/noxfile.py
@@ -124,6 +124,25 @@ def system(session):
if system_test_folder_exists:
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
+@nox.session(python=["2.7", "3.7"])
+def samples(session):
+ """Run the samples test suite."""
+ # Sanity check: Only run tests if the environment variable is set.
+ if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
+ session.skip("Credentials must be set via environment variable")
+
+ samples_path = "samples"
+ if not os.path.exists(samples_path):
+ session.skip("Samples not found.")
+
+ session.install("pyyaml")
+ session.install("samples-tester")
+ for local_dep in LOCAL_DEPS:
+ session.install("-e", local_dep)
+ session.install("-e", ".")
+
+ session.run("sample-tester", samples_path, *session.posargs)
+
@nox.session(python="3.7")
def cover(session):
diff --git a/speech/noxfile.py b/speech/noxfile.py
index a2eefbb676..f46c580d0b 100644
--- a/speech/noxfile.py
+++ b/speech/noxfile.py
@@ -125,6 +125,26 @@ def system(session):
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
+@nox.session(python=["2.7", "3.7"])
+def samples(session):
+ """Run the sample test suite."""
+ # Sanity check: Only run tests if the environment variable is set.
+ if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
+ session.skip("Credentials must be set via environment variable")
+
+ samples_path = "samples"
+ if not os.path.exists(samples_path):
+ session.skip("Samples not found.")
+
+ session.install("pyyaml")
+ session.install("samples-tester")
+ for local_dep in LOCAL_DEPS:
+ session.install("-e", local_dep)
+ session.install("-e", ".")
+
+ session.run("sample-tester", samples_path, *session.posargs)
+
+
@nox.session(python="3.7")
def cover(session):
"""Run the final coverage report.
$ git status
On branch language-and-speech-samples
nothing to commit, working tree clean
$ python --version
Python 3.7.3
$ pip install --user --upgrade nox
Requirement already up-to-date: nox in /Users/rebeccataylor/.pyenv/versions/3.7.3/lib/python3.7/site-packages (2019.8.20)
Requirement already satisfied, skipping upgrade: virtualenv>=14.0.0 in /Users/rebeccataylor/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from nox) (16.7.5)
Requirement already satisfied, skipping upgrade: colorlog<4.0.0,>=2.6.1 in /Users/rebeccataylor/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from nox) (3.2.0)
Requirement already satisfied, skipping upgrade: argcomplete<2.0,>=1.9.4 in /Users/rebeccataylor/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from nox) (1.10.0)
Requirement already satisfied, skipping upgrade: py<2.0.0,>=1.4.0 in /Users/rebeccataylor/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from nox) (1.8.0)
$ nox --version
2019.8.20
$ nox -s samples
nox > Error while collecting sessions.
nox > Sessions not found: samples
$ python --version
Python 3.6.8
$ pip install --user --upgrade nox
Requirement already up-to-date: nox in /Users/rebeccataylor/.pyenv/versions/3.6.8/lib/python3.6/site-packages (2019.8.20)
Requirement already satisfied, skipping upgrade: py<2.0.0,>=1.4.0 in /Users/rebeccataylor/.pyenv/versions/3.6.8/lib/python3.6/site-packages (from nox) (1.8.0)
Requirement already satisfied, skipping upgrade: virtualenv>=14.0.0 in /Users/rebeccataylor/.pyenv/versions/3.6.8/lib/python3.6/site-packages (from nox) (16.7.5)
Requirement already satisfied, skipping upgrade: argcomplete<2.0,>=1.9.4 in /Users/rebeccataylor/.pyenv/versions/3.6.8/lib/python3.6/site-packages (from nox) (1.10.0)
Requirement already satisfied, skipping upgrade: colorlog<4.0.0,>=2.6.1 in /Users/rebeccataylor/.pyenv/versions/3.6.8/lib/python3.6/site-packages (from nox) (3.2.0)
$ nox --version
2019.8.20
$ nox -s samples
nox > Error while collecting sessions.
nox > Sessions not found: samples