From c17bea2f30ac8d33774340fd0a30b6d9f5f0bdf8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 12 Mar 2021 11:19:37 -0800 Subject: [PATCH] chore: Updating testing, linting, etc (#94) * fix: fixed config for Python and Java grpc lib * chore(python): fix column sizing issue in docs * chore(python): use 'http' in LICENSE * chore(python): skip docfx in main presubmit * chore(python): skip docfx in main presubmit * fix: properly template the repo name * chore: add missing quotation mark * chore: add 3.9 to noxfile template * build(python): make `NOX_SESSION` optional * chore: Add header checker config to python library synth * chore: add noxfile parameters for extra dependencies * build: migrate to flakybot * chore(python): include py.typed files in release * docs: update python contributing guide * build(python): enable flakybot on library unit and system tests * test: install pyopenssl for mtls testing --- .../.github/header-checker-lint.yml | 15 +++++++++++ packages/google-cloud-monitoring/.gitignore | 4 ++- .../google-cloud-monitoring/.kokoro/build.sh | 26 ++++++++++++++----- .../.kokoro/docs/docs-presubmit.cfg | 11 ++++++++ .../google-cloud-monitoring/.trampolinerc | 1 + .../google-cloud-monitoring/CONTRIBUTING.rst | 22 +++++++++++++--- packages/google-cloud-monitoring/LICENSE | 7 ++--- packages/google-cloud-monitoring/MANIFEST.in | 4 +-- .../docs/_static/custom.css | 7 ++++- .../google/cloud/monitoring_v3/__init__.py | 4 +-- .../snippets/v3/alerts-client/noxfile.py | 2 +- .../snippets/v3/cloud-client/noxfile.py | 2 +- .../v3/uptime-check-client/noxfile.py | 2 +- .../google-cloud-monitoring/synth.metadata | 7 ++--- 14 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 packages/google-cloud-monitoring/.github/header-checker-lint.yml diff --git a/packages/google-cloud-monitoring/.github/header-checker-lint.yml b/packages/google-cloud-monitoring/.github/header-checker-lint.yml new file mode 100644 index 000000000000..fc281c05bd55 --- /dev/null +++ b/packages/google-cloud-monitoring/.github/header-checker-lint.yml @@ -0,0 +1,15 @@ +{"allowedCopyrightHolders": ["Google LLC"], + "allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"], + "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"], + "sourceFileExtensions": [ + "ts", + "js", + "java", + "sh", + "Dockerfile", + "yaml", + "py", + "html", + "txt" + ] +} \ No newline at end of file diff --git a/packages/google-cloud-monitoring/.gitignore b/packages/google-cloud-monitoring/.gitignore index b9daa52f118d..b4243ced74e4 100644 --- a/packages/google-cloud-monitoring/.gitignore +++ b/packages/google-cloud-monitoring/.gitignore @@ -50,8 +50,10 @@ docs.metadata # Virtual environment env/ + +# Test logs coverage.xml -sponge_log.xml +*sponge_log.xml # System test environment variables. system_tests/local_test_setup diff --git a/packages/google-cloud-monitoring/.kokoro/build.sh b/packages/google-cloud-monitoring/.kokoro/build.sh index 712144332886..fb0ee04fadd0 100755 --- a/packages/google-cloud-monitoring/.kokoro/build.sh +++ b/packages/google-cloud-monitoring/.kokoro/build.sh @@ -15,7 +15,11 @@ set -eo pipefail -cd github/python-monitoring +if [[ -z "${PROJECT_ROOT:-}" ]]; then + PROJECT_ROOT="github/python-monitoring" +fi + +cd "${PROJECT_ROOT}" # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -30,16 +34,26 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json") # Remove old nox -python3.6 -m pip uninstall --yes --quiet nox-automation +python3 -m pip uninstall --yes --quiet nox-automation # Install nox -python3.6 -m pip install --upgrade --quiet nox -python3.6 -m nox --version +python3 -m pip install --upgrade --quiet nox +python3 -m nox --version + +# If this is a continuous build, send the test log to the FlakyBot. +# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot. +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + cleanup() { + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot + } + trap cleanup EXIT HUP +fi # If NOX_SESSION is set, it only runs the specified session, # otherwise run all the sessions. if [[ -n "${NOX_SESSION:-}" ]]; then - python3.6 -m nox -s "${NOX_SESSION:-}" + python3 -m nox -s ${NOX_SESSION:-} else - python3.6 -m nox + python3 -m nox fi diff --git a/packages/google-cloud-monitoring/.kokoro/docs/docs-presubmit.cfg b/packages/google-cloud-monitoring/.kokoro/docs/docs-presubmit.cfg index 1118107829b7..928adfa9551c 100644 --- a/packages/google-cloud-monitoring/.kokoro/docs/docs-presubmit.cfg +++ b/packages/google-cloud-monitoring/.kokoro/docs/docs-presubmit.cfg @@ -15,3 +15,14 @@ env_vars: { key: "TRAMPOLINE_IMAGE_UPLOAD" value: "false" } + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-monitoring/.kokoro/build.sh" +} + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "docs docfx" +} diff --git a/packages/google-cloud-monitoring/.trampolinerc b/packages/google-cloud-monitoring/.trampolinerc index 995ee29111e1..383b6ec89fbc 100644 --- a/packages/google-cloud-monitoring/.trampolinerc +++ b/packages/google-cloud-monitoring/.trampolinerc @@ -24,6 +24,7 @@ required_envvars+=( pass_down_envvars+=( "STAGING_BUCKET" "V2_STAGING_BUCKET" + "NOX_SESSION" ) # Prevent unintentional override on the default image. diff --git a/packages/google-cloud-monitoring/CONTRIBUTING.rst b/packages/google-cloud-monitoring/CONTRIBUTING.rst index f34dcc8e058a..cd7cf066718f 100644 --- a/packages/google-cloud-monitoring/CONTRIBUTING.rst +++ b/packages/google-cloud-monitoring/CONTRIBUTING.rst @@ -70,9 +70,14 @@ We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: $ nox -s unit-2.7 - $ nox -s unit-3.7 + $ nox -s unit-3.8 $ ... +- Args to pytest can be passed through the nox command separated by a `--`. For + example, to run a single test:: + + $ nox -s unit-3.8 -- -k + .. note:: The unit tests and system tests are described in the @@ -93,8 +98,12 @@ On Debian/Ubuntu:: ************ Coding Style ************ +- We use the automatic code formatter ``black``. You can run it using + the nox session ``blacken``. This will eliminate many lint errors. Run via:: + + $ nox -s blacken -- PEP8 compliance, with exceptions defined in the linter configuration. +- PEP8 compliance is required, with exceptions defined in the linter configuration. If you have ``nox`` installed, you can test that you have not introduced any non-compliant code via:: @@ -133,13 +142,18 @@ Running System Tests - To run system tests, you can execute:: - $ nox -s system-3.7 + # Run all system tests + $ nox -s system-3.8 $ nox -s system-2.7 + # Run a single system test + $ nox -s system-3.8 -- -k + + .. note:: System tests are only configured to run under Python 2.7 and - Python 3.7. For expediency, we do not run them in older versions + Python 3.8. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-monitoring/LICENSE b/packages/google-cloud-monitoring/LICENSE index a8ee855de2aa..d64569567334 100644 --- a/packages/google-cloud-monitoring/LICENSE +++ b/packages/google-cloud-monitoring/LICENSE @@ -1,6 +1,7 @@ - Apache License + + Apache License Version 2.0, January 2004 - https://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -192,7 +193,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/packages/google-cloud-monitoring/MANIFEST.in b/packages/google-cloud-monitoring/MANIFEST.in index e9e29d12033d..e783f4c6209b 100644 --- a/packages/google-cloud-monitoring/MANIFEST.in +++ b/packages/google-cloud-monitoring/MANIFEST.in @@ -16,10 +16,10 @@ # Generated by synthtool. DO NOT EDIT! include README.rst LICENSE -recursive-include google *.json *.proto +recursive-include google *.json *.proto py.typed recursive-include tests * global-exclude *.py[co] global-exclude __pycache__ # Exclude scripts for samples readmegen -prune scripts/readme-gen \ No newline at end of file +prune scripts/readme-gen diff --git a/packages/google-cloud-monitoring/docs/_static/custom.css b/packages/google-cloud-monitoring/docs/_static/custom.css index 0abaf229fce3..bcd37bbd3c4a 100644 --- a/packages/google-cloud-monitoring/docs/_static/custom.css +++ b/packages/google-cloud-monitoring/docs/_static/custom.css @@ -1,4 +1,9 @@ div#python2-eol { border-color: red; border-width: medium; -} \ No newline at end of file +} + +/* Ensure minimum width for 'Parameters' / 'Returns' column */ +dl.field-list > dt { + min-width: 100px +} diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/__init__.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/__init__.py index d427ebfdbb0c..489ba27a37c2 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/__init__.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/__init__.py @@ -184,10 +184,10 @@ "ListUptimeCheckConfigsResponse", "ListUptimeCheckIpsRequest", "ListUptimeCheckIpsResponse", - "MetricServiceClient", "MutationRecord", "NotificationChannel", "NotificationChannelDescriptor", + "NotificationChannelServiceClient", "Point", "QueryError", "QueryErrorList", @@ -221,5 +221,5 @@ "UptimeCheckServiceClient", "VerifyNotificationChannelRequest", "WindowsBasedSli", - "NotificationChannelServiceClient", + "MetricServiceClient", ) diff --git a/packages/google-cloud-monitoring/samples/snippets/v3/alerts-client/noxfile.py b/packages/google-cloud-monitoring/samples/snippets/v3/alerts-client/noxfile.py index bca0522ec4d9..97bf7da80e39 100644 --- a/packages/google-cloud-monitoring/samples/snippets/v3/alerts-client/noxfile.py +++ b/packages/google-cloud-monitoring/samples/snippets/v3/alerts-client/noxfile.py @@ -85,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to tested samples. -ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8"] +ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG['ignored_versions'] diff --git a/packages/google-cloud-monitoring/samples/snippets/v3/cloud-client/noxfile.py b/packages/google-cloud-monitoring/samples/snippets/v3/cloud-client/noxfile.py index bca0522ec4d9..97bf7da80e39 100644 --- a/packages/google-cloud-monitoring/samples/snippets/v3/cloud-client/noxfile.py +++ b/packages/google-cloud-monitoring/samples/snippets/v3/cloud-client/noxfile.py @@ -85,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to tested samples. -ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8"] +ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG['ignored_versions'] diff --git a/packages/google-cloud-monitoring/samples/snippets/v3/uptime-check-client/noxfile.py b/packages/google-cloud-monitoring/samples/snippets/v3/uptime-check-client/noxfile.py index bca0522ec4d9..97bf7da80e39 100644 --- a/packages/google-cloud-monitoring/samples/snippets/v3/uptime-check-client/noxfile.py +++ b/packages/google-cloud-monitoring/samples/snippets/v3/uptime-check-client/noxfile.py @@ -85,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to tested samples. -ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8"] +ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG['ignored_versions'] diff --git a/packages/google-cloud-monitoring/synth.metadata b/packages/google-cloud-monitoring/synth.metadata index f42df9731ee6..f174a3cb0964 100644 --- a/packages/google-cloud-monitoring/synth.metadata +++ b/packages/google-cloud-monitoring/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-monitoring.git", - "sha": "bec9e87551baf9ef5d60c81810e3efa01e96377f" + "sha": "4cdb1ff439154409c94e347dd5f3b6e2bc40e998" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6133907dbb3ddab204a17a15d5c53ec0aae9b033" + "sha": "0780323da96d5a53925fe0547757181fe76e8f1e" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6133907dbb3ddab204a17a15d5c53ec0aae9b033" + "sha": "0780323da96d5a53925fe0547757181fe76e8f1e" } } ], @@ -48,6 +48,7 @@ ".github/ISSUE_TEMPLATE/feature_request.md", ".github/ISSUE_TEMPLATE/support_request.md", ".github/PULL_REQUEST_TEMPLATE.md", + ".github/header-checker-lint.yml", ".github/release-please.yml", ".github/snippet-bot.yml", ".gitignore",