Skip to content

Commit ccc8d99

Browse files
committed
Exit the script process with non-zero status if at least one build was unsuccessful
1 parent d5a0a72 commit ccc8d99

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

build_docs.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import logging
2929
import logging.handlers
3030
from functools import total_ordering
31-
from os import readlink
31+
from os import readlink, EX_OK, EX_SOFTWARE
3232
import re
3333
import shlex
3434
import shutil
@@ -1044,7 +1044,7 @@ def purge_path(www_root: Path, path: Path):
10441044
run(["curl", "-XPURGE", f"https://docs.python.org/{{{','.join(to_purge)}}}"])
10451045

10461046

1047-
def main() -> None:
1047+
def main() -> bool:
10481048
"""Script entry point."""
10491049
args = parse_args()
10501050
setup_logging(args.log_directory)
@@ -1054,6 +1054,7 @@ def main() -> None:
10541054
del args.languages
10551055
del args.branch
10561056
todo = list(product(versions, languages))
1057+
all_built_successfully = True
10571058
while todo:
10581059
version, language = todo.pop()
10591060
if sentry_sdk:
@@ -1063,7 +1064,7 @@ def main() -> None:
10631064
try:
10641065
lock = zc.lockfile.LockFile(HERE / "build_docs.lock")
10651066
builder = DocBuilder(version, language, **vars(args))
1066-
builder.run()
1067+
all_built_successfully &= builder.run()
10671068
except zc.lockfile.LockError:
10681069
logging.info("Another builder is running... waiting...")
10691070
time.sleep(10)
@@ -1078,6 +1079,9 @@ def main() -> None:
10781079
dev_symlink(args.www_root, args.group)
10791080
proofread_canonicals(args.www_root, args.skip_cache_invalidation)
10801081

1082+
return all_built_successfully
1083+
10811084

10821085
if __name__ == "__main__":
1083-
main()
1086+
all_built_successfully = main()
1087+
sys.exit(EX_OK if all_built_successfully else EX_SOFTWARE)

0 commit comments

Comments
 (0)