Skip to content

Commit dd994c8

Browse files
create GH issues for strict sphinx (#33404)
* add strict-sphinx for issue creation * add vnext_issue creator to run_sphinx_build * add GH_TOKEN to generate docs to step * update template * update date to april deadline * don't need args * only open issues if running in analyze-weekly * add in rohit's feedback
1 parent 769ed08 commit dd994c8

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

eng/pipelines/templates/stages/python-analyze-weekly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ stages:
9696
${{ parameters.BuildTargetingString }}
9797
--service="${{ parameters.ServiceDirectory }}"
9898
--toxenv="strict-sphinx"
99+
env:
100+
GH_TOKEN: $(azuresdk-github-pat)

eng/tox/run_sphinx_build.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from ci_tools.parsing import ParsedSetup
2525
from ci_tools.functions import get_config_setting
26+
from gh_tools.vnext_issue_creator import create_vnext_issue
2627

2728
logging.getLogger().setLevel(logging.INFO)
2829

@@ -40,7 +41,7 @@ def move_output_and_compress(target_dir, package_dir, package_name):
4041
individual_zip_location = os.path.join(ci_doc_dir, package_name, package_name)
4142
shutil.make_archive(individual_zip_location, 'gztar', target_dir)
4243

43-
def sphinx_build(target_dir, output_dir, fail_on_warning=False):
44+
def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=None):
4445
command_array = [
4546
"sphinx-build",
4647
"-b",
@@ -67,6 +68,8 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False):
6768
args.working_directory, e.returncode
6869
)
6970
)
71+
if args.strict and in_ci():
72+
create_vnext_issue(package_name, "sphinx")
7073
exit(1)
7174

7275
if __name__ == "__main__":
@@ -122,7 +125,12 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False):
122125
if should_build_docs(pkg_details.name):
123126
fail_on_warning = args.strict or get_config_setting(args.package_root, "strict_sphinx", default=False)
124127

125-
sphinx_build(target_dir, output_dir, fail_on_warning=fail_on_warning)
128+
sphinx_build(
129+
target_dir,
130+
output_dir,
131+
fail_on_warning=fail_on_warning,
132+
package_name=pkg_details.name
133+
)
126134

127135
if in_ci() or args.in_ci:
128136
move_output_and_compress(output_dir, package_dir, pkg_details.name)

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

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
logging.getLogger().setLevel(logging.INFO)
2020

21+
CHECK_TYPE = Literal["mypy", "pylint", "pyright", "sphinx"]
2122

