Skip to content

Commit cc5e153

Browse files
authored
Ensure exit status is returned by build_docs.py (#286)
1 parent 982c0f8 commit cc5e153

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

build_docs.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -911,20 +911,21 @@ def _checkout_name(select_output: str | None) -> str:
911911
return "cpython"
912912

913913

914-
def main() -> None:
914+
def main() -> int:
915915
"""Script entry point."""
916916
args = parse_args()
917917
setup_logging(args.log_directory, args.select_output)
918918
load_environment_variables()
919919

920920
if args.select_output is None:
921-
build_docs_with_lock(args, "build_docs.lock")
922-
elif args.select_output == "no-html":
923-
build_docs_with_lock(args, "build_docs_archives.lock")
924-
elif args.select_output == "only-html":
925-
build_docs_with_lock(args, "build_docs_html.lock")
926-
elif args.select_output == "only-html-en":
927-
build_docs_with_lock(args, "build_docs_html_en.lock")
921+
return build_docs_with_lock(args, "build_docs.lock")
922+
if args.select_output == "no-html":
923+
return build_docs_with_lock(args, "build_docs_archives.lock")
924+
if args.select_output == "only-html":
925+
return build_docs_with_lock(args, "build_docs_html.lock")
926+
if args.select_output == "only-html-en":
927+
return build_docs_with_lock(args, "build_docs_html_en.lock")
928+
return EX_FAILURE
928929

929930

930931
def parse_args() -> argparse.Namespace:
@@ -1073,12 +1074,12 @@ def build_docs_with_lock(args: argparse.Namespace, lockfile_name: str) -> int:
10731074
return EX_FAILURE
10741075

10751076
try:
1076-
return EX_OK if build_docs(args) else EX_FAILURE
1077+
return build_docs(args)
10771078
finally:
10781079
lock.close()
10791080

10801081

1081-
def build_docs(args: argparse.Namespace) -> bool:
1082+
def build_docs(args: argparse.Namespace) -> int:
10821083
"""Build all docs (each language and each version)."""
10831084
logging.info("Full build start.")
10841085
start_time = perf_counter()
@@ -1159,7 +1160,7 @@ def build_docs(args: argparse.Namespace) -> bool:
11591160

11601161
logging.info("Full build done (%s).", format_seconds(perf_counter() - start_time))
11611162

1162-
return any_build_failed
1163+
return EX_FAILURE if any_build_failed else EX_OK
11631164

11641165

11651166
def parse_versions_from_devguide(http: urllib3.PoolManager) -> Versions:
@@ -1397,4 +1398,4 @@ def purge_surrogate_key(http: urllib3.PoolManager, surrogate_key: str) -> None:
13971398

13981399

13991400
if __name__ == "__main__":
1400-
sys.exit(main())
1401+
raise SystemExit(main())

0 commit comments

Comments
 (0)