Skip to content

Commit b4e8876

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

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

build_docs.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848

4949
HERE = Path(__file__).resolve().parent
5050

51+
try:
52+
from os import EX_OK, EX_SOFTWARE as EX_FAILURE
53+
except ImportError:
54+
EX_OK, EX_FAILURE = 0, 1
55+
5156
try:
5257
import sentry_sdk
5358
except ImportError:
@@ -693,7 +698,7 @@ def full_build(self):
693698
"""
694699
return not self.quick and not self.language.html_only
695700

696-
def run(self):
701+
def run(self) -> bool:
697702
"""Build and publish a Python doc, for a language, and a version."""
698703
try:
699704
self.clone_cpython()
@@ -710,6 +715,8 @@ def run(self):
710715
)
711716
if sentry_sdk:
712717
sentry_sdk.capture_exception(err)
718+
return False
719+
return True
713720

714721
@property
715722
def checkout(self) -> Path:
@@ -1044,7 +1051,7 @@ def purge_path(www_root: Path, path: Path):
10441051
run(["curl", "-XPURGE", f"https://docs.python.org/{{{','.join(to_purge)}}}"])
10451052

10461053

1047-
def main() -> None:
1054+
def main() -> bool:
10481055
"""Script entry point."""
10491056
args = parse_args()
10501057
setup_logging(args.log_directory)
@@ -1054,6 +1061,7 @@ def main() -> None:
10541061
del args.languages
10551062
del args.branch
10561063
todo = list(product(versions, languages))
1064+
all_built_successfully = True
10571065
while todo:
10581066
version, language = todo.pop()
10591067
if sentry_sdk:
@@ -1063,7 +1071,7 @@ def main() -> None:
10631071
try:
10641072
lock = zc.lockfile.LockFile(HERE / "build_docs.lock")
10651073
builder = DocBuilder(version, language, **vars(args))
1066-
builder.run()
1074+
all_built_successfully &= builder.run()
10671075
except zc.lockfile.LockError:
10681076
logging.info("Another builder is running... waiting...")
10691077
time.sleep(10)
@@ -1078,6 +1086,9 @@ def main() -> None:
10781086
dev_symlink(args.www_root, args.group)
10791087
proofread_canonicals(args.www_root, args.skip_cache_invalidation)
10801088

1089+
return all_built_successfully
1090+
10811091

10821092
if __name__ == "__main__":
1083-
main()
1093+
all_built_successfully = main()
1094+
sys.exit(EX_OK if all_built_successfully else EX_FAILURE)

0 commit comments

Comments
 (0)