Skip to content

Commit 0e27a8c

Browse files
authored
fix(workflows): load custom steps before add (#4473)
Assisted-by: GitHub Copilot (model: unknown, supervised)
1 parent 45db690 commit 0e27a8c

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

‎src/specify_cli/workflows/_commands.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,9 +1733,11 @@ def workflow_add(
17331733
from_url: str | None = typer.Option(None, "--from", help="Install from a custom URL"),
17341734
):
17351735
"""Install a workflow from catalog, URL, or local path."""
1736+
from . import load_custom_steps
17361737
from .engine import WorkflowDefinition
17371738

17381739
project_root = _require_specify_project()
1740+
load_custom_steps(project_root)
17391741
_open_workflow_registry(project_root)
17401742
workflows_dir = project_root / ".specify" / "workflows"
17411743
# With --from, source names the expected workflow ID: validate it up

‎tests/test_workflows.py‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10273,6 +10273,68 @@ def test_lowercase_extension_still_installs(self, temp_dir, monkeypatch, sample_
1027310273
assert result.exit_code == 0, result.output
1027410274
assert "installed" in result.output
1027510275

10276+
def test_add_installs_workflow_with_custom_step(self, temp_dir, monkeypatch):
10277+
from typer.testing import CliRunner
10278+
from specify_cli import app
10279+
10280+
(temp_dir / ".specify" / "workflows").mkdir(parents=True)
10281+
step_dir = temp_dir / ".specify" / "workflows" / "steps" / "test-add-step"
10282+
step_dir.mkdir(parents=True)
10283+
step_manifest = {
10284+
"schema_version": "1.0",
10285+
"step": {
10286+
"type_key": "test-add-step",
10287+
"name": "Test Add Step",
10288+
"version": "1.0.0",
10289+
},
10290+
}
10291+
(step_dir / "step.yml").write_text(
10292+
yaml.safe_dump(step_manifest, sort_keys=False),
10293+
encoding="utf-8",
10294+
)
10295+
(step_dir / "__init__.py").write_text(
10296+
"""
10297+
from specify_cli.workflows.base import StepBase, StepResult
10298+
10299+
10300+
class TestAddStep(StepBase):
10301+
type_key = "test-add-step"
10302+
10303+
def execute(self, config, context):
10304+
return StepResult()
10305+
""",
10306+
encoding="utf-8",
10307+
)
10308+
10309+
src = temp_dir / "sample.yml"
10310+
workflow_definition = {
10311+
"schema_version": "1.0",
10312+
"workflow": {
10313+
"id": "test-workflow-with-custom-step",
10314+
"name": "Test Workflow With Custom Step",
10315+
"version": "1.0.0",
10316+
},
10317+
"steps": [
10318+
{"id": "custom-step", "type": "test-add-step"},
10319+
],
10320+
}
10321+
src.write_text(
10322+
yaml.safe_dump(workflow_definition, sort_keys=False),
10323+
encoding="utf-8",
10324+
)
10325+
monkeypatch.chdir(temp_dir)
10326+
result = CliRunner().invoke(app, ["workflow", "add", str(src)])
10327+
10328+
assert result.exit_code == 0, result.output
10329+
installed_workflow = (
10330+
temp_dir
10331+
/ ".specify"
10332+
/ "workflows"
10333+
/ "test-workflow-with-custom-step"
10334+
/ "workflow.yml"
10335+
)
10336+
assert installed_workflow.is_file()
10337+
1027610338

1027710339
class TestWorkflowInfoStepGraph:
1027810340
"""`workflow info` must render each step as `→ <id> [<type>]` with LITERAL

0 commit comments

Comments
 (0)