pipeline: simplify return value of Pipeline.run()
The current implementation was broken, because it didn't return results from the cached stages. Simpley return a boolean now, True for success.
This commit is contained in:
parent
fd37a5d646
commit
635b041d84
1 changed files with 18 additions and 39 deletions
|
|
@ -82,11 +82,7 @@ class Stage:
|
||||||
if check and r.returncode != 0:
|
if check and r.returncode != 0:
|
||||||
raise StageFailed(self.name, r.returncode, r.stdout)
|
raise StageFailed(self.name, r.returncode, r.stdout)
|
||||||
|
|
||||||
return {
|
return r.returncode == 0
|
||||||
"name": self.name,
|
|
||||||
"returncode": r.returncode,
|
|
||||||
"output": r.stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Assembler:
|
class Assembler:
|
||||||
|
|
@ -142,11 +138,7 @@ class Assembler:
|
||||||
if check and r.returncode != 0:
|
if check and r.returncode != 0:
|
||||||
raise AssemblerFailed(self.name, r.returncode, r.stdout)
|
raise AssemblerFailed(self.name, r.returncode, r.stdout)
|
||||||
|
|
||||||
return {
|
return r.returncode == 0
|
||||||
"name": self.name,
|
|
||||||
"returncode": r.returncode,
|
|
||||||
"output": r.stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Pipeline:
|
class Pipeline:
|
||||||
|
|
@ -206,15 +198,9 @@ class Pipeline:
|
||||||
def run(self, output_dir, store, interactive=False, check=True, libdir=None):
|
def run(self, output_dir, store, interactive=False, check=True, libdir=None):
|
||||||
os.makedirs("/run/osbuild", exist_ok=True)
|
os.makedirs("/run/osbuild", exist_ok=True)
|
||||||
object_store = objectstore.ObjectStore(store)
|
object_store = objectstore.ObjectStore(store)
|
||||||
results = {
|
|
||||||
"stages": []
|
|
||||||
}
|
|
||||||
if self.build:
|
if self.build:
|
||||||
r = self.build.run(None, store, interactive, check, libdir)
|
if not self.build.run(None, store, interactive, check, libdir):
|
||||||
results["build"] = r
|
return False
|
||||||
if r["returncode"] != 0:
|
|
||||||
results["returncode"] = r["returncode"]
|
|
||||||
return results
|
|
||||||
|
|
||||||
with self.get_buildtree(object_store) as build_tree:
|
with self.get_buildtree(object_store) as build_tree:
|
||||||
if self.stages:
|
if self.stages:
|
||||||
|
|
@ -235,31 +221,24 @@ class Pipeline:
|
||||||
# generated trees remain valid.
|
# generated trees remain valid.
|
||||||
with object_store.new_tree(self.tree_id, base_id=base) as tree:
|
with object_store.new_tree(self.tree_id, base_id=base) as tree:
|
||||||
for stage in self.stages[base_idx + 1:]:
|
for stage in self.stages[base_idx + 1:]:
|
||||||
r = stage.run(tree,
|
if not stage.run(tree,
|
||||||
build_tree,
|
build_tree,
|
||||||
interactive=interactive,
|
interactive=interactive,
|
||||||
check=check,
|
check=check,
|
||||||
libdir=libdir)
|
libdir=libdir):
|
||||||
results["stages"].append(r)
|
return False
|
||||||
if r["returncode"] != 0:
|
|
||||||
results["returncode"] = r["returncode"]
|
|
||||||
return results
|
|
||||||
|
|
||||||
if self.assembler:
|
if self.assembler:
|
||||||
with object_store.get_tree(self.tree_id) as tree:
|
with object_store.get_tree(self.tree_id) as tree:
|
||||||
r = self.assembler.run(tree,
|
if not self.assembler.run(tree,
|
||||||
build_tree,
|
build_tree,
|
||||||
output_dir=output_dir,
|
output_dir=output_dir,
|
||||||
interactive=interactive,
|
interactive=interactive,
|
||||||
check=check,
|
check=check,
|
||||||
libdir=libdir)
|
libdir=libdir):
|
||||||
results["assembler"] = r
|
return False
|
||||||
if r["returncode"] != 0:
|
|
||||||
results["returncode"] = r["returncode"]
|
|
||||||
return results
|
|
||||||
|
|
||||||
results["returncode"] = 0
|
return True
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
def load(description):
|
def load(description):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue