summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-07-13 16:43:46 +0000
committerJürg Billeter <j@bitron.ch>2017-08-08 08:32:21 +0200
commite0f1f7b1145ac8af736cc50d5696e13fe84a0a83 (patch)
treecb82acf8511a3f483ae3e6740c72cd1a22b5ab0d
parentbba906f89aab831e2e8031265a0f172c5cbe068d (diff)
downloadbuildstream-e0f1f7b1145ac8af736cc50d5696e13fe84a0a83.tar.gz
Add initial `bst push` command
This is mainly useful for testing artifact caches and such. Most users will hopefully be able to make use of artifact caches populated by automated build machines, but right now it's unlikely that most people will be pushing artifacts around.
-rw-r--r--buildstream/_frontend/main.py31
-rw-r--r--buildstream/_pipeline.py38
2 files changed, 69 insertions, 0 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index 79adf11d7..43cdc431f 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -209,6 +209,37 @@ def track(app, target, variant, deps, except_):
##################################################################
+# Push Command #
+##################################################################
+@cli.command(short_help="Push a built artifact")
+@click.option('--variant',
+ help='A variant of the specified target')
+@click.option('--deps', '-d', default='none',
+ type=click.Choice(['none', 'all']),
+ help='The dependencies to fetch (default: none)')
+@click.argument('target')
+@click.pass_obj
+def push(app, target, variant, deps):
+ """Push a built artifact to the configured remote artifact cache.
+
+ Specify `--deps` to control which artifacts to push:
+
+ \b
+ none: No dependencies, just the element itself
+ all: All dependencies
+ """
+ app.initialize(target, variant)
+ try:
+ to_push = app.pipeline.deps_elements(deps)
+ app.pipeline.push(app.scheduler, to_push)
+ click.echo("")
+ except _BstError as e:
+ click.echo("")
+ click.echo("ERROR: {}".format(e))
+ sys.exit(-1)
+
+
+##################################################################
# Show Command #
##################################################################
@cli.command(short_help="Show elements in the pipeline")
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 64ce4d679..8092340fc 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -631,6 +631,44 @@ class Pipeline():
self.open_workspace(scheduler, workspace_dir, source_index, no_checkout,
track, False)
+ # push()
+ #
+ # Pushes elements in the pipeline
+ #
+ # Args:
+ # scheduler (Scheduler): The scheduler to run this pipeline on
+ # elements (list): List of elements to push
+ #
+ def push(self, scheduler, elements):
+
+ if not self.artifacts.can_push():
+ self.message(self.target, MessageType.FAIL, "Not configured for pushing artifacts")
+
+ plan = elements
+ self.assert_consistent(plan)
+ self.session_elements = len(plan)
+
+ push = PushQueue()
+ push.enqueue(plan)
+ queues = [push]
+
+ self.message(self.target, MessageType.START, "Pushing {} artifacts".format(len(plan)))
+ elapsed, status = scheduler.run(queues)
+ pushed = len(push.processed_elements)
+
+ if status == SchedStatus.ERROR:
+ self.message(self.target, MessageType.FAIL, "Push failed", elapsed=elapsed)
+ raise PipelineError()
+ elif status == SchedStatus.TERMINATED:
+ self.message(self.target, MessageType.WARN,
+ "Terminated after pushing {} elements".format(pushed),
+ elapsed=elapsed)
+ raise PipelineError()
+ else:
+ self.message(self.target, MessageType.SUCCESS,
+ "Pushed {} complete".format(pushed),
+ elapsed=elapsed)
+
# remove_elements():
#
# Internal function