-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[lint] Updating issue format for pylint only (right now) #40006
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
108 commits
Select commit
Hold shift + click to select a range
187c460
start of updating pr
l0lawrence 2c273bf
try
l0lawrence 4ce69ba
try removing live tests
l0lawrence c2b1f47
update
l0lawrence 0944981
try
l0lawrence 5723c3e
try
l0lawrence fb53a83
try
l0lawrence c1b19da
bump
l0lawrence d12ea80
remove logid
l0lawrence 7c65e94
add here?
l0lawrence fd2e7b8
sdwap
l0lawrence da4554e
requests
l0lawrence d82da39
update
l0lawrence 6b41848
this
l0lawrence 452a045
lose
l0lawrence e706695
try
l0lawrence f74536c
add
l0lawrence 9cbb3dc
add
l0lawrence 2b1fa1e
whoops
l0lawrence 8a8425e
try
l0lawrence 917b96d
bump
l0lawrence 3cbf607
try
l0lawrence 6b61713
this
l0lawrence 44fe1cd
actually you know need to return sometyhing
l0lawrence 56c4f2e
this
l0lawrence d978cac
this
l0lawrence 8134dc1
tryt
l0lawrence f3903df
try
l0lawrence e1fffe0
try
l0lawrence 9635bf5
this
l0lawrence b66522b
this
l0lawrence eb8484f
this
l0lawrence 43e033e
try
l0lawrence da8e917
try
l0lawrence 3d8a5f8
try
l0lawrence f9d7827
try
l0lawrence 761385f
json
l0lawrence 6492a07
try nthis
l0lawrence 44d20d5
try
l0lawrence 8c90a24
tests
l0lawrence a47e641
try this
l0lawrence ea3975d
task
l0lawrence d20ae58
do
l0lawrence e603881
bump
l0lawrence a00456e
this
l0lawrence 810cdfe
eteer
l0lawrence e50c669
this
l0lawrence 5cc0f11
log link
l0lawrence 688d9a1
log_output
l0lawrence f284a17
log_output
l0lawrence 9103150
THIS
l0lawrence fa0928e
add
l0lawrence 8b3438f
this
l0lawrence 04c0eb7
wrong naming
l0lawrence aecb566
content
l0lawrence 569449c
this
l0lawrence a9cc38c
this
l0lawrence 0e27fd0
bump
l0lawrence 9cf7a50
update
l0lawrence 41df3c1
add
l0lawrence 221e563
bump
l0lawrence 2b31e71
fix
l0lawrence fbe986d
remove comment
l0lawrence 34675a1
start addressing comments
l0lawrence e50b76a
comments
l0lawrence e99cedf
this
l0lawrence 2215990
Update eng/tox/run_pylint.py
l0lawrence 0f97707
move try
l0lawrence 9dff014
add
l0lawrence f934ce7
add other reqs
l0lawrence 7e316bc
requests
l0lawrence 3fdf356
update
l0lawrence f02b004
this?
l0lawrence b4ca01a
need to remove- for eg righjt now
l0lawrence e0dfa90
revert
l0lawrence ae86434
this
l0lawrence eec4740
script
l0lawrence 6495391
pin
l0lawrence 57f3fdb
this
l0lawrence de7e73e
this?
l0lawrence a1c66a6
oops
l0lawrence 369a3e8
logging
l0lawrence 084e8e5
this
l0lawrence 287578e
bump
l0lawrence 7873a62
targeted
l0lawrence 15179a7
done?
l0lawrence d2ff814
this
l0lawrence b86dfe8
version
l0lawrence ae04bef
this
l0lawrence fe427f2
bump
l0lawrence 49ab3d0
remove
l0lawrence b5dad17
delete
l0lawrence 94e1a0c
unused import
l0lawrence 07a8079
bump
l0lawrence f0481db
update
l0lawrence 1141192
naming
l0lawrence 2c6564f
add
l0lawrence 74fd3f9
liscene
l0lawrence 2a043af
new approach
l0lawrence efbea2e
rename
l0lawrence a109857
this
l0lawrence 8a45720
this
l0lawrence 540839f
path
l0lawrence 814b8f8
this
l0lawrence f5da0c2
this
l0lawrence 44ae4f7
try
l0lawrence d66791e
unrelated to this p\r
l0lawrence 23c2570
bump
l0lawrence 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
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,153 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import os | ||
| import argparse | ||
| import requests | ||
| import json | ||
| import logging | ||
| from github import Github, Auth | ||
| from ci_tools.functions import discover_targeted_packages | ||
|
|
||
| logging.getLogger().setLevel(logging.INFO) | ||
| root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "..")) | ||
|
|
||
| def get_build_info(service_directory: str, package_name: str) -> str: | ||
| """Get the build info from the build link.""" | ||
| build_id = os.getenv("BUILD_BUILDID") | ||
| timeline_link =f"https://dev.azure.com/azure-sdk/internal/_apis/build/builds/{build_id}/timeline?api-version=6.0" | ||
|
|
||
| token = os.environ["SYSTEM_ACCESSTOKEN"] | ||
| AUTH_HEADERS = {"Authorization": f"Bearer {token}"} | ||
|
|
||
| try: | ||
| # Make the API request | ||
| response = requests.get(timeline_link, headers=AUTH_HEADERS) | ||
| response_json = json.loads(response.text) | ||
|
|
||
| for task in response_json["records"]: | ||
| if "Run Pylint Next" in task["name"]: | ||
| log_link = task['log']['url'] + "?api-version=6.0" | ||
| # Get the log file from the build link | ||
| log_output = requests.get(log_link, headers=AUTH_HEADERS) | ||
| build_output = log_output.content.decode("utf-8") | ||
| new_output = (build_output.split(f"next-pylint: commands[3]> python /mnt/vss/_work/1/s/eng/tox/run_pylint.py -t {service_directory} --next=True")[1]).split(f"ERROR:root:{package_name} exited with linting error")[0] | ||
| return new_output | ||
| except Exception as e: | ||
| logging.error(f"Exception occurred while getting build info: {e}") | ||
| return "Error getting build info" | ||
|
|
||
|
|
||
|
|
||
| def main(targeted_packages): | ||
| for package in targeted_packages: | ||
| # iterate through the packages and find if there is an issue associated with the package | ||
| # there may be multiple packages in the targeted_packages list | ||
| logging.info(f"Processing package: {package}") | ||
|
|
||
| # update open GitHub issues matching the package pattern | ||
| auth = Auth.Token(os.environ["GH_TOKEN"]) | ||
| g = Github(auth=auth) | ||
| repo = g.get_repo("Azure/azure-sdk-for-python") | ||
|
|
||
| package_name = package.split("/")[-1] | ||
| logging.info(f"Searching for issues in repo {repo.name} for package {package_name}") | ||
|
|
||
| for issue in repo.get_issues(state="open", labels=["pylint"], creator="azure-sdk"): | ||
| if f"{package_name} needs linting updates for pylint version" in issue.title: | ||
| logging.info(f"Found issue for package {package_name}: {issue.title}") | ||
| build_info = get_build_info(package, package_name) | ||
|
|
||
| template = ( | ||
| f"\n\n**Pylint Errors:**" | ||
| f"\n\n{build_info}" | ||
| f"\n" | ||
| f"\n\n**How to fix:**" | ||
| f"\n**Note:** If you are a bot. Fix the issue by fixing the above pylint errors." | ||
| ) | ||
| if issue.body: | ||
| first_section = issue.body.split("**How to fix:**")[0] | ||
| new_body = first_section + template + "\n" + issue.body.split("**How to fix:**")[1] | ||
| issue.edit(body=new_body) | ||
| logging.info(f"Updated issue #{issue.number} for package {package_name}") | ||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser( | ||
| description=""" | ||
| This script is the single point for all checks invoked by CI within this repo. It works in two phases. | ||
| 1. Identify which packages in the repo are in scope for this script invocation, based on a glob string and a service directory. | ||
| 2. Invoke one or multiple `tox` environments for each package identified as in scope. | ||
|
|
||
| In the case of an environment invoking `pytest`, results can be collected in a junit xml file, and test markers can be selected via --mark_arg. | ||
| """ | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "glob_string", | ||
| nargs="?", | ||
| help=( | ||
| "A comma separated list of glob strings that will target the top level directories that contain packages." | ||
| 'Examples: All = "azure-*", Single = "azure-keyvault", Targeted Multiple = "azure-keyvault,azure-mgmt-resource"' | ||
| ), | ||
| ) | ||
|
|
||
| parser.add_argument("--disablecov", help=("Flag. Disables code coverage."), action="store_true") | ||
|
|
||
| parser.add_argument( | ||
| "--service", | ||
| help=("Name of service directory (under sdk/) to test. Example: --service applicationinsights"), | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "-w", | ||
| "--wheel_dir", | ||
| dest="wheel_dir", | ||
| help="Location for prebuilt artifacts (if any)", | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "-i", | ||
| "--injected-packages", | ||
| dest="injected_packages", | ||
| default="", | ||
| help="Comma or space-separated list of packages that should be installed prior to dev_requirements. If local path, should be absolute.", | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--filter-type", | ||
| dest="filter_type", | ||
| default="Build", | ||
| help="Filter type to identify eligible packages. for e.g. packages filtered in Build can pass filter type as Build,", | ||
| choices=["Build", "Docs", "Regression", "Omit_management", "None"], | ||
| ) | ||
|
|
||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| # We need to support both CI builds of everything and individual service | ||
| # folders. This logic allows us to do both. | ||
| if args.service and args.service != "auto": | ||
| service_dir = os.path.join("sdk", args.service) | ||
| target_dir = os.path.join(root_dir, service_dir) | ||
| else: | ||
| target_dir = root_dir | ||
|
|
||
| logging.info(f"Beginning discovery for {args.service} and root dir {root_dir}. Resolving to {target_dir}.") | ||
|
|
||
| if args.filter_type == "None": | ||
| args.filter_type = "Build" | ||
| compatibility_filter = False | ||
| else: | ||
| compatibility_filter = True | ||
|
|
||
| targeted_packages = discover_targeted_packages( | ||
| args.glob_string, target_dir, "", args.filter_type, compatibility_filter | ||
| ) | ||
|
|
||
| if len(targeted_packages) == 0: | ||
| logging.info(f"No packages collected for targeting string {args.glob_string} and root dir {root_dir}. Exit 0.") | ||
| exit(0) | ||
|
|
||
| main(targeted_packages) |
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.