Skip to content

Commit 9d34f81

Browse files
committed
tests: rewrite logic for skipping VPCSC runs
1 parent 645822f commit 9d34f81

3 files changed

Lines changed: 100 additions & 203 deletions

File tree

monitoring/noxfile.py

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Generated by synthtool. DO NOT EDIT!
18+
1719
from __future__ import absolute_import
1820
import os
1921
import shutil
@@ -22,6 +24,12 @@
2224

2325

2426
LOCAL_DEPS = (os.path.join("..", "api_core"), os.path.join("..", "core"))
27+
BLACK_VERSION = "black==19.3b0"
28+
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
29+
30+
if os.path.exists("samples"):
31+
BLACK_PATHS.append("samples")
32+
2533

2634
@nox.session(python="3.7")
2735
def lint(session):
@@ -30,14 +38,8 @@ def lint(session):
3038
Returns a failure if the linters find linting errors or sufficiently
3139
serious code quality issues.
3240
"""
33-
session.install("flake8", "black", *LOCAL_DEPS)
34-
session.run(
35-
"black",
36-
"--check",
37-
"google",
38-
"tests",
39-
"docs",
40-
)
41+
session.install("flake8", BLACK_VERSION, *LOCAL_DEPS)
42+
session.run("black", "--check", *BLACK_PATHS)
4143
session.run("flake8", "google", "tests")
4244

4345

@@ -46,18 +48,13 @@ def blacken(session):
4648
"""Run black.
4749
4850
Format code to uniform standard.
49-
51+
5052
This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
5153
That run uses an image that doesn't have 3.6 installed. Before updating this
5254
check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
5355
"""
54-
session.install("black")
55-
session.run(
56-
"black",
57-
"google",
58-
"tests",
59-
"docs",
60-
)
56+
session.install(BLACK_VERSION)
57+
session.run("black", *BLACK_PATHS)
6158

6259

6360
@nox.session(python="3.7")
@@ -83,7 +80,7 @@ def default(session):
8380
"--cov-append",
8481
"--cov-config=.coveragerc",
8582
"--cov-report=",
86-
"--cov-fail-under=97",
83+
"--cov-fail-under=0",
8784
os.path.join("tests", "unit"),
8885
*session.posargs,
8986
)
@@ -121,20 +118,11 @@ def system(session):
121118
session.install("-e", "../test_utils/")
122119
session.install("-e", ".")
123120

124-
# Additional setup for VPCSC system tests
125-
if os.environ.get("GOOGLE_CLOUD_TESTS_IN_VPCSC") != "true":
126-
# Unset PROJECT_ID, since VPCSC system tests expect this to be a project
127-
# within the VPCSC perimeter.
128-
env = {
129-
"PROJECT_ID": "",
130-
"GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT": os.environ.get("PROJECT_ID"),
131-
}
132-
133121
# Run py.test against the system tests.
134122
if system_test_exists:
135-
session.run("py.test", "--quiet", system_test_path, env=env, *session.posargs)
123+
session.run("py.test", "--quiet", system_test_path, *session.posargs)
136124
if system_test_folder_exists:
137-
session.run("py.test", "--quiet", system_test_folder_path, env=env, *session.posargs)
125+
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
138126

139127

140128
@nox.session(python="3.7")
@@ -149,21 +137,24 @@ def cover(session):
149137

150138
session.run("coverage", "erase")
151139

140+
152141
@nox.session(python="3.7")
153142
def docs(session):
154143
"""Build the docs for this library."""
155144

156-
session.install('-e', '.')
157-
session.install('sphinx', 'alabaster', 'recommonmark')
145+
session.install("-e", ".")
146+
session.install("sphinx", "alabaster", "recommonmark")
158147

159-
shutil.rmtree(os.path.join('docs', '_build'), ignore_errors=True)
148+
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
160149
session.run(
161-
'sphinx-build',
162-
'-W', # warnings as errors
163-
'-T', # show full traceback on exception
164-
'-N', # no colors
165-
'-b', 'html',
166-
'-d', os.path.join('docs', '_build', 'doctrees', ''),
167-
os.path.join('docs', ''),
168-
os.path.join('docs', '_build', 'html', ''),
150+
"sphinx-build",
151+
"-W", # warnings as errors
152+
"-T", # show full traceback on exception
153+
"-N", # no colors
154+
"-b",
155+
"html",
156+
"-d",
157+
os.path.join("docs", "_build", "doctrees", ""),
158+
os.path.join("docs", ""),
159+
os.path.join("docs", "_build", "html", ""),
169160
)

monitoring/synth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@
9494
# Add templated files
9595
# ----------------------------------------------------------------------------
9696
templated_files = common.py_library(unit_cov_level=97, cov_level=97)
97-
s.move(templated_files, excludes=["noxfile.py"])
97+
s.move(templated_files)
9898

9999
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 commit comments

Comments
 (0)