Skip to content

Commit 9dac56c

Browse files
close vnext issues if library passing (#33494)
* add close_vnext_issue function * add close_vnext_issue function to ci checks that create issues * add strict sphinx * log GH issue number we're closing
1 parent 5689065 commit 9dac56c

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

eng/tox/run_mypy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from ci_tools.parsing import ParsedSetup
2020
from ci_tools.variables import in_ci
2121

22-
2322
logging.getLogger().setLevel(logging.INFO)
2423

2524
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
@@ -101,9 +100,11 @@
101100
sample_code_error = sample_err
102101

103102
if args.next and in_ci() and not is_typing_ignored(package_name):
104-
from gh_tools.vnext_issue_creator import create_vnext_issue
103+
from gh_tools.vnext_issue_creator import create_vnext_issue, close_vnext_issue
105104
if src_code_error or sample_code_error:
106105
create_vnext_issue(package_name, "mypy")
106+
else:
107+
close_vnext_issue(package_name, "mypy")
107108

108109
if src_code_error and sample_code_error:
109110
raise Exception(

eng/tox/run_pylint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
create_vnext_issue(pkg_details.name, "pylint")
7878

7979
exit(1)
80+
81+
if args.next and in_ci():
82+
from gh_tools.vnext_issue_creator import close_vnext_issue
83+
close_vnext_issue(pkg_details.name, "pylint")

eng/tox/run_pyright.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ def get_pyright_config_path(args):
120120

121121
print("See https://aka.ms/python/typing-guide for information.\n\n")
122122
raise error
123+
124+
if args.next and in_ci() and not is_typing_ignored(package_name):
125+
from gh_tools.vnext_issue_creator import close_vnext_issue
126+
close_vnext_issue(package_name, "pyright")

eng/tox/run_sphinx_build.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,9 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=Non
134134

135135
if in_ci() or args.in_ci:
136136
move_output_and_compress(output_dir, package_dir, pkg_details.name)
137+
138+
if args.strict:
139+
from gh_tools.vnext_issue_creator import close_vnext_issue
140+
close_vnext_issue(pkg_details.name, "sphinx")
137141
else:
138-
logging.info("Skipping sphinx build for {}".format(pkg_details.name))
142+
logging.info("Skipping sphinx build for {}".format(pkg_details.name))

tools/azure-sdk-tools/gh_tools/vnext_issue_creator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,18 @@ def create_vnext_issue(package_name: str, check_type: CHECK_TYPE) -> None:
158158
title=title,
159159
body=template,
160160
)
161+
162+
163+
def close_vnext_issue(package_name: str, check_type: CHECK_TYPE) -> None:
164+
"""This is called when a client library passes a vnext check. If an issue exists for the library, it is closed."""
165+
166+
auth = Auth.Token(os.environ["GH_TOKEN"])
167+
g = Github(auth=auth)
168+
169+
repo = g.get_repo("Azure/azure-sdk-for-python")
170+
171+
issues = repo.get_issues(state="open", labels=[check_type], creator="azure-sdk")
172+
vnext_issue = [issue for issue in issues if issue.title.split("needs")[0].strip() == package_name]
173+
if vnext_issue:
174+
logging.info(f"{package_name} passes {check_type}. Closing existing GH issue #{vnext_issue[0].number}...")
175+
vnext_issue[0].edit(state="closed")

0 commit comments

Comments
 (0)