From 814026db2ded64af1526843a774478c3ece3d748 Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 10 Sep 2022 21:55:25 -0400 Subject: maintainers/scripts/update.nix: exit with nonzero exit code when script fails --- maintainers/scripts/update.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'maintainers/scripts/update.py') diff --git a/maintainers/scripts/update.py b/maintainers/scripts/update.py index 07e0b5c68305c..f1bed6527e797 100644 --- a/maintainers/scripts/update.py +++ b/maintainers/scripts/update.py @@ -13,6 +13,9 @@ import tempfile class CalledProcessError(Exception): process: asyncio.subprocess.Process +class UpdateFailedException(Exception): + pass + def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) @@ -69,7 +72,7 @@ async def run_update_script(nixpkgs_root: str, merge_lock: asyncio.Lock, temp_di eprint(f"--- SHOWING ERROR LOG FOR {package['name']} ----------------------") if not keep_going: - raise asyncio.exceptions.CancelledError() + raise UpdateFailedException(f"The update script for {package['name']} failed with exit code {e.process.returncode}") @contextlib.contextmanager def make_worktree() -> Generator[Tuple[str, str], None, None]: @@ -185,9 +188,14 @@ async def start_updates(max_workers: int, keep_going: bool, commit: bool, packag try: # Start updater workers. await updaters - except asyncio.exceptions.CancelledError as e: + except asyncio.exceptions.CancelledError: # When one worker is cancelled, cancel the others too. updaters.cancel() + except UpdateFailedException as e: + # When one worker fails, cancel the others, as this exception is only thrown when keep_going is false. + updaters.cancel() + eprint(e) + sys.exit(1) def main(max_workers: int, keep_going: bool, commit: bool, packages_path: str) -> None: with open(packages_path) as f: -- cgit 1.4.1