name: CI on: push: branches: [master, main] pull_request: branches: [master, main] workflow_dispatch: permissions: contents: read # 同一分支上连续推送时,取消尚未完成的旧运行,省掉排队等待 concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: test: name: Node ${{ matrix.node }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: # 22.19 是 package.json engines 的下限,24 是 DSH 桌面端内置的运行时 node: ['22.19', '24'] steps: - uses: actions/checkout@v4 # 注意:本仓库有意不提交 lockfile。插件对两个宿主包的声明是不同的: # - @deepseek-ai/cordis → 只在 peerDependencies,由宿主提供(插件不打包它); # - @deepseek-ai/schemastery → dependencies + peerDependencies 双声明, # 因为 lib/index.js 直接 import 它,而宿主**不会**把它注入插件的模块 # 解析链(与 @deepseek-ai/dsh-tools 同款问题),所以必须能被装上。 # CI 因此用 install 而不是 ci(ci 要求 lockfile 存在), # 也因此 setup-node 不能开 cache: npm(它要求 lockfile 才能算缓存键)。 # 代价:每次跑 CI 都会解析到 schemastery ^3.18.1 的最新版,构建不可复现。 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Install dependencies run: npm install --ignore-scripts --no-audit --no-fund # 快速语法体检:覆盖宿主页与浏览器页,挡住 lib/client.js 这类非 Node 入口的低级错误 - name: Syntax check run: npm run check - name: Test run: npm test # 文档里的数字(测试项数、lib 文件数)会随开发漂移,人工回改必然漏 # (本项目漏过 4 处)。这一步让漂移在 CI 里变成红灯;本地用 `npm run fix:docs` 自动改写。 - name: Verify documented numbers run: npm run verify:docs publish-dry-run: name: Publish dry run runs-on: ubuntu-latest needs: test steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '24' - name: Install dependencies run: npm install --ignore-scripts --no-audit --no-fund # 确认 package.json 的 files / exports 真的能打出可用产物, # 并列出将要发布的文件,避免误带 node_modules 或漏掉 lib/client.js - name: npm pack dry run run: npm pack --dry-run