Skip to content

Commit b8352f9

Browse files
test: require 100% unit test coverage (via synth) (#359)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * feat: add RPC Priority request options PiperOrigin-RevId: 364449524 Source-Author: Google APIs <noreply@google.com> Source-Date: Mon Mar 22 17:39:37 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 6598bb829c9e9a534be674649ffd1b4671a821f9 Source-Link: googleapis/googleapis@6598bb8 * chore(deps): update precommit hook pycqa/flake8 to v3.9.0 [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pycqa/flake8](https://gitlab.com/pycqa/flake8) | repository | minor | `3.8.4` -> `3.9.0` | --- ### Release Notes <details> <summary>pycqa/flake8</summary> ### [`v3.9.0`](https://gitlab.com/pycqa/flake8/compare/3.8.4...3.9.0) [Compare Source](https://gitlab.com/pycqa/flake8/compare/3.8.4...3.9.0) </details> --- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/synthtool). Source-Author: WhiteSource Renovate <bot@renovateapp.com> Source-Date: Tue Mar 23 17:38:03 2021 +0100 Source-Repo: googleapis/synthtool Source-Sha: f5c5904fb0c6aa3b3730eadf4e5a4485afc65726 Source-Link: googleapis/synthtool@f5c5904 * test(python): use constraints files to check dependency lower bounds Use a constraints file when installing dependencies for system and unit tests nox sessions. https://pip.pypa.io/en/stable/user_guide/#constraints-files > Constraints files are requirements files that **only control which version of a requirement is installed, not whether it is installed or not**. Their syntax and contents is nearly identical to Requirements Files. There is one key difference: Including a package in a constraints file does not trigger installation of the package. ``` testing ├── constraints-3.10.txt ├── constraints-3.11.txt ├── constraints-3.6.txt ├── constraints-3.7.txt ├── constraints-3.8.txt └── constraints-3.9.txt ``` Going forward, one constraints file (currently 3.6) will be populated with every library requirement and extra listed in the `setup.py`. The constraints file will pin each requirement to the lower bound. This ensures that library maintainers will see test failures if they forget to update a lower bound on a dependency. See googleapis/python-bigquery#263 for an example Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Tue Mar 23 10:52:02 2021 -0600 Source-Repo: googleapis/synthtool Source-Sha: 86ed43d4f56e6404d068e62e497029018879c771 Source-Link: googleapis/synthtool@86ed43d * build(python): update docfx job to use new plugin Source-Author: Dan Lee <71398022+dandhlee@users.noreply.github.com> Source-Date: Tue Mar 30 19:36:37 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: 4501974ad08b5d693311457e2ea4ce845676e329 Source-Link: googleapis/synthtool@4501974 * chore: Add license headers for python config files Source-Author: Anthonios Partheniou <partheniou@google.com> Source-Date: Tue Apr 6 11:32:03 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: 5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc Source-Link: googleapis/synthtool@5b5bf6d * chore: add constraints file check for python samples This is the sibling PR to GoogleCloudPlatform/python-docs-samples#5611 and this is the issue opened for it GoogleCloudPlatform/python-docs-samples#5549 If you look at the files in [this example repo](https://github.com/leahecole/testrepo-githubapp/pull/31/files), you'll see that renovate successfully opened a PR on three constraints files in `samples` directories and subdirectories, and properly ignored `constraints` files at the root level cc @tswast TODO: - [x] update renovate to check for samples/constraints.txt dependency updates - [x] run lint locally to double check that I'm not introducing lint error Source-Author: Leah E. Cole <6719667+leahecole@users.noreply.github.com> Source-Date: Fri Apr 9 22:50:04 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: 0a071b3460344886297a304253bf924aa68ddb7e Source-Link: googleapis/synthtool@0a071b3
1 parent 5dd7e5e commit b8352f9

File tree

7 files changed

+179
-19
lines changed

7 files changed

+179
-19
lines changed

.github/header-checker-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"allowedCopyrightHolders": ["Google LLC"],
22
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
3-
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
3+
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"],
44
"sourceFileExtensions": [
55
"ts",
66
"js",

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
115
# See https://pre-commit.com for more information
216
# See https://pre-commit.com/hooks.html for more hooks
317
repos:

docs/conf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
# -*- coding: utf-8 -*-
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
215
#
316
# google-cloud-pubsub documentation build configuration file
417
#

noxfile.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from __future__ import absolute_import
2020
import os
21+
import pathlib
2122
import shutil
2223

2324
import nox
@@ -30,6 +31,8 @@
3031
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
3132
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
3233

34+
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
35+
3336
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
3437
nox.options.sessions = [
3538
"unit",
@@ -84,13 +87,15 @@ def lint_setup_py(session):
8487

8588
def default(session):
8689
# Install all test dependencies, then install this package in-place.
87-
session.install("asyncmock", "pytest-asyncio")
8890

89-
session.install(
90-
"mock", "pytest", "pytest-cov",
91+
constraints_path = str(
92+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
9193
)
94+
session.install("asyncmock", "pytest-asyncio", "-c", constraints_path)
9295

93-
session.install("-e", ".")
96+
session.install("mock", "pytest", "pytest-cov", "-c", constraints_path)
97+
98+
session.install("-e", ".", "-c", constraints_path)
9499

95100
# Run py.test against the unit tests.
96101
session.run(
@@ -117,6 +122,9 @@ def unit(session):
117122
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
118123
def system(session):
119124
"""Run the system test suite."""
125+
constraints_path = str(
126+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
127+
)
120128
system_test_path = os.path.join("tests", "system.py")
121129
system_test_folder_path = os.path.join("tests", "system")
122130

@@ -141,8 +149,10 @@ def system(session):
141149

142150
# Install all test dependencies, then install this package into the
143151
# virtualenv's dist-packages.
144-
session.install("mock", "pytest", "google-cloud-testutils", "psutil")
145-
session.install("-e", ".")
152+
session.install(
153+
"mock", "pytest", "google-cloud-testutils", "psutil", "-c", constraints_path
154+
)
155+
session.install("-e", ".", "-c", constraints_path)
146156

147157
# Run py.test against the system tests.
148158
if system_test_exists:
@@ -171,7 +181,7 @@ def cover(session):
171181
test runs (not system test runs), and then erases coverage data.
172182
"""
173183
session.install("coverage", "pytest-cov")
174-
session.run("coverage", "report", "--show-missing", "--fail-under=99")
184+
session.run("coverage", "report", "--show-missing", "--fail-under=100")
175185

176186
session.run("coverage", "erase")
177187

@@ -203,9 +213,7 @@ def docfx(session):
203213
"""Build the docfx yaml files for this library."""
204214

205215
session.install("-e", ".")
206-
# sphinx-docfx-yaml supports up to sphinx version 1.5.5.
207-
# https://github.com/docascode/sphinx-docfx-yaml/issues/97
208-
session.install("sphinx==1.5.5", "alabaster", "recommonmark", "sphinx-docfx-yaml")
216+
session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml")
209217

210218
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
211219
session.run(

renovate.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"extends": [
33
"config:base", ":preserveSemverRanges"
44
],
5-
"ignorePaths": [".pre-commit-config.yaml"]
5+
"ignorePaths": [".pre-commit-config.yaml"],
6+
"pip_requirements": {
7+
"fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"]
8+
}
69
}

samples/snippets/noxfile.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,16 @@ def blacken(session: nox.sessions.Session) -> None:
172172
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
173173
"""Runs py.test for a particular project."""
174174
if os.path.exists("requirements.txt"):
175-
session.install("-r", "requirements.txt")
175+
if os.path.exists("constraints.txt"):
176+
session.install("-r", "requirements.txt", "-c", "constraints.txt")
177+
else:
178+
session.install("-r", "requirements.txt")
176179

177180
if os.path.exists("requirements-test.txt"):
178-
session.install("-r", "requirements-test.txt")
181+
if os.path.exists("constraints-test.txt"):
182+
session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
183+
else:
184+
session.install("-r", "requirements-test.txt")
179185

180186
if INSTALL_LIBRARY_FROM_SOURCE:
181187
session.install("-e", _get_repo_root())

synth.metadata

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{
44
"git": {
55
"name": ".",
6-
"remote": "git@github.com:plamut/python-pubsub.git",
7-
"sha": "0a662a6daad0517fb0e01732c9dd7f9d1852924c"
6+
"remote": "https://github.com/googleapis/python-pubsub.git",
7+
"sha": "9f451a1fe0ac5cb2fb13d72b0436e0b521a4fecb"
88
}
99
},
1010
{
@@ -19,21 +19,21 @@
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "c84c8f156e09702e1c8946bfb9746e6f5892cf27"
22+
"sha": "0a071b3460344886297a304253bf924aa68ddb7e"
2323
}
2424
},
2525
{
2626
"git": {
2727
"name": "synthtool",
2828
"remote": "https://github.com/googleapis/synthtool.git",
29-
"sha": "c84c8f156e09702e1c8946bfb9746e6f5892cf27"
29+
"sha": "0a071b3460344886297a304253bf924aa68ddb7e"
3030
}
3131
},
3232
{
3333
"git": {
3434
"name": "synthtool",
3535
"remote": "https://github.com/googleapis/synthtool.git",
36-
"sha": "c84c8f156e09702e1c8946bfb9746e6f5892cf27"
36+
"sha": "0a071b3460344886297a304253bf924aa68ddb7e"
3737
}
3838
}
3939
],
@@ -47,5 +47,121 @@
4747
"generator": "bazel"
4848
}
4949
}
50+
],
51+
"generatedFiles": [
52+
".coveragerc",
53+
".flake8",
54+
".github/CONTRIBUTING.md",
55+
".github/ISSUE_TEMPLATE/bug_report.md",
56+
".github/ISSUE_TEMPLATE/feature_request.md",
57+
".github/ISSUE_TEMPLATE/support_request.md",
58+
".github/PULL_REQUEST_TEMPLATE.md",
59+
".github/header-checker-lint.yml",
60+
".github/release-please.yml",
61+
".github/snippet-bot.yml",
62+
".gitignore",
63+
".kokoro/build.sh",
64+
".kokoro/continuous/common.cfg",
65+
".kokoro/continuous/continuous.cfg",
66+
".kokoro/docker/docs/Dockerfile",
67+
".kokoro/docker/docs/fetch_gpg_keys.sh",
68+
".kokoro/docs/common.cfg",
69+
".kokoro/docs/docs-presubmit.cfg",
70+
".kokoro/docs/docs.cfg",
71+
".kokoro/populate-secrets.sh",
72+
".kokoro/presubmit/common.cfg",
73+
".kokoro/presubmit/presubmit.cfg",
74+
".kokoro/publish-docs.sh",
75+
".kokoro/release.sh",
76+
".kokoro/release/common.cfg",
77+
".kokoro/release/release.cfg",
78+
".kokoro/samples/lint/common.cfg",
79+
".kokoro/samples/lint/continuous.cfg",
80+
".kokoro/samples/lint/periodic.cfg",
81+
".kokoro/samples/lint/presubmit.cfg",
82+
".kokoro/samples/python3.6/common.cfg",
83+
".kokoro/samples/python3.6/continuous.cfg",
84+
".kokoro/samples/python3.6/periodic-head.cfg",
85+
".kokoro/samples/python3.6/periodic.cfg",
86+
".kokoro/samples/python3.6/presubmit.cfg",
87+
".kokoro/samples/python3.7/common.cfg",
88+
".kokoro/samples/python3.7/continuous.cfg",
89+
".kokoro/samples/python3.7/periodic-head.cfg",
90+
".kokoro/samples/python3.7/periodic.cfg",
91+
".kokoro/samples/python3.7/presubmit.cfg",
92+
".kokoro/samples/python3.8/common.cfg",
93+
".kokoro/samples/python3.8/continuous.cfg",
94+
".kokoro/samples/python3.8/periodic-head.cfg",
95+
".kokoro/samples/python3.8/periodic.cfg",
96+
".kokoro/samples/python3.8/presubmit.cfg",
97+
".kokoro/test-samples-against-head.sh",
98+
".kokoro/test-samples-impl.sh",
99+
".kokoro/test-samples.sh",
100+
".kokoro/trampoline.sh",
101+
".kokoro/trampoline_v2.sh",
102+
".pre-commit-config.yaml",
103+
".trampolinerc",
104+
"CODE_OF_CONDUCT.md",
105+
"CONTRIBUTING.rst",
106+
"LICENSE",
107+
"MANIFEST.in",
108+
"docs/_static/custom.css",
109+
"docs/_templates/layout.html",
110+
"docs/conf.py",
111+
"docs/multiprocessing.rst",
112+
"google/cloud/pubsub_v1/proto/pubsub.proto",
113+
"google/cloud/pubsub_v1/proto/schema.proto",
114+
"google/pubsub/__init__.py",
115+
"google/pubsub/py.typed",
116+
"google/pubsub_v1/__init__.py",
117+
"google/pubsub_v1/py.typed",
118+
"google/pubsub_v1/services/__init__.py",
119+
"google/pubsub_v1/services/publisher/__init__.py",
120+
"google/pubsub_v1/services/publisher/async_client.py",
121+
"google/pubsub_v1/services/publisher/client.py",
122+
"google/pubsub_v1/services/publisher/pagers.py",
123+
"google/pubsub_v1/services/publisher/transports/__init__.py",
124+
"google/pubsub_v1/services/publisher/transports/base.py",
125+
"google/pubsub_v1/services/publisher/transports/grpc.py",
126+
"google/pubsub_v1/services/publisher/transports/grpc_asyncio.py",
127+
"google/pubsub_v1/services/schema_service/__init__.py",
128+
"google/pubsub_v1/services/schema_service/async_client.py",
129+
"google/pubsub_v1/services/schema_service/client.py",
130+
"google/pubsub_v1/services/schema_service/pagers.py",
131+
"google/pubsub_v1/services/schema_service/transports/__init__.py",
132+
"google/pubsub_v1/services/schema_service/transports/base.py",
133+
"google/pubsub_v1/services/schema_service/transports/grpc.py",
134+
"google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py",
135+
"google/pubsub_v1/services/subscriber/__init__.py",
136+
"google/pubsub_v1/services/subscriber/async_client.py",
137+
"google/pubsub_v1/services/subscriber/client.py",
138+
"google/pubsub_v1/services/subscriber/pagers.py",
139+
"google/pubsub_v1/services/subscriber/transports/__init__.py",
140+
"google/pubsub_v1/services/subscriber/transports/base.py",
141+
"google/pubsub_v1/services/subscriber/transports/grpc.py",
142+
"google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py",
143+
"google/pubsub_v1/types/__init__.py",
144+
"google/pubsub_v1/types/pubsub.py",
145+
"google/pubsub_v1/types/schema.py",
146+
"mypy.ini",
147+
"noxfile.py",
148+
"renovate.json",
149+
"samples/AUTHORING_GUIDE.md",
150+
"samples/CONTRIBUTING.md",
151+
"samples/snippets/noxfile.py",
152+
"scripts/decrypt-secrets.sh",
153+
"scripts/fixup_pubsub_v1_keywords.py",
154+
"scripts/readme-gen/readme_gen.py",
155+
"scripts/readme-gen/templates/README.tmpl.rst",
156+
"scripts/readme-gen/templates/auth.tmpl.rst",
157+
"scripts/readme-gen/templates/auth_api_key.tmpl.rst",
158+
"scripts/readme-gen/templates/install_deps.tmpl.rst",
159+
"scripts/readme-gen/templates/install_portaudio.tmpl.rst",
160+
"setup.cfg",
161+
"testing/.gitignore",
162+
"tests/unit/gapic/pubsub_v1/__init__.py",
163+
"tests/unit/gapic/pubsub_v1/test_publisher.py",
164+
"tests/unit/gapic/pubsub_v1/test_schema_service.py",
165+
"tests/unit/gapic/pubsub_v1/test_subscriber.py"
50166
]
51167
}

0 commit comments

Comments
 (0)