about summary refs log tree commit diff
path: root/maintainers/scripts/update.py
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2022-09-10 21:55:25 -0400
committerWinter <winter@winter.cafe>2022-09-20 17:59:07 -0400
commit814026db2ded64af1526843a774478c3ece3d748 (patch)
treeda81bfe21b9ba695302ad950b464b2b811617669 /maintainers/scripts/update.py
parent647068fb464f9cc22a30cf5cba75a623e28a91d2 (diff)
maintainers/scripts/update.nix: exit with nonzero exit code when script fails
Diffstat (limited to 'maintainers/scripts/update.py')
-rw-r--r--maintainers/scripts/update.py12
1 files changed, 10 insertions, 2 deletions
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: