-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore(migration): Migrate code from googleapis/python-test-utils into packages/google-cloud-testutils #15545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(migration): Migrate code from googleapis/python-test-utils into packages/google-cloud-testutils #15545
Conversation
chore: copy test_utils, scripts to master
Release-As: 0.1.0
To avoid generating bogus PRs Co-authored-by: Jeffrey Rennie <rennie@google.com> Source-Author: Carlos de la Guardia <cguardia@yahoo.com> Source-Date: Tue May 19 11:57:19 2020 -0500 Source-Repo: googleapis/synthtool Source-Sha: d2364eb80b840a36136c8ce12f1c6efabcc9600e Source-Link: googleapis/synthtool@d2364eb
Add a lower bound checker to be invoked on the command line by client libraries. This accomplishes two things: - Makes it easier to mass update/create constraints files. - Adds another layer of checks to the lower bounds in setup.py / constraints files. See googleapis/synthtool#869 for additional context on the lower bounds work. `lower-bound-checker` is intentionally restrictive on the types of pins it permits in `setup.py` and `constraints.txt`. The tool doesn't try to `pip install` the package. It is assumed that other checks (e.g., setup.py lint, unit tests) will pick up on things like misspelled package names or a version range that cannot be fulfilled. ``` busunkim@busunkim:~/github/python-test-utils$ lower-bound-checker check --help Usage: lower-bound-checker check [OPTIONS] Check that the constraints-file pins to the lower bound specified in package-name's setup.py for each requirement. Requirements: 1. The setup.py pins every requirement in one of the following formats: * foo==1.2.0 * foo>=1.2.0 * foo>=1.2.0, <2.0.0dev * foo<2.0.0dev, >=1.2.0 2. The constraints file pins every requirement to a single version: * foo==1.2.0 3. package-name is already be installed in the environment. Options: --package-name TEXT Name of the package. [required] --constraints-file TEXT Path to constraints file. [required] --help Show this message and exit. ``` **Example Usage:** (for reviewers) - Install this repo from source: `pip install /path/to/repo` - Install another package from source: `pip install /path/to/google-cloud-foo` 1. Check an existing package and constraints file: ``` lower-bound-checker check --package-name google-cloud-foo --constraints-file testing/constraints-3.6.txt ``` 2. Create/update a constraints file: ``` lower-bound-checker update --package-name google-cloud-foo --constraints-file testing/constraints-3.6.txt ```
🤖 I have created a release \*beep\* \*boop\* --- ## [0.2.0](https://www.github.com/googleapis/python-test-utils/compare/v0.1.0...v0.2.0) (2021-02-22) ### Features * add lower bound checker ([#8](https://www.github.com/googleapis/python-test-utils/issues/8)) ([5ebac9f](https://www.github.com/googleapis/python-test-utils/commit/5ebac9fb0ad005f8ea947c14dfca6de3c0d2cac9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/4552bf17-d7f1-4b9d-9cc2-7db8ceff4876/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) Source-Link: googleapis/synthtool@5b5bf6d Source-Link: googleapis/synthtool@f5c5904 Source-Link: googleapis/synthtool@79c8dd7 Source-Link: googleapis/synthtool@2c54c47 Source-Link: googleapis/synthtool@d176743 Source-Link: googleapis/synthtool@3336657 Source-Link: googleapis/synthtool@d1bb917 Source-Link: googleapis/synthtool@573f765 Source-Link: googleapis/synthtool@ba960d7 Source-Link: googleapis/synthtool@fb53b6f Source-Link: googleapis/synthtool@41a4e56 Source-Link: googleapis/synthtool@3738610 Source-Link: googleapis/synthtool@aa255b1 Source-Link: googleapis/synthtool@69629b6 Source-Link: googleapis/synthtool@32af6da Source-Link: googleapis/synthtool@5f6ef0e Source-Link: googleapis/synthtool@477764c Source-Link: googleapis/synthtool@9b0da52 Source-Link: googleapis/synthtool@dba48bb Source-Link: googleapis/synthtool@257fda1 Source-Link: googleapis/synthtool@d302f93 Source-Link: googleapis/synthtool@d91dd8a Source-Link: googleapis/synthtool@bfcdbe0 Source-Link: googleapis/synthtool@5dfda56 Source-Link: googleapis/synthtool@e99975b Source-Link: googleapis/synthtool@ffe1040
Co-authored-by: google-cloud-policy-bot[bot] <80869356+google-cloud-policy-bot[bot]@users.noreply.github.com>
gcr.io/repo-automation-bots/owlbot-python:latest@sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa
#34) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pre-commit/pre-commit-hooks](https://togithub.com/pre-commit/pre-commit-hooks) | repository | major | `v3.4.0` -> `v4.0.1` | --- ### Release Notes <details> <summary>pre-commit/pre-commit-hooks</summary> ### [`v4.0.1`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.1) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v4.0.0...v4.0.1) ##### Fixes - `check-shebang-scripts-are-executable` fix entry point. - [#​602](https://togithub.com/pre-commit/pre-commit-hooks/issues/602) issue by [@​Person-93](https://togithub.com/Person-93). - [#​603](https://togithub.com/pre-commit/pre-commit-hooks/issues/603) PR by [@​scop](https://togithub.com/scop). ### [`v4.0.0`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.0) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.0) ##### Features - `check-json`: report duplicate keys. - [#​558](https://togithub.com/pre-commit/pre-commit-hooks/issues/558) PR by [@​AdityaKhursale](https://togithub.com/AdityaKhursale). - [#​554](https://togithub.com/pre-commit/pre-commit-hooks/issues/554) issue by [@​adamchainz](https://togithub.com/adamchainz). - `no-commit-to-branch`: add `main` to default blocked branches. - [#​565](https://togithub.com/pre-commit/pre-commit-hooks/issues/565) PR by [@​ndevenish](https://togithub.com/ndevenish). - `check-case-conflict`: check conflicts in directory names as well. - [#​575](https://togithub.com/pre-commit/pre-commit-hooks/issues/575) PR by [@​slsyy](https://togithub.com/slsyy). - [#​70](https://togithub.com/pre-commit/pre-commit-hooks/issues/70) issue by [@​andyjack](https://togithub.com/andyjack). - `check-vcs-permalinks`: forbid other branch names. - [#​582](https://togithub.com/pre-commit/pre-commit-hooks/issues/582) PR by [@​jack1142](https://togithub.com/jack1142). - [#​581](https://togithub.com/pre-commit/pre-commit-hooks/issues/581) issue by [@​jack1142](https://togithub.com/jack1142). - `check-shebang-scripts-are-executable`: new hook which ensures shebang'd scripts are executable. - [#​545](https://togithub.com/pre-commit/pre-commit-hooks/issues/545) PR by [@​scop](https://togithub.com/scop). ##### Fixes - `check-executables-have-shebangs`: Short circuit shebang lookup on windows. - [#​544](https://togithub.com/pre-commit/pre-commit-hooks/issues/544) PR by [@​scop](https://togithub.com/scop). - `requirements-txt-fixer`: Fix comments which have indentation - [#​549](https://togithub.com/pre-commit/pre-commit-hooks/issues/549) PR by [@​greshilov](https://togithub.com/greshilov). - [#​548](https://togithub.com/pre-commit/pre-commit-hooks/issues/548) issue by [@​greshilov](https://togithub.com/greshilov). - `pretty-format-json`: write to stdout using UTF-8 encoding. - [#​571](https://togithub.com/pre-commit/pre-commit-hooks/issues/571) PR by [@​jack1142](https://togithub.com/jack1142). - [#​570](https://togithub.com/pre-commit/pre-commit-hooks/issues/570) issue by [@​jack1142](https://togithub.com/jack1142). - Use more inclusive language. - [#​599](https://togithub.com/pre-commit/pre-commit-hooks/issues/599) PR by [@​asottile](https://togithub.com/asottile). ##### Breaking changes - Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`. - [#​597](https://togithub.com/pre-commit/pre-commit-hooks/issues/597) PR by [@​asottile](https://togithub.com/asottile). </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **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-Link: googleapis/synthtool@333fd90 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3
fixes #907 Source-Link: googleapis/synthtool@b0eb8a8 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
'six.wraps' preserves metdata better under Python 2.7, which makes stuff like pytest fixture injection work with plain functions. Closes #36.
🤖 I have created a release \*beep\* \*boop\* --- ### [0.2.1](https://www.github.com/googleapis/python-test-utils/compare/v0.2.0...v0.2.1) (2021-06-29) ### Bug Fixes * use 'six.wraps' vs. 'functools.wraps' ([#37](https://www.github.com/googleapis/python-test-utils/issues/37)) ([701c3a4](https://www.github.com/googleapis/python-test-utils/commit/701c3a41fcf0a63c2b8b689493fa2ae21304511b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@53ea389 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:e1793a23ae0ee9aafb2e3a53b564a351f74790dbe3c2d75f8fc3b8c43e5c036c
Source-Link: googleapis/synthtool@e44dc0c Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:5ff7446edeaede81c3ed58b23a4e76a5403fba1350ce28478045657303b6479d
Source-Link: googleapis/synthtool@dd05f9d Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:aea14a583128771ae8aefa364e1652f3c56070168ef31beb203534222d842b8b
Summary of ChangesHello @parthea, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request undertakes a significant chore: the migration of the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR migrates the python-test-utils library into a new package, involving extensive changes across source code and configuration files. A high-severity vulnerability was identified in readme_gen.py due to unsafe YAML deserialization using yaml.load(), which can lead to arbitrary code execution; yaml.safe_load() is recommended. Additionally, there are opportunities to update hardcoded paths and URLs from the old repository, address potentially broken CI configurations, and modernize some code, including Python 2 compatibility fixes and improved version parsing. All original comments have been retained as they do not contradict any provided rules.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/google-cloud-testutils/.github/workflows/unittest.yml (32)
The version v6 for actions/upload-artifact appears to be invalid. The latest stable version is v4. Using an invalid version will cause the workflow to fail.
uses: actions/upload-artifact@v4packages/google-cloud-testutils/.github/workflows/unittest.yml (54)
The version v7 for actions/download-artifact appears to be invalid. The latest stable version is v4. Using an invalid version will cause the workflow to fail.
uses: actions/download-artifact@v4packages/google-cloud-testutils/scripts/readme-gen/readme_gen.py (57)
The use of yaml.load() is a high-severity vulnerability as it can lead to arbitrary code execution if the YAML file is compromised. It is deprecated in modern PyYAML versions without a Loader argument. Please use yaml.safe_load() instead to securely parse YAML files and prevent potential code execution.
config = yaml.safe_load(f)
packages/google-cloud-testutils/.kokoro/continuous/common.cfg (17-26)
The paths for build_file and TRAMPOLINE_BUILD_FILE seem to be hardcoded with the old repository name python-test-utils. After migrating to a monorepo, these paths are likely incorrect and will cause CI failures. Please update these paths to reflect the new directory structure. This issue is present in multiple Kokoro configuration files throughout the .kokoro directory.
packages/google-cloud-testutils/.github/PULL_REQUEST_TEMPLATE.md (2)
This link to create a new issue points to the old repository. It should be updated to point to the new issue tracker for this package within the monorepo.
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-cloud-python/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
packages/google-cloud-testutils/.repo-metadata.json (5-10)
The client_documentation, issue_tracker, and repo fields appear to be pointing to the old standalone repository. Since this package is being migrated into a monorepo, these should be updated to reflect the new location. For example, repo should likely be the name of the monorepo (e.g., googleapis/google-cloud-python), and the URLs should be adjusted accordingly.
packages/google-cloud-testutils/setup.py (24-27)
Reading the version number using a regex is a bit fragile. A more robust approach is to execute version.py and read the __version__ variable from a dictionary. This avoids issues if the formatting of version.py changes.
version_info = {}
with open(os.path.join(PACKAGE_ROOT, "test_utils/version.py")) as fp:
exec(fp.read(), version_info)
version = version_info["__version__"]
packages/google-cloud-testutils/test_utils/retry.py (90)
For Python 3, super() can be called without arguments. This makes the code cleaner and less prone to errors if the class name changes.
super().__init__(max_tries, delay, backoff, logger)
packages/google-cloud-testutils/test_utils/retry.py (148)
For Python 3, super() can be called without arguments. This makes the code cleaner and less prone to errors if the class name changes.
super().__init__(max_tries, delay, backoff, logger)
packages/google-cloud-testutils/test_utils/retry.py (203)
For Python 3, super() can be called without arguments. This makes the code cleaner and less prone to errors if the class name changes.
super().__init__(max_tries, delay, backoff, logger)
packages/google-cloud-testutils/tests/unit/test_orchestrate.py (18-21)
The try...except ImportError block for importing mock is a pattern for Python 2 compatibility. Since this package requires Python 3.7+, this is no longer necessary. You can directly import mock from unittest.
from unittest import mock|
Wait for cl/867743948 |
daniel-sanche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
This is ready for review but not merge |
See #10960.
This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.