Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): enforce Electron asar regression in CI

tiammomo216a3e345b59
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 96164b68c4..1730c575b4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -84,6 +84,31 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
+ # 默认 unit tier 会排除 migration 测试,而 CI 的常规安装也会跳过 Electron
+ # 二进制。只有相关路径变化时才补下载锁定 runtime,强制跑真实 .asar 复制回归。
+ - name: Run Electron ASAR migration regression
+ if: ${{ github.event_name == 'pull_request' }}
+ env:
+ CINDY_REQUIRE_ELECTRON_RUNTIME_TEST: '1'
+ ELECTRON_OVERRIDE_DIST_PATH: ''
+ ELECTRON_SKIP_BINARY_DOWNLOAD: ''
+ PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ run: |
+ if git diff --quiet "$PR_BASE_SHA"...HEAD -- \
+ .github/workflows/ci.yml \
+ package.json \
+ pnpm-lock.yaml \
+ apps/desktop/package.json \
+ apps/desktop/vite.main.config.ts \
+ apps/desktop/vitest.config.ts \
+ apps/desktop/src/main/legacyUserDataMigration.ts \
+ apps/desktop/src/main/__tests__/legacyUserDataMigration.test.ts; then
+ echo "Electron ASAR migration paths unchanged; skipping runtime regression."
+ exit 0
+ fi
+ pnpm rebuild electron
+ pnpm --filter desktop exec vitest run src/main/__tests__/legacyUserDataMigration.test.ts
+
# XDT_SKIP_AGENT_BIN_INSTALL 跳过了 postinstall 的全部 agent 二进制,但
# runtime-configs.ts 模块顶层的 bundledRipgrepDir() 缺 rg 时直接 throw,
# 会让 apps/desktop 单测在收集阶段全挂——ripgrep 必须单独装回来。
diff --git a/apps/desktop/src/main/__tests__/legacyUserDataMigration.test.ts b/apps/desktop/src/main/__tests__/legacyUserDataMigration.test.ts
index 05437e4503..6355b30a92 100644
--- a/apps/desktop/src/main/__tests__/legacyUserDataMigration.test.ts
+++ b/apps/desktop/src/main/__tests__/legacyUserDataMigration.test.ts
@@ -30,6 +30,13 @@ const electronResourcesDir = process.platform === 'darwin'
: path.join(path.dirname(electronPath), 'resources');
const electronAsarFixture = path.join(electronResourcesDir, 'default_app.asar');
const hasElectronRuntime = existsSync(electronPath) && existsSync(electronAsarFixture);
+const requireElectronRuntime = process.env.CINDY_REQUIRE_ELECTRON_RUNTIME_TEST === '1';
+
+if (requireElectronRuntime && !hasElectronRuntime) {
+ throw new Error(
+ 'CINDY_REQUIRE_ELECTRON_RUNTIME_TEST requires an installed Electron runtime and default_app.asar',
+ );
+}
/** 内存 fs 假体:Map 存文件(内容 + mtime),Set 存目录/符号链接;merge 复制不覆盖。 */
function createMemFs() {