mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 05:08:12 +00:00
* Update crewAI CLI with various enhancements and fixes - Updated `create_json_crew.py` to require `crewai[tools]>=1.14.7`. - Enhanced `git.py` with improved repository initialization, including automatic initial commit creation and exclusion patterns for initial commits. - Modified `install_crew.py` to allow error handling during installation with an optional `raise_on_error` parameter. - Expanded `plus_api.py` to include methods for creating and updating crews from ZIP files. - Introduced a new `archive.py` for creating deployable ZIP archives of CrewAI projects, ensuring local artifacts are excluded. - Updated `run_crew.py` to manage JSON crew dependencies and run crews in the project's environment. - Enhanced deployment logic in `main.py` to handle ZIP uploads and improve user feedback during deployment processes. - Added tests for new functionalities and ensured existing tests reflect recent changes in behavior and requirements. * fix(cli): address deploy zip review feedback * fix(cli): sync missing lockfile before deploy * fix(cli): preserve remote deploy on git setup warnings * test(cli): use single deploy main import style * fix(cli): skip project install for json crew sync * fix(cli): load json runner from source checkout * fix(cli): skip json crew sync when locked * fix(cli): address deploy zip review feedback * fix(cli): pass env on zip redeploy * fix(cli): harden json run and zip fallback * fix(cli): validate before deploy lock install * fix(cli): respect poetry lock for json runs * fix(cli): align json zip wrapper detection * fix(deps): bump starlette audit floor * fix(cli): avoid auth retry for deploy exits * fix(cli): update json zip script entrypoints
103 lines
2.6 KiB
Python
103 lines
2.6 KiB
Python
from pathlib import Path
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
import crewai_cli.install_crew as install_crew_module
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _tool_credentials(monkeypatch):
|
|
monkeypatch.setattr(
|
|
install_crew_module,
|
|
"build_env_with_all_tool_credentials",
|
|
lambda: {"CREWAI_TEST": "1"},
|
|
)
|
|
|
|
|
|
def test_install_crew_json_project_skips_project_install(
|
|
fp, monkeypatch, tmp_path: Path
|
|
):
|
|
monkeypatch.chdir(tmp_path)
|
|
(tmp_path / "pyproject.toml").write_text(
|
|
"""
|
|
[project]
|
|
name = "json_crew"
|
|
|
|
[tool.crewai]
|
|
type = "crew"
|
|
""".strip()
|
|
)
|
|
(tmp_path / "crew.jsonc").write_text("{}\n")
|
|
fp.register(["uv", "sync", "--no-install-project"], stdout="")
|
|
|
|
install_crew_module.install_crew([])
|
|
|
|
|
|
def test_install_crew_json_project_with_python_package_installs_project(
|
|
fp, monkeypatch, tmp_path: Path
|
|
):
|
|
monkeypatch.chdir(tmp_path)
|
|
(tmp_path / "pyproject.toml").write_text(
|
|
"""
|
|
[project]
|
|
name = "hybrid-crew"
|
|
|
|
[tool.crewai]
|
|
type = "crew"
|
|
""".strip()
|
|
)
|
|
(tmp_path / "crew.jsonc").write_text("{}\n")
|
|
package_dir = tmp_path / "src" / "hybrid_crew"
|
|
package_dir.mkdir(parents=True)
|
|
(package_dir / "crew.py").write_text("class HybridCrew: ...\n")
|
|
fp.register(["uv", "sync"], stdout="")
|
|
|
|
install_crew_module.install_crew([])
|
|
|
|
|
|
def test_install_crew_flow_project_installs_project(fp, monkeypatch, tmp_path: Path):
|
|
monkeypatch.chdir(tmp_path)
|
|
(tmp_path / "pyproject.toml").write_text(
|
|
"""
|
|
[project]
|
|
name = "flow_project"
|
|
|
|
[tool.crewai]
|
|
type = "flow"
|
|
""".strip()
|
|
)
|
|
(tmp_path / "crew.jsonc").write_text("{}\n")
|
|
fp.register(["uv", "sync"], stdout="")
|
|
|
|
install_crew_module.install_crew([])
|
|
|
|
|
|
def test_install_crew_classic_project_installs_project(
|
|
fp, monkeypatch, tmp_path: Path
|
|
):
|
|
monkeypatch.chdir(tmp_path)
|
|
(tmp_path / "pyproject.toml").write_text("[project]\nname = 'classic'\n")
|
|
fp.register(["uv", "sync"], stdout="")
|
|
|
|
install_crew_module.install_crew([])
|
|
|
|
|
|
def test_install_crew_install_project_false_adds_no_install_project(fp):
|
|
fp.register(["uv", "sync", "--no-install-project", "--frozen"], stdout="")
|
|
|
|
install_crew_module.install_crew(["--frozen"], install_project=False)
|
|
|
|
|
|
def test_install_crew_reraises_sync_failure_when_requested(fp):
|
|
fp.register(["uv", "sync"], returncode=1, stderr="sync failed\n")
|
|
|
|
with pytest.raises(subprocess.CalledProcessError):
|
|
install_crew_module.install_crew([], raise_on_error=True)
|
|
|
|
|
|
def test_install_crew_swallows_sync_failure_by_default(fp):
|
|
fp.register(["uv", "sync"], returncode=1, stderr="sync failed\n")
|
|
|
|
install_crew_module.install_crew([])
|