From 1194f138ed7096b60b2147bce0c1c79d53565a15 Mon Sep 17 00:00:00 2001 From: Mohammad Alisafaee Date: Fri, 20 Jan 2023 15:45:37 +0100 Subject: [PATCH] fix(workflow): better error message when running non-eixisting workflow file --- renku/ui/cli/run.py | 4 ++-- tests/cli/test_workflow_file.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/renku/ui/cli/run.py b/renku/ui/cli/run.py index 856800d17d..35ebb17b02 100644 --- a/renku/ui/cli/run.py +++ b/renku/ui/cli/run.py @@ -562,10 +562,10 @@ def is_workflow_file() -> bool: return False path = Path(command_line[0]) - if not path.is_file() or not is_subpath(path=path, base=project_context.path): - return False if path.suffix.lower() in [".yml", ".yaml"] and not os.access(path, os.X_OK): return True + if not path.is_file() or not is_subpath(path=path, base=project_context.path): + return False try: content = read_workflow_file(path=path) diff --git a/tests/cli/test_workflow_file.py b/tests/cli/test_workflow_file.py index 288bd2654d..e6af095957 100644 --- a/tests/cli/test_workflow_file.py +++ b/tests/cli/test_workflow_file.py @@ -82,6 +82,15 @@ def test_run_workflow_file_with_selected_steps(runner, workflow_file_project): assert not (workflow_file_project.path / "results" / "output.csv.wc").exists() +def test_run_non_existing_workflow_file(runner, workflow_file_project): + """Test running a non-existing workflow file gives proper error if file has YAML extension.""" + result = runner.invoke(cli, ["run", "non-existing-workflow-file.yml"]) + + assert 2 == result.exit_code, format_result_exception(result) + + assert "No such file or directory: 'non-existing-workflow-file.yml'" in result.output + + def test_run_workflow_file_with_no_commit(runner, workflow_file_project): """Test running a workflow file with ``--no-commit`` option.""" commit_before = workflow_file_project.repository.head.commit.hexsha