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

Properly surface errors from build commands #1168

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,7 @@ async def compose_build(compose, args):
status = 0
for t in asyncio.as_completed(tasks):
s = await t
if s is not None:
if s is not None and s != 0:
status = s

return status
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions tests/integration/build_fail_multi/bad/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM busybox

RUN false
8 changes: 8 additions & 0 deletions tests/integration/build_fail_multi/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"
services:
bad:
build:
context: bad
good:
build:
context: good
3 changes: 3 additions & 0 deletions tests/integration/build_fail_multi/good/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM busybox
#ensure that this build finishes second so that it has a chance to overwrite the return code
RUN sleep 0.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-2.0

import os
import unittest

from tests.integration.test_utils import RunSubprocessMixin
from tests.integration.test_utils import podman_compose_path
from tests.integration.test_utils import test_path


def compose_yaml_path():
""" "Returns the path to the compose file used for this test module"""
base_path = os.path.join(test_path(), "build_fail_multi")
return os.path.join(base_path, "docker-compose.yml")


class TestComposeBuildFailMulti(unittest.TestCase, RunSubprocessMixin):
def test_build_fail_multi(self):
output, error = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"build",
# prevent the successful build from being cached to ensure it runs long enough
"--no-cache",
],
expected_returncode=1,
)
self.assertIn("RUN false", str(output))
self.assertIn("while running runtime: exit status 1", str(error))