Skip to content

Commit 2694420

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

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

build_docs.py

Lines changed: 11 additions & 5 deletions
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
@@ -693,7 +693,7 @@ def full_build(self):
693693
"""
694694
return not self.quick and not self.language.html_only
695695

696-
def run(self):
696+
def run(self) -> bool:
697697
"""Build and publish a Python doc, for a language, and a version."""
698698
try:
699699
self.clone_cpython()
@@ -710,6 +710,8 @@ def run(self):
710710
)
711711
if sentry_sdk:
712712
sentry_sdk.capture_exception(err)
713+
return False
714+
return True
713715

714716
@property
715717
def checkout(self) -> Path:
@@ -1044,7 +1046,7 @@ def purge_path(www_root: Path, path: Path):
10441046
run(["curl", "-XPURGE", f"https://docs.python.org/{{{','.join(to_purge)}}}"])
10451047

10461048

1047-
def main() -> None:
1049+
def main() -> bool:
10481050
"""Script entry point."""
10491051
args = parse_args()
10501052
setup_logging(args.log_directory)
@@ -1054,6 +1056,7 @@ def main() -> None:
10541056
del args.languages
10551057
del args.branch
10561058
todo = list(product(versions, languages))
1059+
all_built_successfully = True
10571060
while todo:
10581061
version, language = todo.pop()
10591062
if sentry_sdk:
@@ -1063,7 +1066,7 @@ def main() -> None:
10631066
try:
10641067
lock = zc.lockfile.LockFile(HERE / "build_docs.lock")
10651068
builder = DocBuilder(version, language, **vars(args))
1066-
builder.run()
1069+
all_built_successfully &= builder.run()
10671070
except zc.lockfile.LockError:
10681071
logging.info("Another builder is running... waiting...")
10691072
time.sleep(10)
@@ -1078,6 +1081,9 @@ def main() -> None:
10781081
dev_symlink(args.www_root, args.group)
10791082
proofread_canonicals(args.www_root, args.skip_cache_invalidation)
10801083

1084+
return all_built_successfully
1085+
10811086

10821087
if __name__ == "__main__":
1083-
main()
1088+
all_built_successfully = main()
1089+
sys.exit(EX_OK if all_built_successfully else EX_SOFTWARE)

0 commit comments

Comments
 (0)