-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add Breaking Check Without Tox #43988
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de394f9
migrate
JennyPng 96c1722
format
JennyPng 2e0b6c3
Merge branch 'main' into jennypng-breaking
JennyPng b6028d8
clean
JennyPng e8925b2
minor
JennyPng 8b306e8
edit readme for breaking
JennyPng 6e1e823
Merge branch 'main' into jennypng-breaking
JennyPng d004563
Merge branch 'main' into jennypng-breaking
JennyPng 2ff2171
address comments
JennyPng 3f5a743
FORMAT
JennyPng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import argparse | ||
| import os | ||
| import sys | ||
|
|
||
| from typing import Optional, List | ||
| from subprocess import CalledProcessError, check_call | ||
|
|
||
| from .Check import Check | ||
| from ci_tools.functions import install_into_venv | ||
| from ci_tools.scenario.generation import create_package_and_install | ||
| from ci_tools.variables import discover_repo_root, set_envvar_defaults | ||
| from ci_tools.logging import logger | ||
|
|
||
| JSONDIFF_VERSION = "1.2.0" | ||
| REPO_ROOT = discover_repo_root() | ||
| BREAKING_CHECKER_PATH = os.path.join(REPO_ROOT, "scripts", "breaking_changes_checker") | ||
|
|
||
|
|
||
| class breaking(Check): | ||
| def __init__(self) -> None: | ||
| super().__init__() | ||
|
|
||
| def register( | ||
| self, subparsers: "argparse._SubParsersAction", parent_parsers: Optional[List[argparse.ArgumentParser]] = None | ||
| ) -> None: | ||
| """Register the breaking change check. The breaking change check checks for breaking changes against the target package.""" | ||
| parents = parent_parsers or [] | ||
| p = subparsers.add_parser("breaking", parents=parents, help="Run the breaking change check") | ||
| p.set_defaults(func=self.run) | ||
|
|
||
| def run(self, args: argparse.Namespace) -> int: | ||
| """Run the breaking change check command.""" | ||
| logger.info("Running breaking check...") | ||
|
|
||
| set_envvar_defaults() | ||
| targeted = self.get_targeted_directories(args) | ||
|
|
||
| results: List[int] = [] | ||
|
|
||
| for parsed in targeted: | ||
| package_dir = parsed.folder | ||
| package_name = parsed.name | ||
| executable, staging_directory = self.get_executable(args.isolate, args.command, sys.executable, package_dir) | ||
| logger.info(f"Processing {package_name} for breaking check...") | ||
|
|
||
| # install dependencies | ||
| self.install_dev_reqs(executable, args, package_dir) | ||
|
|
||
| try: | ||
| install_into_venv( | ||
| executable, | ||
| [f"jsondiff=={JSONDIFF_VERSION}", "-e", BREAKING_CHECKER_PATH], | ||
| package_dir, | ||
| ) | ||
| except CalledProcessError as e: | ||
| logger.error( | ||
| f"Failed to install jsondiff or breaking change checker while processing {package_name}: {e}" | ||
| ) | ||
| results.append(1) | ||
| continue | ||
|
|
||
| create_package_and_install( | ||
| distribution_directory=staging_directory, | ||
| target_setup=package_dir, | ||
| skip_install=False, | ||
| cache_dir=None, | ||
| work_dir=staging_directory, | ||
| force_create=False, | ||
| package_type="sdist", | ||
| pre_download_disabled=False, | ||
| python_executable=executable, | ||
| ) | ||
|
|
||
| try: | ||
| cmd = [ | ||
| executable, | ||
| os.path.join(BREAKING_CHECKER_PATH, "detect_breaking_changes.py"), | ||
| "--target", | ||
| package_dir, | ||
| ] | ||
| check_call(cmd) | ||
| except CalledProcessError as e: | ||
| logger.error(f"Breaking check failed for {package_name}: {e}") | ||
| results.append(1) | ||
| continue | ||
|
|
||
| return max(results) if results else 0 | ||
scbedd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.