This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new dbd50f5a217 [v3-1-test] Fix svn push step to add both versions in one 
commit (#59505) (#59520)
dbd50f5a217 is described below

commit dbd50f5a2174eb7f8c040e1b9900ff000efa8725
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Dec 16 19:21:06 2025 +0100

    [v3-1-test] Fix svn push step to add both versions in one commit (#59505) 
(#59520)
    
    This step required manual step due to how svn was added for
    airflow version and task-sdk version before commit.
    Also fixed issue with ls command for task-sdk which fails.
    Added tests for the changes
    (cherry picked from commit 4bfd1215941ae230bc96321b8b2cfad517829a12)
    
    Co-authored-by: Ephraim Anierobi <[email protected]>
---
 .../commands/release_candidate_command.py          |  22 +--
 dev/breeze/tests/test_release_candidate_command.py | 187 +++++++++++++++++++++
 2 files changed, 198 insertions(+), 11 deletions(-)

diff --git 
a/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py 
b/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
index 2587ad04688..5877c05ffb8 100644
--- a/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
+++ b/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
@@ -473,25 +473,25 @@ def move_artifacts_to_svn(
             shell=True,
         )
         console_print("[success]Moved artifacts to SVN:")
-        run_command(["ls"])
-        run_command([f"ls {version}"])
-        run_command([f"ls task-sdk/{task_sdk_version}"])
+        run_command([f"ls {repo_root}/asf-dist/dev/airflow/{version}"])
+        run_command([f"ls 
{repo_root}/asf-dist/dev/airflow/task-sdk/{task_sdk_version}"])
 
 
 def push_artifacts_to_asf_repo(version, task_sdk_version, repo_root):
     if confirm_action("Do you want to push artifacts to ASF repo?"):
+        base_dir = f"{repo_root}/asf-dist/dev/airflow"
+        airflow_dir = f"{base_dir}/{version}"
+        task_sdk_dir = f"{base_dir}/task-sdk/{task_sdk_version}"
+
         console_print("Airflow Version Files to push to svn:")
-        if not get_dry_run():
-            os.chdir(f"{repo_root}/asf-dist/dev/airflow/{version}")
-        run_command(["ls"])
+        run_command(["ls"], cwd=airflow_dir if not get_dry_run() else None)
         confirm_action("Do you want to continue?", abort=True)
-        run_command("svn add *", check=True, shell=True)
         console_print("Task SDK Version Files to push to svn:")
-        if not get_dry_run():
-            
os.chdir(f"{repo_root}/asf-dist/dev/airflow/task-sdk/{task_sdk_version}")
-        run_command(["ls"])
+        run_command(["ls"], cwd=task_sdk_dir if not get_dry_run() else None)
         confirm_action("Do you want to continue?", abort=True)
-        run_command("svn add *", check=True, shell=True)
+        if not get_dry_run():
+            os.chdir(base_dir)
+        run_command(f"svn add {version}/* task-sdk/{task_sdk_version}/*", 
check=True, shell=True)
         run_command(
             ["svn", "commit", "-m", f"Add artifacts for Airflow {version} and 
Task SDK {task_sdk_version}"],
             check=True,
diff --git a/dev/breeze/tests/test_release_candidate_command.py 
b/dev/breeze/tests/test_release_candidate_command.py
index c92d7b0aad7..049d45b3cfb 100644
--- a/dev/breeze/tests/test_release_candidate_command.py
+++ b/dev/breeze/tests/test_release_candidate_command.py
@@ -328,3 +328,190 @@ def 
test_remove_old_releases_removes_both_airflow_and_task_sdk_releases(monkeypa
         (["svn", "rm", "1.0.6rc1"], {"check": True}),
         (["svn", "commit", "-m", "Remove old Task SDK release: 1.0.6rc1"], 
{"check": True}),
     ]
+
+
+def test_move_artifacts_to_svn_returns_early_when_user_declines(monkeypatch, 
rc_cmd):
+    """Test that function returns early when user declines initial prompt."""
+    version = "2.10.0rc3"
+    version_without_rc = "2.10.0"
+    task_sdk_version = "1.0.6rc3"
+    task_sdk_version_without_rc = "1.0.6"
+    repo_root = "/repo/root"
+
+    confirm_prompts: list[str] = []
+
+    def fake_confirm_action(prompt: str, **kwargs):
+        confirm_prompts.append(prompt)
+        return False
+
+    def should_not_be_called(*_args, **_kwargs):
+        raise AssertionError("This should not have been called when user 
declines the initial prompt.")
+
+    monkeypatch.setattr(rc_cmd, "confirm_action", fake_confirm_action)
+    monkeypatch.setattr(rc_cmd.os, "chdir", should_not_be_called)
+    monkeypatch.setattr(rc_cmd, "console_print", should_not_be_called)
+    monkeypatch.setattr(rc_cmd, "run_command", should_not_be_called)
+
+    rc_cmd.move_artifacts_to_svn(
+        version=version,
+        version_without_rc=version_without_rc,
+        task_sdk_version=task_sdk_version,
+        task_sdk_version_without_rc=task_sdk_version_without_rc,
+        repo_root=repo_root,
+    )
+
+    assert confirm_prompts == ["Do you want to move artifacts to SVN?"]
+
+
+def test_move_artifacts_to_svn_completes_successfully(monkeypatch, rc_cmd):
+    """Test that function completes successfully when user confirms."""
+    version = "2.10.0rc3"
+    version_without_rc = "2.10.0"
+    task_sdk_version = "1.0.6rc3"
+    task_sdk_version_without_rc = "1.0.6"
+    repo_root = "/repo/root"
+
+    chdir_calls: list[str] = []
+    console_messages: list[str] = []
+    run_command_calls: list[tuple[list[str] | str, dict]] = []
+    confirm_prompts: list[str] = []
+
+    def fake_confirm_action(prompt: str, **kwargs):
+        confirm_prompts.append(prompt)
+        return True
+
+    def fake_chdir(path: str):
+        chdir_calls.append(path)
+
+    def fake_run_command(cmd: list[str] | str, **kwargs):
+        run_command_calls.append((cmd, kwargs))
+
+    monkeypatch.setattr(rc_cmd, "confirm_action", fake_confirm_action)
+    monkeypatch.setattr(rc_cmd.os, "chdir", fake_chdir)
+    monkeypatch.setattr(rc_cmd, "console_print", lambda msg="": 
console_messages.append(str(msg)))
+    monkeypatch.setattr(rc_cmd, "run_command", fake_run_command)
+
+    rc_cmd.move_artifacts_to_svn(
+        version=version,
+        version_without_rc=version_without_rc,
+        task_sdk_version=task_sdk_version,
+        task_sdk_version_without_rc=task_sdk_version_without_rc,
+        repo_root=repo_root,
+    )
+
+    assert confirm_prompts == ["Do you want to move artifacts to SVN?"]
+    assert chdir_calls == [f"{repo_root}/asf-dist/dev/airflow"]
+    # Verify svn mkdir for airflow version
+    assert any(
+        cmd == ["svn", "mkdir", version] and kwargs.get("check") is True for 
cmd, kwargs in run_command_calls
+    )
+    # Verify mv command for airflow artifacts
+    assert any(
+        cmd == f"mv {repo_root}/dist/*{version_without_rc}* {version}/"
+        and kwargs.get("check") is True
+        and kwargs.get("shell") is True
+        for cmd, kwargs in run_command_calls
+    )
+    # Verify svn mkdir for task-sdk version
+    assert any(cmd == ["svn", "mkdir", f"task-sdk/{task_sdk_version}"] for 
cmd, kwargs in run_command_calls)
+    # Verify mv command for task-sdk artifacts
+    assert any(
+        cmd == f"mv {repo_root}/dist/*{task_sdk_version_without_rc}* 
task-sdk/{task_sdk_version}/"
+        and kwargs.get("check") is True
+        and kwargs.get("shell") is True
+        for cmd, kwargs in run_command_calls
+    )
+    assert "[success]Moved artifacts to SVN:" in console_messages
+    # Verify ls commands
+    assert any(cmd == [f"ls {repo_root}/asf-dist/dev/airflow/{version}"] for 
cmd, kwargs in run_command_calls)
+    assert any(
+        cmd == [f"ls 
{repo_root}/asf-dist/dev/airflow/task-sdk/{task_sdk_version}"]
+        for cmd, kwargs in run_command_calls
+    )
+
+
+def 
test_push_artifacts_to_asf_repo_returns_early_when_user_declines(monkeypatch, 
rc_cmd):
+    """Test that function returns early when user declines initial prompt."""
+    version = "2.10.0rc3"
+    task_sdk_version = "1.0.6rc3"
+    repo_root = "/repo/root"
+
+    confirm_prompts: list[str] = []
+
+    def fake_confirm_action(prompt: str, **kwargs):
+        confirm_prompts.append(prompt)
+        if kwargs.get("abort") and not prompt.startswith("Do you want to 
push"):
+            # Simulate abort behavior
+            import sys
+
+            sys.exit(1)
+        return False
+
+    def should_not_be_called(*_args, **_kwargs):
+        raise AssertionError("This should not have been called when user 
declines the initial prompt.")
+
+    monkeypatch.setattr(rc_cmd, "confirm_action", fake_confirm_action)
+    monkeypatch.setattr(rc_cmd, "get_dry_run", lambda: False)
+    monkeypatch.setattr(rc_cmd.os, "chdir", should_not_be_called)
+    monkeypatch.setattr(rc_cmd, "console_print", should_not_be_called)
+    monkeypatch.setattr(rc_cmd, "run_command", should_not_be_called)
+
+    rc_cmd.push_artifacts_to_asf_repo(version=version, 
task_sdk_version=task_sdk_version, repo_root=repo_root)
+
+    assert confirm_prompts == ["Do you want to push artifacts to ASF repo?"]
+
+
+def test_push_artifacts_to_asf_repo_completes_successfully(monkeypatch, 
rc_cmd):
+    """Test that function completes successfully when user confirms all 
prompts."""
+    version = "2.10.0rc3"
+    task_sdk_version = "1.0.6rc3"
+    repo_root = "/repo/root"
+
+    chdir_calls: list[str] = []
+    console_messages: list[str] = []
+    run_command_calls: list[tuple[list[str] | str, dict]] = []
+    confirm_prompts: list[str] = []
+
+    def fake_confirm_action(prompt: str, **kwargs):
+        confirm_prompts.append(prompt)
+        return True
+
+    def fake_chdir(path: str):
+        chdir_calls.append(path)
+
+    def fake_run_command(cmd: list[str] | str, **kwargs):
+        run_command_calls.append((cmd, kwargs))
+
+    monkeypatch.setattr(rc_cmd, "confirm_action", fake_confirm_action)
+    monkeypatch.setattr(rc_cmd, "get_dry_run", lambda: False)
+    monkeypatch.setattr(rc_cmd.os, "chdir", fake_chdir)
+    monkeypatch.setattr(rc_cmd, "console_print", lambda msg="": 
console_messages.append(str(msg)))
+    monkeypatch.setattr(rc_cmd, "run_command", fake_run_command)
+
+    rc_cmd.push_artifacts_to_asf_repo(version=version, 
task_sdk_version=task_sdk_version, repo_root=repo_root)
+
+    assert confirm_prompts == [
+        "Do you want to push artifacts to ASF repo?",
+        "Do you want to continue?",
+        "Do you want to continue?",
+    ]
+    assert chdir_calls == [f"{repo_root}/asf-dist/dev/airflow"]
+    ls_calls = [(cmd, kwargs) for cmd, kwargs in run_command_calls if cmd == 
["ls"]]
+    assert len(ls_calls) == 2  # Two ls calls
+    assert any(kwargs.get("cwd") == 
f"{repo_root}/asf-dist/dev/airflow/{version}" for cmd, kwargs in ls_calls)
+    assert any(
+        kwargs.get("cwd") == 
f"{repo_root}/asf-dist/dev/airflow/task-sdk/{task_sdk_version}"
+        for cmd, kwargs in ls_calls
+    )
+    assert any(
+        cmd == f"svn add {version}/* task-sdk/{task_sdk_version}/*" for cmd, 
kwargs in run_command_calls
+    )
+    assert any(
+        cmd == ["svn", "commit", "-m", f"Add artifacts for Airflow {version} 
and Task SDK {task_sdk_version}"]
+        for cmd, kwargs in run_command_calls
+    )
+    assert "[success]Files pushed to svn" in console_messages
+    assert (
+        "Verify that the files are available here: 
https://dist.apache.org/repos/dist/dev/airflow/";
+        in console_messages
+    )

Reply via email to