Skip to content

Commit e6133cc

Browse files
authored
Merge pull request #1538 from PolicyEngine/codex/modal-cleanup-noninteractive
Confirm Modal app cleanup in CI
2 parents d294c51 + bdeb3b4 commit e6133cc

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

.github/scripts/modal-cleanup-apps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for app_name in payload.get("app_names", []):
1616
if [[ -z "${app_name}" ]]; then
1717
continue
1818
fi
19-
if ! output="$(uv run modal app stop --env "${environment}" "${app_name}" 2>&1)"; then
19+
if ! output="$(uv run modal app stop --yes --env "${environment}" "${app_name}" 2>&1)"; then
2020
echo "${output}"
2121
if [[ "${output}" == *"already stopped"* ]]; then
2222
continue

.github/scripts/test_modal_cleanup_apps.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@
44
import subprocess
55

66

7+
def test_modal_cleanup_confirms_app_stop_in_noninteractive_ci(tmp_path):
8+
cleanup_file = tmp_path / "cleanup.json"
9+
cleanup_file.write_text('{"app_names":["old-app"]}\n')
10+
args_file = tmp_path / "uv-args.txt"
11+
_write_fake_uv(
12+
tmp_path,
13+
exit_code=0,
14+
output="Stopped.",
15+
args_file=args_file,
16+
)
17+
18+
result = subprocess.run(
19+
[
20+
"bash",
21+
".github/scripts/modal-cleanup-apps.sh",
22+
str(cleanup_file),
23+
],
24+
capture_output=True,
25+
env={
26+
**os.environ,
27+
"PATH": f"{tmp_path}:{os.environ['PATH']}",
28+
"MODAL_ENVIRONMENT": "testing",
29+
},
30+
text=True,
31+
)
32+
33+
assert result.returncode == 0
34+
assert args_file.read_text().splitlines() == [
35+
"run",
36+
"modal",
37+
"app",
38+
"stop",
39+
"--yes",
40+
"--env",
41+
"testing",
42+
"old-app",
43+
]
44+
45+
746
def test_modal_cleanup_treats_already_stopped_app_as_success(tmp_path):
847
cleanup_file = tmp_path / "cleanup.json"
948
cleanup_file.write_text('{"app_names":["old-app"]}\n')
@@ -52,10 +91,23 @@ def test_modal_cleanup_fails_on_other_stop_errors(tmp_path):
5291
assert "Permission denied" in result.stdout
5392

5493

55-
def _write_fake_uv(tmp_path, *, exit_code: int, output: str) -> None:
94+
def _write_fake_uv(
95+
tmp_path,
96+
*,
97+
exit_code: int,
98+
output: str,
99+
args_file=None,
100+
) -> None:
56101
uv = tmp_path / "uv"
102+
args_capture = (
103+
f"""printf '%s\\n' "$@" > "{args_file}"
104+
"""
105+
if args_file is not None
106+
else ""
107+
)
57108
uv.write_text(
58109
f"""#!/usr/bin/env bash
110+
{args_capture}\
59111
echo "{output}" >&2
60112
exit {exit_code}
61113
"""

changelog.d/1537.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make Modal retired-app cleanup non-interactive in CI.

0 commit comments

Comments
 (0)