From 8146158e1d71f01efa18b15fa732b013817c1788 Mon Sep 17 00:00:00 2001 From: shanyuhai123 <864299347@qq.com> Date: Mon, 28 Sep 2026 20:19:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=20pnpm=20=E7=BC=93=E5=AD=98=E4=B8=8E=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=B5=8B=E8=AF=95=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../install-workspace-dependencies/action.yml | 46 +++++++++++++++++++ .github/scripts/resolve-ci-scope.mjs | 1 + .github/workflows/buddy-build.yml | 18 ++++---- .github/workflows/ci.yml | 25 +++++----- .github/workflows/macos-verify.yml | 12 ++--- .../__tests__/ExtensionService.spec.ts | 12 ++--- apps/buddy/vite.config.ts | 1 + 7 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 .github/actions/install-workspace-dependencies/action.yml diff --git a/.github/actions/install-workspace-dependencies/action.yml b/.github/actions/install-workspace-dependencies/action.yml new file mode 100644 index 00000000..b51291c2 --- /dev/null +++ b/.github/actions/install-workspace-dependencies/action.yml @@ -0,0 +1,46 @@ +name: Install workspace dependencies +description: Restore the pnpm store, install selected workspace packages, and save the store before further checks. + +inputs: + packages: + description: Space-separated workspace package selectors. + required: true + +runs: + using: composite + steps: + - name: Resolve pnpm store + id: store + shell: bash + run: | + store_path="$(pnpm store path --silent)" + node_arch="$(node -p 'process.arch')" + printf 'path=%s\narch=%s\n' "$store_path" "$node_arch" >> "$GITHUB_OUTPUT" + + - name: Restore pnpm store + id: cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: ${{ steps.store.outputs.path }} + key: node-cache-${{ runner.os }}-${{ steps.store.outputs.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + node-cache-${{ runner.os }}-${{ steps.store.outputs.arch }}-pnpm- + + - name: Install workspace dependencies + shell: bash + env: + WORKSPACE_PACKAGES: ${{ inputs.packages }} + run: | + read -r -a packages <<< "$WORKSPACE_PACKAGES" + filters=() + for package in "${packages[@]}"; do + filters+=(--filter "$package") + done + pnpm "${filters[@]}" install --frozen-lockfile + + - name: Save pnpm store + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: ${{ steps.store.outputs.path }} + key: ${{ steps.cache.outputs.cache-primary-key }} diff --git a/.github/scripts/resolve-ci-scope.mjs b/.github/scripts/resolve-ci-scope.mjs index 62d6b5ce..8846f47e 100644 --- a/.github/scripts/resolve-ci-scope.mjs +++ b/.github/scripts/resolve-ci-scope.mjs @@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url' const repoRoot = resolve(import.meta.dirname, '../..') const ciInputs = new Set([ + '.github/actions/install-workspace-dependencies/action.yml', '.github/workflows/ci.yml', '.github/scripts/resolve-ci-scope.mjs', ]) diff --git a/.github/workflows/buddy-build.yml b/.github/workflows/buddy-build.yml index c465ab77..a6f3f818 100644 --- a/.github/workflows/buddy-build.yml +++ b/.github/workflows/buddy-build.yml @@ -38,8 +38,6 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Setup Rust uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable @@ -61,7 +59,9 @@ jobs: xvfb - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Resolve package target id: package @@ -121,8 +121,6 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Setup Rust uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable @@ -130,7 +128,9 @@ jobs: toolchain: 1.98.0 - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Resolve package target id: package @@ -262,8 +262,6 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Setup Rust uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable @@ -271,7 +269,9 @@ jobs: toolchain: 1.98.0 - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Resolve package target id: package diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06a0ad46..1017184d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: branches: [master] paths: - .github/workflows/ci.yml + - .github/actions/install-workspace-dependencies/action.yml - .github/scripts/resolve-ci-scope.mjs - .github/scripts/buddy-test-runtime.mjs - .cargo/** @@ -87,11 +88,11 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter @uselexora/lexora-website install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-website' - name: Lint workspace run: pnpm --filter @uselexora/lexora-website lint @@ -118,11 +119,11 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora' - name: Lint repository run: >- @@ -148,11 +149,11 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Lint workspace run: pnpm exec eslint .playwright/scripts apps/buddy packaging/buddy @@ -328,11 +329,11 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' ci-gate: name: CI Gate diff --git a/.github/workflows/macos-verify.yml b/.github/workflows/macos-verify.yml index 99a602d4..73bd2984 100644 --- a/.github/workflows/macos-verify.yml +++ b/.github/workflows/macos-verify.yml @@ -44,8 +44,6 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Setup Rust uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable @@ -59,7 +57,9 @@ jobs: node packaging/buddy/release/artifacts.mjs --format dmg --github-output "$GITHUB_OUTPUT" - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Test native components env: @@ -124,11 +124,11 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - name: Install workspace dependencies - run: pnpm --filter @uselexora/lexora --filter '@uselexora/lexora-buddy...' install --frozen-lockfile + uses: ./.github/actions/install-workspace-dependencies + with: + packages: '@uselexora/lexora @uselexora/lexora-buddy...' - name: Download verified macOS package uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 diff --git a/apps/buddy/platform/extensions/__tests__/ExtensionService.spec.ts b/apps/buddy/platform/extensions/__tests__/ExtensionService.spec.ts index 25932ea2..a5983641 100644 --- a/apps/buddy/platform/extensions/__tests__/ExtensionService.spec.ts +++ b/apps/buddy/platform/extensions/__tests__/ExtensionService.spec.ts @@ -19,10 +19,10 @@ function deferred() { }) return { promise, resolve } } -async function fixture(overrides: Partial = {}) { +async function fixture(overrides: Partial = {}, initialManifest = manifest()) { const { root, store } = await createStore() cleanup.push(() => rm(root, { recursive: true, force: true })) - await store.install((await reviewPackage(root, store)).token) + await store.install((await reviewPackage(root, store, initialManifest)).token) const hosts: Array<{ broker: (method: string, params: unknown) => Promise, failed: () => void, disposed: boolean, commands: JsonValue[] }> = [] const events: unknown[] = [] const service = new ExtensionService(store, { @@ -298,9 +298,8 @@ it('rejects unauthorized media and late picker selections without retaining gran }) it('binds presentation changes to a current declared placement and reports real installation state', async () => { - const f = await fixture({ workbench: async event => event.kind === 'presentation' ? event.viewId : null }) const value = manifest({ apiVersion: 2, id: 'tests.panel', contributes: { views: [{ id: 'tests.panel.ui', title: 'Panel', entry: 'view.js', resource: 'none' }], placements: [{ id: 'tests.panel.float', kind: 'view', location: 'workbench.floating', view: 'tests.panel.ui' }] } }) - await f.service.install((await reviewPackage(f.root, f.store, value)).token) + const f = await fixture({ workbench: async event => event.kind === 'presentation' ? event.viewId : null }, value) const input = { viewId: randomUUID(), extensionId: value.id, viewType: 'tests.panel.ui', resource: null, state: { secret: 'private-state' }, stateVersion: 1 } const view = await f.service.openView({ ...input, placementId: 'tests.panel.float' }) const request = (method: string, params: JsonValue) => f.service.viewRequest(view.id, view.generation, view.token, method, params) @@ -319,11 +318,10 @@ it('binds presentation changes to a current declared placement and reports real it('keeps export permission separate from reads and expires writers with their owning view', async () => { let destination = '' - const f = await fixture({ selectSavePath: async () => destination }) + const value = manifest({ apiVersion: 2, id: 'tests.export', permissions: { localResources: true }, contributes: { views: [{ id: 'tests.export.page', title: 'Export', entry: 'view.js', resource: 'none' }] } }) + const f = await fixture({ selectSavePath: async () => destination }, value) destination = join(f.root, 'export.binary') await writeFile(destination, 'original') - const value = manifest({ apiVersion: 2, id: 'tests.export', permissions: { localResources: true }, contributes: { views: [{ id: 'tests.export.page', title: 'Export', entry: 'view.js', resource: 'none' }] } }) - await f.service.install((await reviewPackage(f.root, f.store, value)).token) const input = { viewId: randomUUID(), extensionId: value.id, viewType: 'tests.export.page', resource: null, state: null, stateVersion: 1 } const readOnly = await f.service.openView(input) const payload = { name: 'file.unknown', size: 4 } diff --git a/apps/buddy/vite.config.ts b/apps/buddy/vite.config.ts index dce20d49..f91ab98d 100644 --- a/apps/buddy/vite.config.ts +++ b/apps/buddy/vite.config.ts @@ -66,6 +66,7 @@ export default defineConfig({ extends: true, test: { name: 'platform', + testTimeout: 15_000, include: ['platform/**/*.{test,spec}.?(c|m)[jt]s?(x)'], }, },