feat: 支持多项目打包
- config.json 改为按项目存储(projects.<id>),上传配置全局共用;旧单项目配置自动迁移为 readoor
- 新增项目管理(管理员):Git 仓库/凭据、源码目录、Xcode 工程、拷贝条目、配置替换方式、自定义字段、替换规则
- 通用配置替换:pbxproj 版本号与签名,patch_rules 支持 define / replace_line 及 ${app.X}、${server.X} 模板
- 请求通过 X-Project 头选择项目;打包任务记录 project_id,历史按项目过滤
- 前端顶部切换项目,App/服务器环境表单按项目显示字段
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2bd5c7057f
commit
8f2f23682f
@@ -55,6 +55,17 @@ def tmp_dirs(tmp_path):
|
||||
return source_dir, build_dir
|
||||
|
||||
|
||||
def _patch_project_source(source_dir, remote_url="git@github.com:test/repo.git"):
|
||||
"""让任务所属项目使用指定的远程仓库和共享源码目录"""
|
||||
from backend.projects import ProjectSource
|
||||
source = ProjectSource(remote_url, remote_url, source_dir)
|
||||
return patch.multiple(
|
||||
"backend.services.build_service",
|
||||
load_task_project=MagicMock(return_value={}),
|
||||
get_project_source=MagicMock(return_value=source),
|
||||
)
|
||||
|
||||
|
||||
def _make_mock_process(returncode=0, output=b"ok\n"):
|
||||
"""创建 mock 进程,支持 async for stdout"""
|
||||
proc = AsyncMock()
|
||||
@@ -87,7 +98,7 @@ async def test_update_source_clone_no_remote(tmp_path, log_streamer):
|
||||
source_dir = tmp_path / "branches" / "main"
|
||||
|
||||
with patch("backend.services.build_service.get_git_remote_url", return_value=""):
|
||||
with pytest.raises(Exception, match="GIT_REMOTE_URL"):
|
||||
with pytest.raises(Exception, match="未配置 Git 仓库地址"):
|
||||
await update_source("t1", source_dir, "main")
|
||||
|
||||
|
||||
@@ -152,8 +163,7 @@ async def test_prepare_source_snapshot_serializes_shared_source(tmp_dirs, log_st
|
||||
source_dir, build_dir_parent = tmp_dirs
|
||||
task = MagicMock(branch="main")
|
||||
|
||||
with patch("backend.services.build_service.get_git_remote_url", return_value="git@github.com:test/repo.git"), \
|
||||
patch("backend.services.build_service.get_shared_source_dir", return_value=source_dir), \
|
||||
with _patch_project_source(source_dir), \
|
||||
patch("backend.services.build_service.BUILD_BASE_DIR", build_dir_parent), \
|
||||
patch("backend.services.build_service.update_source", new_callable=AsyncMock) as mock_update, \
|
||||
patch("backend.services.build_service.get_source_commit", new_callable=AsyncMock, return_value="abc123"):
|
||||
@@ -168,8 +178,7 @@ async def test_prepare_source_snapshot_passes_tag_ref_type(tmp_dirs, log_streame
|
||||
source_dir, build_dir_parent = tmp_dirs
|
||||
task = MagicMock(id="tag-task", branch="v3.2.0", ref_type="tag")
|
||||
|
||||
with patch("backend.services.build_service.get_git_remote_url", return_value="git@github.com:test/repo.git"), \
|
||||
patch("backend.services.build_service.get_shared_source_dir", return_value=source_dir), \
|
||||
with _patch_project_source(source_dir), \
|
||||
patch("backend.services.build_service.BUILD_BASE_DIR", build_dir_parent), \
|
||||
patch("backend.services.build_service.update_source", new_callable=AsyncMock) as mock_update, \
|
||||
patch("backend.services.build_service.get_source_commit", new_callable=AsyncMock, return_value="abc123"):
|
||||
@@ -266,6 +275,7 @@ async def test_run_pod_install_patches_afnetworking(tmp_path, log_streamer):
|
||||
source_dir.mkdir(parents=True)
|
||||
source_file = source_dir / "AFHTTPSessionManager.m"
|
||||
source_file.write_text("#import <netinet6/in6.h>\n")
|
||||
(tmp_path / "Podfile").write_text("pod 'AFNetworking'")
|
||||
|
||||
with patch("asyncio.create_subprocess_exec", return_value=_make_mock_process()):
|
||||
await run_pod_install("t1", tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user