Allow specify workflow run to execute YAML files without a project#2825
Allow specify workflow run to execute YAML files without a project#2825Copilot wants to merge 4 commits into
specify workflow run to execute YAML files without a project#2825Conversation
--workflow option to init for post-bootstrap workflow execution
Instead of adding --workflow to init, make `specify workflow run ./file.yml` work without requiring a .specify/ project directory. When the source is a YAML file that exists on disk, cwd is used as the project root. When it's a workflow ID, the .specify/ project requirement is preserved.
Done in 08d21cf. Removed the Usage: |
--workflow option to init for post-bootstrap workflow executionspecify workflow run to execute YAML files without a project
There was a problem hiding this comment.
Pull request overview
This PR updates the specify workflow run CLI to support running a local workflow YAML file even when the current directory is not an initialized Spec Kit project (i.e., no .specify/ directory). This aligns the CLI with the documented ability to run workflows from local YAML paths, while preserving the existing “project required” behavior when running by workflow ID.
Changes:
- Detect when
sourceis an existing.yml/.yamlfile and usecwdas the workflow engine project root without calling_require_specify_project(). - Add pytest coverage verifying local YAML execution works without a project, while workflow IDs still require a project.
- Add test coverage for missing YAML paths and a failing YAML workflow run.
Show a summary per file
| File | Description |
|---|---|
| src/specify_cli/init.py | Makes workflow run skip the .specify/ project requirement when source is an existing YAML file path. |
| tests/test_workflow_run_without_project.py | Adds regression tests for running a YAML workflow outside a project and for related edge cases. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
| source_path = Path(source) | ||
| is_file_source = source_path.suffix in (".yml", ".yaml") and source_path.exists() | ||
|
|
| if is_file_source: | ||
| # When running a YAML file directly, use cwd as project root | ||
| # without requiring a .specify/ project directory. | ||
| project_root = Path.cwd() | ||
| else: | ||
| project_root = _require_specify_project() |
| ], catch_exceptions=False) | ||
| finally: | ||
| os.chdir(old_cwd) | ||
| assert "failed" in result.output.lower() |
Makes
specify workflow run ./myworkflow.ymlwork without requiring a.specify/project directory. When the source argument is a YAML file path that exists on disk, the current working directory is used as the project root. When running by workflow ID, the existing project requirement is preserved.Changes
src/specify_cli/__init__.py: Modified theworkflow_runcommand to detect when the source is an existing YAML file and skip the.specify/project requirement, usingcwdas the project root instead.tests/test_workflow_run_without_project.py: Tests for running a YAML workflow without a project, verifying workflow ID still requires a project, handling missing YAML files, and reporting failure status.