Skip to content

Commit 50bf76c

Browse files
samgoodmanSam Goodmangcf-owl-bot[bot]
authored
ci: Don't include unit tests in calculation of test coverage (#1436)
* chore: release 1.13.1 Release-As: 1.13.1 * fix: Don't include tests in calculating test coverage * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Owl-bot approved way of removing tests inclusion in calculation * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Moved to right location * Blackened * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Changed coverage level * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Sam Goodman <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 5a5cd30 commit 50bf76c

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

noxfile.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def default(session):
172172
"--quiet",
173173
f"--junitxml=unit_{session.python}_sponge_log.xml",
174174
"--cov=google",
175-
"--cov=tests/unit",
176175
"--cov-append",
177176
"--cov-config=.coveragerc",
178177
"--cov-report=",
@@ -268,7 +267,7 @@ def cover(session):
268267
test runs (not system test runs), and then erases coverage data.
269268
"""
270269
session.install("coverage", "pytest-cov")
271-
session.run("coverage", "report", "--show-missing", "--fail-under=99")
270+
session.run("coverage", "report", "--show-missing", "--fail-under=98")
272271

273272
session.run("coverage", "erase")
274273

owlbot.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
# ----------------------------------------------------------------------------
8686

8787
templated_files = common.py_library(
88-
cov_level=99,
88+
cov_level=98,
8989
system_test_python_versions=["3.8"],
9090
unit_test_python_versions=["3.6", "3.7", "3.8", "3.9"],
9191
unit_test_extras=["testing"],
@@ -123,4 +123,7 @@
123123
# Don't treat docs warnings as errors
124124
s.replace("noxfile.py", """["']-W["'], # warnings as errors""", "")
125125

126+
# Don't include tests in calculation of test coverage
127+
s.replace("noxfile.py", """ \"--cov=tests/unit\",""", "")
128+
126129
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

samples/model-builder/noxfile.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ def lint(session: nox.sessions.Session) -> None:
171171
def blacken(session: nox.sessions.Session) -> None:
172172
"""Run black. Format code to uniform standard."""
173173
session.install(BLACK_VERSION)
174-
python_files = [
175-
path
176-
for path in os.listdir(".")
177-
if path.endswith(".py") or path.endswith("experiment_tracking")
178-
]
174+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
179175

180176
session.run("black", *python_files)
181177

@@ -184,7 +180,6 @@ def blacken(session: nox.sessions.Session) -> None:
184180
# format = isort + black
185181
#
186182

187-
188183
@nox.session
189184
def format(session: nox.sessions.Session) -> None:
190185
"""
@@ -234,7 +229,9 @@ def _session_tests(
234229

235230
if os.path.exists("requirements-test.txt"):
236231
if os.path.exists("constraints-test.txt"):
237-
session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
232+
session.install(
233+
"-r", "requirements-test.txt", "-c", "constraints-test.txt"
234+
)
238235
else:
239236
session.install("-r", "requirements-test.txt")
240237
with open("requirements-test.txt") as rtfile:
@@ -247,9 +244,9 @@ def _session_tests(
247244
post_install(session)
248245

249246
if "pytest-parallel" in packages:
250-
concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"])
247+
concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto'])
251248
elif "pytest-xdist" in packages:
252-
concurrent_args.extend(["-n", "auto"])
249+
concurrent_args.extend(['-n', 'auto'])
253250

254251
session.run(
255252
"pytest",
@@ -279,7 +276,7 @@ def py(session: nox.sessions.Session) -> None:
279276

280277

281278
def _get_repo_root() -> Optional[str]:
282-
"""Returns the root folder of the project."""
279+
""" Returns the root folder of the project. """
283280
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
284281
p = Path(os.getcwd())
285282
for i in range(10):

0 commit comments

Comments
 (0)