From d9cee7e63f0a36e1ba5f2af1d56b1970512c0985 Mon Sep 17 00:00:00 2001 From: MyPrototypeWhat <43230886+MyPrototypeWhat@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:56:25 +0800 Subject: [PATCH 1/3] ci: add per-plugin test workflow for changed plugins Add .github/workflows/plugin-tests.yml, which runs on pull_request for plugins/** changes, detects changed plugins// dirs that define scripts.test, and runs npm test in each via a matrix (Node 22, read-only permissions). Document plugin test conventions in CONTRIBUTING.md and CONTRIBUTING.zh-CN.md. --- .github/workflows/plugin-tests.yml | 89 ++++++++++++++++++++++++++++++ CONTRIBUTING.md | 9 +++ CONTRIBUTING.zh-CN.md | 9 +++ 3 files changed, 107 insertions(+) create mode 100644 .github/workflows/plugin-tests.yml diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml new file mode 100644 index 00000000..4490e070 --- /dev/null +++ b/.github/workflows/plugin-tests.yml @@ -0,0 +1,89 @@ +name: Plugin tests + +on: + pull_request: + paths: + - 'plugins/**' + +permissions: + contents: read + +concurrency: + group: plugin-tests-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + detect: + name: detect changed plugins + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + dirs: ${{ steps.detect.outputs.dirs }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - id: detect + name: List changed plugins with a test script + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + set -euo pipefail + git diff --name-only -z "$BASE_SHA...$HEAD_SHA" -- plugins/ \ + | node -e ' + const fs = require("fs"); + const path = require("path"); + const files = fs.readFileSync(0, "utf8").split("\0").filter(Boolean); + const dirs = new Set(); + for (const f of files) { + const p = f.split("/"); + if (p.length >= 4 && p[0] === "plugins" && p[1] && p[2]) dirs.add(`plugins/${p[1]}/${p[2]}`); + } + const out = []; + for (const d of [...dirs].sort()) { + const pkg = path.join(d, "package.json"); + try { + if (!fs.statSync(d).isDirectory()) continue; + const j = JSON.parse(fs.readFileSync(pkg, "utf8")); + if (j && j.scripts && typeof j.scripts.test === "string" && j.scripts.test.trim()) out.push(d); + } catch { /* missing dir or package.json, or invalid JSON: skip */ } + } + process.stdout.write(JSON.stringify(out)); + ' > dirs.json + echo "Plugins to test: $(cat dirs.json)" + echo "dirs=$(cat dirs.json)" >> "$GITHUB_OUTPUT" + + test: + name: test (${{ matrix.dir }}) + needs: detect + if: needs.detect.outputs.dirs != '' && needs.detect.outputs.dirs != '[]' + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + dir: ${{ fromJSON(needs.detect.outputs.dirs) }} + defaults: + run: + working-directory: ${{ matrix.dir }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 22 + - name: Install plugin dependencies + run: | + set -euo pipefail + if [ -f package-lock.json ]; then + npm ci --no-audit --no-fund + elif node -e 'const p=require("./package.json"); process.exit(Object.keys({...p.dependencies, ...p.devDependencies}).length ? 0 : 1)'; then + npm install --no-audit --no-fund + else + echo "No dependencies declared; skipping install." + fi + - name: npm test + run: npm test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27d282cc..08ebf370 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,4 +16,13 @@ Submit ready-to-run files. If the app requires a build step, include its source Before submitting, install the app in MiniMax Code, open it, and check its main features. Include your test environment and results in the pull request, and state any unverified behavior. When updating an existing app, keep its plugin ID and update the version and usage instructions as appropriate. +## Plugin tests + +Tests for a plugin are optional and live inside the plugin's own directory (for example `plugins///test/`). They run through the `test` script in the plugin's `package.json`, i.e. `npm test` from the plugin directory. + +- Tests must not use the network and must not depend on the MiniMax Code host app. +- Install any dependencies only inside the plugin directory (commit a `package-lock.json` if you have dependencies); never add them to the root `package.json`. +- The root `test/` directory is reserved for repository-wide Mini App rule checks. It must not import or run plugin tests. +- The `Plugin tests` workflow runs only for plugins changed by a pull request, separately from the rules CI (`npm run check`). CI uses Node.js 22. + Working with an AI coding agent? It reads `AGENTS.md` automatically; `docs/` holds the same rules for people. diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md index 8487a003..e089b40b 100644 --- a/CONTRIBUTING.zh-CN.md +++ b/CONTRIBUTING.zh-CN.md @@ -16,4 +16,13 @@ 提交前在 MiniMax Code 中手动安装、打开并检查主要功能,在 PR 中写明测试环境和结果;未验证的部分如实说明。更新已有作品时,保留插件 ID,并按改动更新版本与使用说明。 +## 插件测试 + +插件测试是可选的,放在插件自己的目录里(例如 `plugins///test/`),通过插件 `package.json` 中的 `test` 脚本运行,即在插件目录下执行 `npm test`。 + +- 测试不得访问网络,也不得依赖 MiniMax Code 宿主应用。 +- 依赖只安装在插件目录内(有依赖时请提交 `package-lock.json`),不要加到根目录 `package.json`。 +- 根目录 `test/` 只用于仓库级的 MiniApp 规则检查,不得引用或运行插件测试。 +- `Plugin tests` 工作流只针对 PR 改动到的插件运行,与规则 CI(`npm run check`)相互独立。CI 使用 Node.js 22。 + 使用 AI 编码助手时,它会自动读取 `AGENTS.md`;`docs/` 里是同一套规则的人类可读版本。 From 35dcd5e082c2947005bfa6e93cb51c58be660302 Mon Sep 17 00:00:00 2001 From: dazhi Date: Tue, 27 Oct 2026 14:11:50 +0800 Subject: [PATCH 2/3] ci(plugin-tests): diff the merge commit, document local node_modules, and tell agents about plugin tests Review follow-up on the per-plugin test workflow: - detect: check out the PR merge commit with fetch-depth 2 and diff it against its first parent, instead of cloning the full history (108 MiB and growing) to diff base...head. - CONTRIBUTING (en/zh): use the repository's tests/ convention in the example, allow servers the test starts on 127.0.0.1 (only external hosts are off-limits), and say to delete the plugin's node_modules before npm run check, which rejects any node_modules inside a package. - AGENTS.md: add the plugin-test step, since agents read AGENTS.md rather than CONTRIBUTING. Assisted-by: Claude Opus 5.5 (OpenCode) --- .github/workflows/plugin-tests.yml | 8 +++----- AGENTS.md | 7 ++++++- CONTRIBUTING.md | 6 +++--- CONTRIBUTING.zh-CN.md | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index 4490e070..d600adda 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -22,16 +22,14 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - fetch-depth: 0 + # The pull_request checkout is the PR's merge commit; its first parent is the base. + fetch-depth: 2 persist-credentials: false - id: detect name: List changed plugins with a test script - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | set -euo pipefail - git diff --name-only -z "$BASE_SHA...$HEAD_SHA" -- plugins/ \ + git diff --name-only -z HEAD^1 HEAD -- plugins/ \ | node -e ' const fs = require("fs"); const path = require("path"); diff --git a/AGENTS.md b/AGENTS.md index e15047bf..2c6ca48a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,7 +24,12 @@ package at `plugins///`; the rest change the checks (`docs/package-contract.md`), name a MiniMax Code version at or above it under `## Tested environment`. 4. Add one row to the table in both root READMEs. -5. Run `npm run check`. Done when it reports no errors and every warning is either fixed or +5. Tests are optional. Put them in the package directory (for example `tests/`) and run them + through `scripts.test` in the package's `package.json`; the Plugin tests workflow runs `npm test` + there when a pull request changes the package. Keep them off external hosts (loopback is fine), + install dependencies only inside the package with a committed `package-lock.json`, and delete + that `node_modules` before the next step. +6. Run `npm run check`. Done when it reports no errors and every warning is either fixed or explained in the PR description. ## Hard rules diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 08ebf370..ef894040 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,10 +18,10 @@ Before submitting, install the app in MiniMax Code, open it, and check its main ## Plugin tests -Tests for a plugin are optional and live inside the plugin's own directory (for example `plugins///test/`). They run through the `test` script in the plugin's `package.json`, i.e. `npm test` from the plugin directory. +Tests for a plugin are optional and live inside the plugin's own directory (for example `plugins///tests/`). They run through the `test` script in the plugin's `package.json`, i.e. `npm test` from the plugin directory. -- Tests must not use the network and must not depend on the MiniMax Code host app. -- Install any dependencies only inside the plugin directory (commit a `package-lock.json` if you have dependencies); never add them to the root `package.json`. +- Tests must not reach external network hosts and must not depend on the MiniMax Code host app. A server the test starts on `127.0.0.1` is fine. +- Install any dependencies only inside the plugin directory (commit a `package-lock.json` if you have dependencies); never add them to the root `package.json`. Delete the plugin's `node_modules` before running `npm run check`: the check rejects any `node_modules` directory inside a package, ignored by Git or not. - The root `test/` directory is reserved for repository-wide Mini App rule checks. It must not import or run plugin tests. - The `Plugin tests` workflow runs only for plugins changed by a pull request, separately from the rules CI (`npm run check`). CI uses Node.js 22. diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md index e089b40b..cefd42ca 100644 --- a/CONTRIBUTING.zh-CN.md +++ b/CONTRIBUTING.zh-CN.md @@ -18,10 +18,10 @@ ## 插件测试 -插件测试是可选的,放在插件自己的目录里(例如 `plugins///test/`),通过插件 `package.json` 中的 `test` 脚本运行,即在插件目录下执行 `npm test`。 +插件测试是可选的,放在插件自己的目录里(例如 `plugins///tests/`),通过插件 `package.json` 中的 `test` 脚本运行,即在插件目录下执行 `npm test`。 -- 测试不得访问网络,也不得依赖 MiniMax Code 宿主应用。 -- 依赖只安装在插件目录内(有依赖时请提交 `package-lock.json`),不要加到根目录 `package.json`。 +- 测试不得访问外部网络,也不得依赖 MiniMax Code 宿主应用;测试自己在 `127.0.0.1` 上启动的服务不受限制。 +- 依赖只安装在插件目录内(有依赖时请提交 `package-lock.json`),不要加到根目录 `package.json`。运行 `npm run check` 前请删除插件目录里的 `node_modules`:无论是否被 Git 忽略,规则检查都会拒绝包内的 `node_modules` 目录。 - 根目录 `test/` 只用于仓库级的 MiniApp 规则检查,不得引用或运行插件测试。 - `Plugin tests` 工作流只针对 PR 改动到的插件运行,与规则 CI(`npm run check`)相互独立。CI 使用 Node.js 22。 From ab3274abb06a4dbc9d1686e37e41a6c5e96d98aa Mon Sep 17 00:00:00 2001 From: dazhi Date: Tue, 27 Oct 2026 14:47:00 +0800 Subject: [PATCH 3/3] ci(plugin-tests): run plugin tests on macOS and state the test environment A trial run (#88) on ubuntu-latest failed disk-insight's scanner tests, which assume macOS and Windows filesystem behaviour; on macos-latest they pass. MiniMax Code runs only on macOS and Windows, so the test job now runs on macOS (detection stays on Linux). The runner provides Node.js 22 and Git only. CONTRIBUTING (en/zh) and AGENTS.md now say so, and that a test needing another tool, such as FFmpeg or a browser, must skip itself when the tool is missing. cutline's FFmpeg-based tests fail on both runners until they do. Assisted-by: Claude Opus 5.5 (OpenCode) --- .github/workflows/plugin-tests.yml | 3 ++- AGENTS.md | 3 ++- CONTRIBUTING.md | 2 +- CONTRIBUTING.zh-CN.md | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index d600adda..8d02a69d 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -57,7 +57,8 @@ jobs: name: test (${{ matrix.dir }}) needs: detect if: needs.detect.outputs.dirs != '' && needs.detect.outputs.dirs != '[]' - runs-on: ubuntu-latest + # MiniMax Code runs on macOS and Windows, so plugin tests run where the app runs. + runs-on: macos-latest timeout-minutes: 10 strategy: fail-fast: false diff --git a/AGENTS.md b/AGENTS.md index 2c6ca48a..559f6b03 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,8 @@ package at `plugins///`; the rest change the checks 4. Add one row to the table in both root READMEs. 5. Tests are optional. Put them in the package directory (for example `tests/`) and run them through `scripts.test` in the package's `package.json`; the Plugin tests workflow runs `npm test` - there when a pull request changes the package. Keep them off external hosts (loopback is fine), + there, on macOS with Node.js 22 and Git only, when a pull request changes the package. Skip a test + when a tool it needs, such as FFmpeg, is missing. Keep them off external hosts (loopback is fine), install dependencies only inside the package with a committed `package-lock.json`, and delete that `node_modules` before the next step. 6. Run `npm run check`. Done when it reports no errors and every warning is either fixed or diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef894040..82ab7efd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,6 @@ Tests for a plugin are optional and live inside the plugin's own directory (for - Tests must not reach external network hosts and must not depend on the MiniMax Code host app. A server the test starts on `127.0.0.1` is fine. - Install any dependencies only inside the plugin directory (commit a `package-lock.json` if you have dependencies); never add them to the root `package.json`. Delete the plugin's `node_modules` before running `npm run check`: the check rejects any `node_modules` directory inside a package, ignored by Git or not. - The root `test/` directory is reserved for repository-wide Mini App rule checks. It must not import or run plugin tests. -- The `Plugin tests` workflow runs only for plugins changed by a pull request, separately from the rules CI (`npm run check`). CI uses Node.js 22. +- The `Plugin tests` workflow runs only for plugins changed by a pull request, separately from the rules CI (`npm run check`). It runs on macOS with Node.js 22 and Git and nothing else: a test that needs another tool, such as FFmpeg or a browser, must skip itself when the tool is missing. Working with an AI coding agent? It reads `AGENTS.md` automatically; `docs/` holds the same rules for people. diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md index cefd42ca..92349ee7 100644 --- a/CONTRIBUTING.zh-CN.md +++ b/CONTRIBUTING.zh-CN.md @@ -23,6 +23,6 @@ - 测试不得访问外部网络,也不得依赖 MiniMax Code 宿主应用;测试自己在 `127.0.0.1` 上启动的服务不受限制。 - 依赖只安装在插件目录内(有依赖时请提交 `package-lock.json`),不要加到根目录 `package.json`。运行 `npm run check` 前请删除插件目录里的 `node_modules`:无论是否被 Git 忽略,规则检查都会拒绝包内的 `node_modules` 目录。 - 根目录 `test/` 只用于仓库级的 MiniApp 规则检查,不得引用或运行插件测试。 -- `Plugin tests` 工作流只针对 PR 改动到的插件运行,与规则 CI(`npm run check`)相互独立。CI 使用 Node.js 22。 +- `Plugin tests` 工作流只针对 PR 改动到的插件运行,与规则 CI(`npm run check`)相互独立。CI 运行在 macOS 上,只提供 Node.js 22 和 Git:需要其他工具(如 FFmpeg 或浏览器)的测试,在工具缺失时必须自行跳过。 使用 AI 编码助手时,它会自动读取 `AGENTS.md`;`docs/` 里是同一套规则的人类可读版本。