osbuild: assemblers are pipelines now

Convert the assembler phase of the main pipeline in the old format
into a new Pipeline that as the assembler as a stage, where the
input of that stage is the main pipeline. This removes the need of
having "assemblers" as special concepts and thus the corresponding
code in `Pipeline` is removed. The new assembler pipeline is marked
as exported, but the pipeline that builds the tree is not anymore.
Adapt the `describe` and `output` functions of the `v1` format to
handle the assembler pipeline. Also change the tests accordingly.

NB: The id reported for the assembler via `--inspect` and the result
will change as a result of this, since the assembler stage is now
the first and only stage of a new pipeline and thus has no base
anymore.
This commit is contained in:
Christian Kellner 2021-01-21 16:23:53 +00:00
parent 289d943d94
commit 53e9ec850b
4 changed files with 57 additions and 96 deletions

View file

@ -62,7 +62,6 @@ class TestFormatV1(unittest.TestCase):
storedir = pathlib.Path(tmpdir, "store")
monitor = NullMonitor(sys.stderr.fileno())
libdir = os.path.abspath(os.curdir)
print(libdir)
store = ObjectStore(storedir)
outdir = pathlib.Path(tmpdir, "out")
outdir.mkdir()
@ -94,7 +93,7 @@ class TestFormatV1(unittest.TestCase):
# Load a pipeline and check the resulting manifest
def check_stage(have: osbuild.Stage, want: Dict):
self.assertEqual(have.name, want["name"])
self.assertEqual(have.options, want["options"])
self.assertEqual(have.options, want.get("options", {}))
index = osbuild.meta.Index(os.curdir)
@ -108,7 +107,7 @@ class TestFormatV1(unittest.TestCase):
# We have to have two build pipelines and a main pipeline
self.assertTrue(manifest.pipelines)
self.assertTrue(len(manifest.pipelines) == 3)
self.assertTrue(len(manifest.pipelines) == 4)
# access the individual pipelines via their names
@ -131,17 +130,19 @@ class TestFormatV1(unittest.TestCase):
runner = build["runner"]
# main pipeline is the next one
# the main, aka 'tree', pipeline
pl = manifest["tree"]
have = pl.stages[0]
want = description["pipeline"]["stages"][0]
self.assertEqual(pl.runner, runner)
check_stage(have, want)
# the assembler
have = pl.assembler
# the assembler pipeline
pl = manifest["assembler"]
have = pl.stages[0]
want = description["pipeline"]["assembler"]
self.assertEqual(have.name, want["name"])
self.assertEqual(pl.runner, runner)
check_stage(have, want)
def test_describe(self):

View file

@ -38,10 +38,6 @@ class TapeMonitor(osbuild.monitor.BaseMonitor):
self.counter["stages"] += 1
self.stages.add(stage.id)
def assembler(self, assembler: osbuild.Stage):
self.counter["assembler"] += 1
self.asm = assembler.id
def result(self, result: osbuild.pipeline.BuildResult):
self.counter["result"] += 1
self.results.add(result.id)
@ -63,8 +59,6 @@ class TestMonitor(unittest.TestCase):
pipeline.add_stage(info, {
"isthisthereallife": False
})
info = index.get_module_info("Assembler", "org.osbuild.noop")
pipeline.set_assembler(info)
with tempfile.TemporaryDirectory() as tmpdir:
storedir = os.path.join(tmpdir, "store")
@ -84,7 +78,6 @@ class TestMonitor(unittest.TestCase):
assert res
self.assertIn(pipeline.stages[0].id, log)
self.assertIn(pipeline.assembler.id, log)
self.assertIn("isthisthereallife", log)
@unittest.skipUnless(test.TestBase.can_bind_mount(), "root-only")
@ -101,8 +94,6 @@ class TestMonitor(unittest.TestCase):
pipeline.add_stage(noop_info, {
"isthisjustfantasy": True
})
info = index.get_module_info("Assembler", "org.osbuild.noop")
pipeline.set_assembler(info)
with tempfile.TemporaryDirectory() as tmpdir:
storedir = os.path.join(tmpdir, "store")
@ -119,10 +110,8 @@ class TestMonitor(unittest.TestCase):
self.assertEqual(tape.counter["begin"], 1)
self.assertEqual(tape.counter["finish"], 1)
self.assertEqual(tape.counter["stages"], 2)
self.assertEqual(tape.counter["assembler"], 1)
self.assertEqual(tape.counter["stages"], 2)
self.assertEqual(tape.counter["result"], 3)
self.assertEqual(tape.counter["result"], 2)
self.assertIn(pipeline.stages[0].id, tape.stages)
self.assertIn(pipeline.assembler.id, tape.asm)
self.assertIn("isthisthereallife", tape.output)
self.assertIn("isthisjustfantasy", tape.output)