summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDom Heinzeller <dom.heinzeller@icloud.com>2023-08-23 03:20:33 -0600
committerGitHub <noreply@github.com>2023-08-23 11:20:33 +0200
commit31d5f5691330cbf6502436cd8196ded49ecadd4c (patch)
treea106e2ca5661d761a272672617d92cc95a3f84fb /lib
parentbfdebae831cd53f02934e2d3e29ff7b0a8b4f35d (diff)
downloadspack-31d5f5691330cbf6502436cd8196ded49ecadd4c.tar.gz
spack-31d5f5691330cbf6502436cd8196ded49ecadd4c.tar.bz2
spack-31d5f5691330cbf6502436cd8196ded49ecadd4c.tar.xz
spack-31d5f5691330cbf6502436cd8196ded49ecadd4c.zip
Add --fail-fast option for generating build caches (#38496)
Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/buildcache.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index cd89201f52..17d3f6728c 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -20,6 +20,7 @@ import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.config
import spack.environment as ev
+import spack.error
import spack.mirror
import spack.relocate
import spack.repo
@@ -78,6 +79,11 @@ def setup_parser(subparser: argparse.ArgumentParser):
"Alternatively, one can decide to build a cache for only the package or only the "
"dependencies",
)
+ push.add_argument(
+ "--fail-fast",
+ action="store_true",
+ help="stop pushing on first failure (default is best effort)",
+ )
arguments.add_common_arguments(push, ["specs"])
push.set_defaults(func=push_fn)
@@ -296,6 +302,7 @@ def push_fn(args):
tty.info(f"Selected {len(specs)} specs to push to {url}")
skipped = []
+ failed = []
# tty printing
color = clr.get_color_when()
@@ -326,11 +333,17 @@ def push_fn(args):
except bindist.NoOverwriteException:
skipped.append(format_spec(spec))
+ # Catch any other exception unless the fail fast option is set
+ except Exception as e:
+ if args.fail_fast or isinstance(e, (bindist.PickKeyException, bindist.NoKeyException)):
+ raise
+ failed.append((format_spec(spec), e))
+
if skipped:
if len(specs) == 1:
tty.info("The spec is already in the buildcache. Use --force to overwrite it.")
elif len(skipped) == len(specs):
- tty.info("All specs are already in the buildcache. Use --force to overwite them.")
+ tty.info("All specs are already in the buildcache. Use --force to overwrite them.")
else:
tty.info(
"The following {} specs were skipped as they already exist in the buildcache:\n"
@@ -340,6 +353,17 @@ def push_fn(args):
)
)
+ if failed:
+ if len(failed) == 1:
+ raise failed[0][1]
+
+ raise spack.error.SpackError(
+ f"The following {len(failed)} errors occurred while pushing specs to the buildcache",
+ "\n".join(
+ elide_list([f" {spec}: {e.__class__.__name__}: {e}" for spec, e in failed], 5)
+ ),
+ )
+
def install_fn(args):
"""install from a binary package"""