diff --git a/src/popper/runner_host.py b/src/popper/runner_host.py index 6dc98f1d5..e7ac4d78e 100644 --- a/src/popper/runner_host.py +++ b/src/popper/runner_host.py @@ -212,9 +212,17 @@ def _create_container(self, cid, step): if build: log.info(f"[{step.id}] docker build {img}:{tag} {build_ctx_path}") if not self._config.dry_run: - self._d.images.build( - path=build_ctx_path, tag=f"{img}:{tag}", rm=True, pull=True + streamer = self._d.api.build( + decode=True, path=build_ctx_path, tag=f"{img}:{tag}", rm=True, ) + for chunk in streamer: + if self._config.quiet: + continue + if "stream" in chunk: + lines = [line for line in chunk["stream"].splitlines() if line] + for line in lines: + log.step_info(line.strip()) + elif not self._config.skip_pull and not step.skip_pull: log.info(f"[{step.id}] docker pull {img}:{tag}") if not self._config.dry_run: diff --git a/src/test/test_runner_host.py b/src/test/test_runner_host.py index 3f2fe78b3..ebed1363f 100644 --- a/src/test/test_runner_host.py +++ b/src/test/test_runner_host.py @@ -272,10 +272,13 @@ def test_get_build_info(self): def test_docker_basic_run(self): repo = self.mk_repo() conf = ConfigLoader.load(workspace_dir=repo.working_dir) + test_string = "STEP_INFO:popper:Successfully tagged popperized/bin:master" with WorkflowRunner(conf) as r: wf_data = {"steps": [{"uses": "popperized/bin/sh@master", "args": ["ls"],}]} - r.run(WorkflowParser.parse(wf_data=wf_data)) + with self.assertLogs(log, level="STEP_INFO") as cm: + r.run(WorkflowParser.parse(wf_data=wf_data)) + self.assertTrue(test_string in cm.output, f"Got cmd output: {cm.output}") wf_data = { "steps": [ @@ -300,6 +303,13 @@ def test_docker_basic_run(self): } self.assertRaises(SystemExit, r.run, WorkflowParser.parse(wf_data=wf_data)) + conf = ConfigLoader.load(workspace_dir=repo.working_dir, quiet=True) + with WorkflowRunner(conf) as r: + wf_data = {"steps": [{"uses": "popperized/bin/sh@master", "args": ["ls"],}]} + with self.assertLogs(log, level="STEP_INFO") as cm: + r.run(WorkflowParser.parse(wf_data=wf_data)) + self.assertTrue(test_string not in cm.output) + repo.close() shutil.rmtree(repo.working_dir, ignore_errors=True)