🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
👷 ci(desktop): move the overlay type check into the desktop PR build (#23365)
Inneiedd2b1f5c257
diff --git a/.github/actions/desktop-build-setup/action.yml b/.github/actions/desktop-build-setup/action.ymlindex e1fcb51f154..4d8c306c539 100644--- a/.github/actions/desktop-build-setup/action.yml+++ b/.github/actions/desktop-build-setup/action.yml@@ -121,6 +121,17 @@ runs:echo "CLOUD_DESKTOP=1" >> "$GITHUB_ENV"echo "✅ Cloud repository $resolved_cloud_ref overlaid at $cloud_root"+ # Shared with the isolated desktop install below. The root `pnpm-lock.yaml` is+ # gitignored, so hash the tracked dependency declarations — hashing an absent+ # file would pin one key forever and stop the store from ever taking new tarballs.+ - name: Cache pnpm store+ uses: actions/cache@v4+ with:+ path: ${{ runner.temp }}/pnpm-store+ key: pnpm-store-${{ runner.os }}-v1-${{ hashFiles('package.json', 'pnpm-workspace.yaml', 'apps/*/package.json', 'packages/*/package.json', 'patches/*.patch', 'apps/desktop/pnpm-lock.yaml') }}+ restore-keys: |+ pnpm-store-${{ runner.os }}-v1-+- name: Install dependenciesshell: bashrun: |@@ -128,7 +139,7 @@ runs:if [ "${CLOUD_DESKTOP:-}" = "1" ]; thencd ..fi- pnpm install --node-linker=hoisted+ pnpm install --node-linker=hoisted --store-dir "$RUNNER_TEMP/pnpm-store" --prefer-offline# 移除国内 electron 镜像配置,GitHub Actions 使用官方源更快- name: Remove China electron mirror from .npmrc@@ -143,6 +154,10 @@ runs:- name: Install deps on Desktopshell: bash+ env:+ # Reuse the store restored above instead of the ephemeral global one.+ # pnpm reads its own `pnpm_config_*` env namespace, not `npm_config_*`.+ pnpm_config_store_dir: ${{ runner.temp }}/pnpm-storerun: |set -euo pipefailif [ "${CLOUD_DESKTOP:-}" = "1" ]; thendiff --git a/.github/actions/overlay-type-check/action.yml b/.github/actions/overlay-type-check/action.ymlindex df680e4fb9f..8b90d50dd01 100644--- a/.github/actions/overlay-type-check/action.yml+++ b/.github/actions/overlay-type-check/action.yml@@ -36,9 +36,21 @@ runs:overlay-ref: ${{ inputs.overlay-ref }}overlay-token: ${{ inputs.overlay-token }}+ # The overlay root ships no lockfile, so pnpm resolves from package.json ranges+ # on every run. The root `pnpm-lock.yaml` is gitignored, so the key hashes the+ # tracked dependency declarations instead — hashing an absent file would pin one+ # key forever and stop the store from ever taking new tarballs.+ - name: Cache pnpm store+ uses: actions/cache@v4+ with:+ path: ${{ runner.temp }}/pnpm-store+ key: pnpm-store-${{ runner.os }}-v1-${{ hashFiles('package.json', 'pnpm-workspace.yaml', 'apps/*/package.json', 'packages/*/package.json', 'patches/*.patch', 'apps/desktop/pnpm-lock.yaml') }}+ restore-keys: |+ pnpm-store-${{ runner.os }}-v1-+- name: Install dependenciesshell: bash- run: cd .. && pnpm install --node-linker=hoisted+ run: cd .. && pnpm install --node-linker=hoisted --store-dir "$RUNNER_TEMP/pnpm-store" --prefer-offline- name: Type check overlaid sourcesshell: bashdiff --git a/.github/scripts/desktop-overlay-type-check.test.mjs b/.github/scripts/desktop-overlay-type-check.test.mjsindex 8d1c5c98bcf..9051094bb5b 100644--- a/.github/scripts/desktop-overlay-type-check.test.mjs+++ b/.github/scripts/desktop-overlay-type-check.test.mjs@@ -1,11 +1,25 @@import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';import { readFile } from 'node:fs/promises';import { test } from 'node:test';+import { fileURLToPath } from 'node:url';import { parse } from 'yaml';const load = async (path) => parse(await readFile(new URL(path, import.meta.url), 'utf8'));+const repoRoot = fileURLToPath(new URL('../..', import.meta.url));++/** CI only checks out tracked files, so a gitignored file hashes to nothing there. */+const isIgnored = (file) => {+ try {+ execFileSync('git', ['check-ignore', '--quiet', file], { cwd: repoRoot });+ return true;+ } catch {+ return false;+ }+};+const needsOf = (job) => [job.needs ?? []].flat();const stepUsing = (job, action) => job.steps.find((step) => step.uses === action);@@ -65,7 +79,7 @@ test('the type check runs from the overlay root against the pinned overlay revis});test('a pull request is judged against its base under the same overlay revision', async () => {- const { jobs } = await load('../workflows/overlay-type-check.yml');+ const { jobs } = await load('../workflows/pr-build-desktop.yml');const { steps } = jobs['overlay-type-check'];const [head, base] = steps.filter((step) => step.uses === './.github/actions/overlay-type-check');@@ -76,3 +90,49 @@ test('a pull request is judged against its base under the same overlay revision'new RegExp(`overlayTypeErrors\\.mjs .*${base.with['log-name']}.*${head.with['log-name']}`),);});++test('every pull request gets the overlay check, not only desktop builds', async () => {+ const workflow = await load('../workflows/pr-build-desktop.yml');+ const job = workflow.jobs['overlay-type-check'];++ // The desktop build jobs are gated behind `trigger:build-desktop`; the overlay+ // check must not inherit that gate or ordinary pull requests go unchecked.+ assert.doesNotMatch(String(job.if ?? ''), /trigger:build-desktop|release\//);+ assert.ok([workflow.on.pull_request.types].flat().includes('opened'));+});++for (const path of [+ '../actions/overlay-type-check/action.yml',+ '../actions/desktop-build-setup/action.yml',+]) {+ test(`${path} installs from a cached pnpm store`, async () => {+ const { runs } = await load(path);+ const cache = stepUsing(runs, 'actions/cache@v4');+ const install = runs.steps.find((step) =>+ /pnpm install --node-linker=hoisted/.test(step.run ?? ''),+ );++ assert.ok(cache, 'the store is cached');+ assert.match(String(cache.with.path), /pnpm-store/);+ assert.ok(+ runs.steps.indexOf(cache) < runs.steps.indexOf(install),+ 'the store is restored before install',+ );+ // The overlay root has no lockfile, so the store path must be passed explicitly.+ assert.match(String(install.run), /--store-dir "\$RUNNER_TEMP\/pnpm-store"/);+ assert.match(String(install.run), /--prefer-offline/);++ const hashed = String(cache.with.key)+ .match(/hashFiles\(([^)]*)\)/)[1]+ .split(',')+ .map((entry) => entry.trim().replaceAll("'", ''));++ assert.ok(+ hashed.some((entry) => entry.includes('package.json')),+ 'the key follows dependency declarations',+ );+ for (const file of hashed.filter((entry) => !entry.includes('*'))) {+ assert.ok(!isIgnored(file), `${file} is gitignored, so CI would hash nothing`);+ }+ });+}diff --git a/.github/workflows/overlay-type-check.yml b/.github/workflows/overlay-type-check.ymldeleted file mode 100644index cd78f5ed5a4..00000000000--- a/.github/workflows/overlay-type-check.yml+++ /dev/null@@ -1,72 +0,0 @@-name: Overlay Type Check--on:- pull_request:- branches: [canary]- paths-ignore:- - 'docs/**'- - '**/*.md'- - '**/*.mdx'--concurrency:- group: overlay-type-check-${{ github.event.pull_request.number }}- cancel-in-progress: true--permissions:- contents: read--env:- NODE_VERSION: '24.11.1'--jobs:- overlay-type-check:- name: Overlay type check- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v7- with:- fetch-depth: 2-- - name: Create overlay token- id: overlay-token- uses: ./.github/actions/overlay-token- with:- app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}- private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}- repository: ${{ vars.OVERLAY_REPOSITORY }}-- - name: Type check this pull request with the overlay- id: head- if: steps.overlay-token.outputs.token != ''- continue-on-error: true- uses: ./.github/actions/overlay-type-check- with:- log-name: head.log- node-version: ${{ env.NODE_VERSION }}- overlay-repository: ${{ vars.OVERLAY_REPOSITORY }}- overlay-token: ${{ steps.overlay-token.outputs.token }}-- # The overlay follows this branch with a delay, so the base can already fail- # for reasons this pull request did not cause; only errors it adds count.- - name: Check out the base with this pull request's workflow tooling- if: steps.head.outcome == 'failure'- run: |- set -euo pipefail- head_sha="$(git rev-parse HEAD)"- git checkout --force --detach HEAD^1- git checkout "$head_sha" -- .github-- - name: Type check the base with the same overlay- if: steps.head.outcome == 'failure'- continue-on-error: true- uses: ./.github/actions/overlay-type-check- with:- log-name: base.log- node-version: ${{ env.NODE_VERSION }}- overlay-ref: ${{ env.OVERLAY_REF }}- overlay-repository: ${{ vars.OVERLAY_REPOSITORY }}- overlay-token: ${{ steps.overlay-token.outputs.token }}-- - name: Fail on type errors this pull request introduces- if: steps.head.outcome == 'failure'- run: node .github/scripts/overlayTypeErrors.mjs "$RUNNER_TEMP/base.log" "$RUNNER_TEMP/head.log"diff --git a/.github/workflows/pr-build-desktop.yml b/.github/workflows/pr-build-desktop.ymlindex 2c3ca743845..59cbe37e40c 100644--- a/.github/workflows/pr-build-desktop.yml+++ b/.github/workflows/pr-build-desktop.yml@@ -2,7 +2,12 @@ name: Desktop PR Buildon:pull_request:- types: [synchronize, labeled, unlabeled] # PR 更新或标签变化时触发+ # opened/reopened 让 overlay type check 在普通 PR 上也能跑,不必等到被打上桌面构建标签+ types: [opened, synchronize, reopened, labeled, unlabeled]+ paths-ignore:+ - 'docs/**'+ - '**/*.md'+ - '**/*.mdx'# 确保同一 PR 同一时间只运行一个相同的 workflow,取消正在进行的旧的运行concurrency:@@ -54,6 +59,63 @@ jobs:run: bun run type-checkworking-directory: apps/desktop+ # 业务 overlay 与当前源码一起做类型检查:bundle 不做类型检查,overlay 仍在读取+ # 本仓库已删除的 API 时会一路构建发布,到运行时才失败。+ # 这个 job 不跟随 trigger:build-desktop 标签,普通 PR 也要检查。+ overlay-type-check:+ name: Overlay type check+ runs-on: ubuntu-latest+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@v7+ with:+ fetch-depth: 2++ - name: Create overlay token+ id: overlay-token+ uses: ./.github/actions/overlay-token+ with:+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}+ repository: ${{ vars.OVERLAY_REPOSITORY }}++ - name: Type check this pull request with the overlay+ id: head+ if: steps.overlay-token.outputs.token != ''+ continue-on-error: true+ uses: ./.github/actions/overlay-type-check+ with:+ log-name: head.log+ node-version: 24.11.1+ overlay-repository: ${{ vars.OVERLAY_REPOSITORY }}+ overlay-token: ${{ steps.overlay-token.outputs.token }}++ # The overlay follows this branch with a delay, so the base can already fail+ # for reasons this pull request did not cause; only errors it adds count.+ - name: Check out the base with this pull request's workflow tooling+ if: steps.head.outcome == 'failure'+ run: |+ set -euo pipefail+ head_sha="$(git rev-parse HEAD)"+ git checkout --force --detach HEAD^1+ git checkout "$head_sha" -- .github++ - name: Type check the base with the same overlay+ if: steps.head.outcome == 'failure'+ continue-on-error: true+ uses: ./.github/actions/overlay-type-check+ with:+ log-name: base.log+ node-version: 24.11.1+ overlay-ref: ${{ env.OVERLAY_REF }}+ overlay-repository: ${{ vars.OVERLAY_REPOSITORY }}+ overlay-token: ${{ steps.overlay-token.outputs.token }}++ - name: Fail on type errors this pull request introduces+ if: steps.head.outcome == 'failure'+ run: node .github/scripts/overlayTypeErrors.mjs "$RUNNER_TEMP/base.log" "$RUNNER_TEMP/head.log"+version:name: Determine version# 与 test job 相同的触发条件