Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show docker build output (#785) #882

Merged
merged 7 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/popper/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__popper_version__ = "0.0.0"
__popper_version__ = "0.0.0"
10 changes: 9 additions & 1 deletion src/popper/runner_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(

_, build_logs = self._d.images.build(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this blocks, so the output only shows until images.build() returns. If the output of the build is too big, this might cause memory issues. In order to avoid this, this code can use the low-level API as exemplified here. Very similar to what what's already here, but with a couple of tweaks.

path=build_ctx_path, tag=f"{img}:{tag}", rm=True, pull=True
)

if not self._config.quiet:
for chunk in build_logs:
if "stream" in chunk:
for line in chunk["stream"].splitlines(True):
log.info(line)

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:
Expand Down
14 changes: 13 additions & 1 deletion src/test/test_runner_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,14 @@ 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 = "INFO:popper:Successfully tagged popperized/bin:master\n"

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="INFO") as cm:
r.run(WorkflowParser.parse(wf_data=wf_data))
value = test_string in cm.output
self.assertTrue(value)

wf_data = {
"steps": [
Expand All @@ -300,6 +304,14 @@ 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="INFO") as cm:
r.run(WorkflowParser.parse(wf_data=wf_data))
value = test_string in cm.output
self.assertFalse(value)

repo.close()
shutil.rmtree(repo.working_dir, ignore_errors=True)

Expand Down