Skip to content

Commit 8b1bd01

Browse files
authoredMar 19, 2025··
Merge pull request #1168 from underground-software/build_exit
Properly surface errors from build commands
2 parents 52e2912 + 2e7d83f commit 8b1bd01

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed
 

‎podman_compose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,7 @@ async def compose_build(compose, args):
26132613
status = 0
26142614
for t in asyncio.as_completed(tasks):
26152615
s = await t
2616-
if s is not None:
2616+
if s is not None and s != 0:
26172617
status = s
26182618

26192619
return status

‎tests/integration/build_fail_multi/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM busybox
2+
3+
RUN false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "3"
2+
services:
3+
bad:
4+
build:
5+
context: bad
6+
good:
7+
build:
8+
context: good
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM busybox
2+
#ensure that this build finishes second so that it has a chance to overwrite the return code
3+
RUN sleep 0.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import os
4+
import unittest
5+
6+
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
9+
10+
11+
def compose_yaml_path():
12+
""" "Returns the path to the compose file used for this test module"""
13+
base_path = os.path.join(test_path(), "build_fail_multi")
14+
return os.path.join(base_path, "docker-compose.yml")
15+
16+
17+
class TestComposeBuildFailMulti(unittest.TestCase, RunSubprocessMixin):
18+
def test_build_fail_multi(self):
19+
output, error = self.run_subprocess_assert_returncode(
20+
[
21+
podman_compose_path(),
22+
"-f",
23+
compose_yaml_path(),
24+
"build",
25+
# prevent the successful build from being cached to ensure it runs long enough
26+
"--no-cache",
27+
],
28+
expected_returncode=1,
29+
)
30+
self.assertIn("RUN false", str(output))
31+
self.assertIn("while running runtime: exit status 1", str(error))

0 commit comments

Comments
 (0)
Please sign in to comment.