22-
def get_version_running(check_type: Literal["mypy", "pylint", "pyright"]) -> str:
23+
24+
def get_version_running(check_type: CHECK_TYPE) -> str:
2325
commands = [
2426
sys.executable,
2527
"-m",
@@ -37,7 +39,7 @@ def get_version_running(check_type: Literal["mypy", "pylint", "pyright"]) -> str
3739
return version_running
3840

3941

40-
def get_build_link(check_type: Literal["mypy", "pylint", "pyright"]) -> str:
42+
def get_build_link(check_type: CHECK_TYPE) -> str:
4143
build_id = os.getenv('BUILD_BUILDID')
4244
job_id = os.getenv('SYSTEM_JOBID')
4345

@@ -48,6 +50,8 @@ def get_build_link(check_type: Literal["mypy", "pylint", "pyright"]) -> str:
4850
next_id = "c0edaab3-85d6-5e4b-81a8-d1190a6ee92b"
4951
if check_type == "pylint":
5052
next_id = "e1fa7d9e-8471-5a74-cd7d-e1c9a992e07e"
53+
if check_type == "sphinx":
54+
next_id = "0d206e13-b346-5d3f-79e6-d5bfba9e089e"
5155

5256
return f"https://dev.azure.com/azure-sdk/internal/_build/results?buildId={build_id}&view=logs&j={job_id}&t={next_id}"
5357

@@ -85,7 +89,7 @@ def get_date_for_version_bump(today: datetime.datetime) -> str:
8589
return merge_date.strftime('%Y-%m-%d')
8690

8791

88-
def create_vnext_issue(package_name: str, check_type: Literal["mypy", "pylint", "pyright"]) -> None:
92+
def create_vnext_issue(package_name: str, check_type: CHECK_TYPE) -> None:
8993
"""This is called when a client library fails a vnext check.
9094
An issue is created with the details or an existing issue is updated with the latest information."""
9195

@@ -100,24 +104,43 @@ def create_vnext_issue(package_name: str, check_type: Literal["mypy", "pylint",
100104

101105
version = get_version_running(check_type)
102106
build_link = get_build_link(check_type)
103-
merge_date = get_date_for_version_bump(today)
104-
error_type = "linting" if check_type == "pylint" else "typing"
105-
guide_link = "[Pylint Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)" \
106-
if check_type == "pylint" else "[Typing Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking.md#run-mypy)"
107-
108-
title = f"{package_name} needs {error_type} updates for {check_type} version {version}"
109-
template = (
110-
f"**ACTION NEEDED:** This version of {check_type} will be merged on **{merge_date}**. "
111-
f"The build will begin to fail for this library if errors are not fixed."
112-
f"\n\n**Library name:** {package_name}"
113-
f"\n**{check_type.capitalize()} version:** {version}"
114-
f"\n**{check_type.capitalize()} errors:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
115-
f"\n**How to fix:** Run the `next-{check_type}` tox command at the library package-level and resolve "
116-
f"the {error_type} errors.\n"
117-
f"1) `../{package_name}>pip install \"tox<5\"`\n"
118-
f"2) `../{package_name}>tox run -e next-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
119-
f"See the {guide_link} for more information."
120-
)
107+
if check_type == "sphinx":
108+
merge_date = "2024-04-15" # This is a one-time event
109+
error_type = "docstring"
110+
guide_link = "[Sphinx and docstring checker](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/eng_sys_checks.md#sphinx-and-docstring-checker)"
111+
title = f"{package_name} needs {error_type} updates for {check_type}"
112+
template = (
113+
f"**ACTION NEEDED:** All {check_type} errors and warnings must be fixed by **{merge_date}**. "
114+
f"The build will begin to fail for this library if errors are not fixed."
115+
f"\n\nThis issue indicates that your library reference documentation is rendering with errors. To avoid customer issues, please ensure you take care of these errors and warnings ASAP."
116+
f"\n\n**Library name:** {package_name}"
117+
f"\n**{check_type.capitalize()} build:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
118+
f"\n**How to fix:** Run the `strict-{check_type}` tox command at the library package-level and resolve "
119+
f"the {error_type} errors and warnings.\n"
120+
f"1) `../{package_name}>pip install \"tox<5\"`\n"
121+
f"2) `../{package_name}>tox run -e strict-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
122+
f"3) Once resolved, set `strict_sphinx = true` in the package's pyproject.toml file.\n\n"
123+
f"See {guide_link} for more information."
124+
)
125+
else:
126+
merge_date = get_date_for_version_bump(today)
127+
error_type = "linting" if check_type == "pylint" else "typing"
128+
guide_link = "[Pylint Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)" \
129+
if check_type == "pylint" else "[Typing Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking.md#run-mypy)"
130+
131+
title = f"{package_name} needs {error_type} updates for {check_type} version {version}"
132+
template = (
133+
f"**ACTION NEEDED:** This version of {check_type} will be merged on **{merge_date}**. "
134+
f"The build will begin to fail for this library if errors are not fixed."
135+
f"\n\n**Library name:** {package_name}"
136+
f"\n**{check_type.capitalize()} version:** {version}"
137+
f"\n**{check_type.capitalize()} errors:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
138+
f"\n**How to fix:** Run the `next-{check_type}` tox command at the library package-level and resolve "
139+
f"the {error_type} errors.\n"
140+
f"1) `../{package_name}>pip install \"tox<5\"`\n"
141+
f"2) `../{package_name}>tox run -e next-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
142+
f"See the {guide_link} for more information."
143+
)
121144

122145
# create an issue for the library failing the vnext check
123146
if not vnext_issue:

0 commit comments

Comments
 (0)