### ABI 1.5 - VDE_PLUGIN_ABI_MINOR 5;VdePluginKind OPTIMIZER=9/IO_BATCH=10; VdeOptimizer*/VdeIoBatch* 结构(JSON 输入输出回调);VdePluginRegistration 尾追加两指针 56→72B(offset 56/64), 旧 1.0–1.4 按 struct_size 安全加载、新 kind 结构不足拒绝; - PluginManager:OptimizerInfo/IoBatchInfo、optimizers()/invoke_optimizer、io_batches()/invoke_io_batch、 校验/失败隔离/卸载清理(IO_BATCH 支持 PARTIAL); - sample_optimizer/sample_io_batch(mock);ABI 矩阵 1.0–1.5 accepted=6+2.0 rejected;--abi/--check 适配; - test_plugin_abi15 6/6 + fixtures;既有 ABI 1.4 断言适配; - 文档 plugin-development §16/§17、plugin-distribution ABI 矩阵、plugin-ecosystem-handoff/ecosystem、plugin-ci-template; ### WP/claim - WP-P4-11 交付并移入 Delivered;claim Released 归档;统计 42=31 Delivered+11 Candidate; - claim check 修正:Released claim 可指向 Delivered WP(仅 Active 需要释放); ### 工程 - 版本 1.0.83;全量构建 0 error(421 targets);全量 ctest 7576 注册、7481/7481 PASS(0 failed,25 skipped,302.66s); - 收录 1.0.82 独立验证报告 80。
18 KiB
插件开发 CI 模板与 ABI 兼容矩阵(P3-12c)
目标:给“VDE 插件仓库”一套可直接复制的 CI 方案,覆盖 build → test/--check → 签名 → --build-index → --verify-index → 安装冒烟 → ABI 1.0–1.5 矩阵, 以及发布失败即阻断(fail-closed)的门禁。
对应路线图:P3-12「插件开发 CI 模板与兼容矩阵(内核 1.x × ABI 1.0–1.5)」;当前主线 ABI 1.5(optimizer/io_batch)。 配套阅读:plugin-publishing.md(发布流程)、 plugin-development.md(模板/scaffold/
--check)、 plugin-distribution.md(索引/签名/安装命令)。版本基线:VDE 1.0.70+(宿主插件 ABI 1.5);仓库内
.github/workflows/ci.yml是内核主仓库 CI, 本文模板面向插件发布者仓库(可独立/内嵌使用)。
1. 两种使用场景
| 场景 | 仓库形态 | 建议模板 |
|---|---|---|
| A. 独立插件仓库 | 只含插件源码(scaffold 生成或手写)+ 自己的 CMakeLists | §3 GitHub Actions 模板 A(推荐;SDK/工具由 VDE 发布物提供) |
| B. VDE monorepo 内插件 | plugins/<name>/ 子目录,随主仓库构建 |
§4 GitHub Actions 模板 B(构建 vde_plugin_tool、插件 ABI 矩阵、ctest 过滤) |
插件只依赖纯 C ABI 头
include/vde/plugin/vde_plugin_api.h;CI 需要两样东西: SDK 头目录(VDE_SDK_DIR)与vde_plugin_tool可执行文件(同一 VDE 版本)。 工具需默认全量构建(vde_licenseON 才有 Ed25519 签名/验签能力;-DVDE_BUILD_PLUGIN=OFF时工具不构建)。
2. 最小本地流水线(先本地跑通,再放进 CI)
# 0) 前置:VDE SDK 头 + vde_plugin_tool(同一版本)
VDE_SDK_DIR=/opt/vde # 或 VDE 源码根
TOOL=/opt/vde/bin/vde_plugin_tool
# 1) 构建(插件工程自身 CMake;产物在 <build>/plugin/)
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DVDE_SDK_DIR="$VDE_SDK_DIR"
cmake --build build
# 2) 自检(对构建产物目录,不是源码目录)
"$TOOL" --abi
"$TOOL" --check build/plugin
"$TOOL" --list build/plugin
# 3) 打包(示例:单插件包目录)
mkdir -p repo/packages/com.acme.widget
cp build/plugin/vde-plugin.json build/plugin/*.so repo/packages/com.acme.widget/ # Windows 用 *.dll
# 4) 测试签名密钥(仅 CI/开发;生产用离线签名)
"$TOOL" --gen-keypair --out-dir .ci/keys
"$TOOL" --build-index repo/packages -o repo/index.json \
--sign .ci/keys/plugin_signing.key --key-id ci-test --publisher "Acme CI"
"$TOOL" --verify-index repo/index.json --pubkey .ci/keys/plugin_signing.pub
# 5) 安装冒烟(干净目录)
"$TOOL" --install repo/index.json --dest .ci/install --id com.acme.widget \
--pubkey .ci/keys/plugin_signing.pub
"$TOOL" --check .ci/install/com.acme.widget
# 6) 负例门禁(任一必须失败,退出码 3/4)
printf x >> repo/packages/com.acme.widget/*.so # 篡改 artifact
"$TOOL" --verify-index repo/index.json --pubkey .ci/keys/plugin_signing.pub && exit 1
Windows PowerShell 版本把 cp/mkdir 换成 Copy-Item/New-Item,其余参数一致;工具名为 vde_plugin_tool.exe。
3. GitHub Actions 模板 A:独立插件仓库
复制为插件仓库的
.github/workflows/plugin-ci.yml。占位符:VDE_SDK_DOWNLOAD_URL/VDE_TOOL_DOWNLOAD_URL(内部发布物;或改为 checkout VDE 源码后构建工具), 以及插件 idcom.acme.widget。CI 只用临时测试密钥,生产签名见 §5。
name: Plugin CI
on:
push:
branches: [main, master, "release/*"]
pull_request:
jobs:
build-check-matrix:
name: ${{ matrix.os }} - plugin ABI 1.${{ matrix.abi_minor }} build
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-2022]
# 同一源码用 ABI override 编出 1.0/1.1/1.2/1.3/1.4/1.5 六个 DLL,验证向后兼容性;
# 发布产物默认只发布清单声明的主 ABI(模板为 1.5)。
abi_minor: [0, 1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4
- name: Fetch VDE SDK + tool (pinned release)
shell: bash
run: |
curl -fsSL "$VDE_SDK_DOWNLOAD_URL" -o sdk.tar.gz
mkdir -p vde
tar -xzf sdk.tar.gz -C vde --strip-components=1
echo "VDE_SDK_DIR=$PWD/vde" >> "$GITHUB_ENV"
echo "VDE_PLUGIN_TOOL=$PWD/vde/bin/vde_plugin_tool" >> "$GITHUB_ENV"
env:
VDE_SDK_DOWNLOAD_URL: ${{ secrets.VDE_SDK_DOWNLOAD_URL }}
- name: Build plugin (ABI 1.${{ matrix.abi_minor }})
shell: bash
run: |
# 模板 CMake 不声明 ABI override 选项:用 CMAKE_CXX_FLAGS 注入编译宏,
# 随后把构建产物清单的 abi.minor 对齐(--check 要求清单与 query 一致)。
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DVDE_SDK_DIR="$VDE_SDK_DIR" \
-DCMAKE_CXX_FLAGS="-DVDE_PLUGIN_ABI_MINOR_OVERRIDE=${{ matrix.abi_minor }}"
cmake --build build
- name: Align manifest ABI for matrix
shell: bash
env:
ABI_MINOR: ${{ matrix.abi_minor }}
run: |
python3 - <<PY
import json, os
path = "build/plugin/vde-plugin.json"
with open(path, encoding="utf-8") as f:
manifest = json.load(f)
manifest["abi"]["minor"] = int(os.environ["ABI_MINOR"])
with open(path, "w", encoding="utf-8") as f:
json.dump(manifest, f, indent=2, ensure_ascii=False)
PY
- name: Self-check (manifest / query / ABI)
shell: bash
run: |
"$VDE_PLUGIN_TOOL" --abi | tee abi-${{ matrix.os }}-${{ matrix.abi_minor }}.txt
"$VDE_PLUGIN_TOOL" --check build/plugin
"$VDE_PLUGIN_TOOL" --list build/plugin
- name: Upload plugin artifact
uses: actions/upload-artifact@v4
with:
name: plugin-${{ matrix.os }}-abi1.${{ matrix.abi_minor }}
path: build/plugin/**
package-sign-index:
name: Package - sign - index - verify - install smoke
runs-on: ubuntu-22.04
timeout-minutes: 20
needs: build-check-matrix
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: plugin-ubuntu-22.04-abi1.5
path: plugin
# 工具:可复用上面 sdk artifact,或单独下载 pin 版本(示例从 secrets URL 获取)
- name: Fetch VDE tool
shell: bash
run: |
curl -fsSL "$VDE_TOOL_DOWNLOAD_URL" -o tool.tar.gz
mkdir -p vde
tar -xzf tool.tar.gz -C vde --strip-components=1
echo "VDE_PLUGIN_TOOL=$PWD/vde/vde_plugin_tool" >> "$GITHUB_ENV"
env:
VDE_TOOL_DOWNLOAD_URL: ${{ secrets.VDE_TOOL_DOWNLOAD_URL }}
- name: Package layout
shell: bash
run: |
mkdir -p repo/packages/com.acme.widget
cp plugin/* repo/packages/com.acme.widget/
- name: Dev test key + signed index
shell: bash
run: |
"$VDE_PLUGIN_TOOL" --gen-keypair --out-dir .ci/keys
"$VDE_PLUGIN_TOOL" --build-index repo/packages -o repo/index.json \
--sign .ci/keys/plugin_signing.key \
--key-id ci-${{ github.run_id }} --publisher "Acme CI"
"$VDE_PLUGIN_TOOL" --verify-index repo/index.json \
--pubkey .ci/keys/plugin_signing.pub
- name: Install smoke
shell: bash
run: |
"$VDE_PLUGIN_TOOL" --install repo/index.json --dest .ci/install \
--id com.acme.widget --pubkey .ci/keys/plugin_signing.pub
"$VDE_PLUGIN_TOOL" --check .ci/install/com.acme.widget
test -f .ci/install/com.acme.widget/vde-plugin.json
- name: Negative gate (must fail)
shell: bash
run: |
set +e
printf x >> repo/packages/com.acme.widget/*.so
"$VDE_PLUGIN_TOOL" --verify-index repo/index.json \
--pubkey .ci/keys/plugin_signing.pub
rc=$?
test "$rc" -eq 3 || { echo "expected rc=3 on tampered artifact, got $rc"; exit 1; }
# 未签名索引必须被拒绝(无 --allow-unsigned),退出码 3
"$VDE_PLUGIN_TOOL" --build-index repo/packages -o repo/index.unsigned.json
"$VDE_PLUGIN_TOOL" --verify-index repo/index.unsigned.json \
--pubkey .ci/keys/plugin_signing.pub
rc=$?
test "$rc" -eq 3 || { echo "expected rc=3 on unsigned index, got $rc"; exit 1; }
# 吊销列表命中:key_id 在 --revoked-keys 中必须被拒绝(rc=3)
printf 'ci-%s\n' "${{ github.run_id }}" > .ci/revoked.txt
"$VDE_PLUGIN_TOOL" --verify-index repo/index.json \
--pubkey .ci/keys/plugin_signing.pub --revoked-keys .ci/revoked.txt
rc=$?
test "$rc" -eq 3 || { echo "expected rc=3 on revoked key, got $rc"; exit 1; }
- name: Upload repo (index + packages, CI test signing only)
uses: actions/upload-artifact@v4
with:
name: plugin-repo-ci
path: repo/**
生产发布不要在 PR/普通 push 上用生产密钥。生产签名作业建议:受保护分支 + environment 审批 + 离线签名机或 KMS/HSM;CI 仅构建/自检,签名由受控作业对已通过 CI 的同一 artifact 执行(见 §5)。
4. GitHub Actions 模板 B:VDE monorepo 插件 job
适用于在本仓库
plugins/<name>/维护插件。内核 CI(.github/workflows/ci.yml)之外, 单独加一个插件门禁 job(或作为子步骤),使用插件管理器/工具/ABI 矩阵测试:
plugin-gate:
name: Plugin SDK templates - tool - ABI matrix
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install deps
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libeigen3-dev
- name: Configure
run: |
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=ON -DBUILD_BENCHMARKS=OFF -DBUILD_EXAMPLES=OFF \
-DVDE_BUILD_PLUGIN=ON -DVDE_BUILD_LICENSE=ON \
-DVDE_BUILD_ABI_MATRIX_TESTS=ON
- name: Build plugin manager + tool + ABI matrix
run: |
cmake --build build --target vde_plugin vde_plugin_tool vde_plugin_abi_matrix --parallel $(nproc)
- name: Tool self-diagnostics
run: |
./build/tools/vde_plugin_tool --abi
- name: Plugin tests + scaffold smoke + ABI matrix
working-directory: build
run: |
ctest --output-on-failure -j $(nproc) --timeout 300 \
-R "VDE_PluginToolScaffoldSmoke|test_plugin_(manager|integration|security|extensions|gcs)"
# ABI 兼容矩阵(宿主 ABI 1.5 接受插件 1.0–1.5、拒绝 2.0)
if [ -x ./plugins/abi_matrix/vde_plugin_abi_matrix ]; then
./plugins/abi_matrix/vde_plugin_abi_matrix
else
echo "vde_plugin_abi_matrix not found; check VDE_BUILD_ABI_MATRIX_TESTS"; exit 1
fi
- name: Build each plugin template independently
run: |
for kind in format_plugin cae_solver cam_strategy gcs_solver; do
cmake -S "plugins/templates/$kind" -B "build/template_$kind" -G Ninja \
-DCMAKE_BUILD_TYPE=Release -DVDE_SDK_DIR="$PWD"
cmake --build "build/template_$kind"
./build/tools/vde_plugin_tool --check "build/template_$kind/plugin"
done
要点:
-DBUILD_TESTS=ON -DVDE_BUILD_PLUGIN=ON -DVDE_BUILD_LICENSE=ON同时产出vde_plugin_tool(签名/验签) 与vde_plugin_abi_matrix(真实宿主 + 4 个 ABI DLL + 2.0 拒绝用例);VDE_PluginToolScaffoldSmoke覆盖四类 scaffold → 独立 configure/build →--check/--list+ 负例;- 模板独立构建不进入默认构建(
plugins/templates/*各自 CMakeLists),CI 中显式循环构建; - 若插件包也在仓库内(
plugins/official/*、示例插件),可复用--list <build>/plugins做发现回归。
5. 签名密钥与 CI 安全
| 用途 | 密钥 | 说明 |
|---|---|---|
| PR/日常 CI | 临时密钥(--gen-keypair,作业结束丢弃) |
只验证流水线闭环;不入库、不写入制品说明 |
| 预发布/生产 | 离线/受控密钥(KMS/HSM/签名机) | 仅对通过 CI 的同一 artifact 签名;key_id 固定可审计 |
- 签名/索引构建步骤不要接受来自 PR 的代码变更后直接使用生产 seed;
- 推荐流程:CI 产出
repo/(unsigned,含校验通过标记)→ 受保护分支/environment 审批 → 签名作业 对 artifact 哈希做二次校验后--build-index --sign→ 上传发布物; - 发布物(index.json + packages)与
key_id/公钥指纹/SHA-256 一起归档;旧版本与旧索引保留; - 密钥轮换:新
key_id签新索引;宿主trusted_keys同时保留新旧;旧 key 加入revoked_key_ids; - 吊销:宿主策略
revoked_key_ids优先于受信表;工具侧--verify-index/--install/--upgrade支持--revoked-keys <file>(每行 key_id 或 JSON)做部署侧强制;不传则不检查,发布者需在发布说明/宿主 配置中同步吊销信息(吊销文件本身应与发布说明一起审计)。
6. ABI 兼容矩阵(内核 1.x × 插件 ABI 1.0–1.5)
接受规则:plugin.abi.major == host.abi.major 且 plugin.abi.minor <= host.abi.minor。
| 宿主 ABI \ 插件 ABI | 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 2.0 |
|---|---|---|---|---|---|---|---|
| 1.1 | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 1.2 | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| 1.3 | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
| 1.4 | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
| 1.5(当前主线) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
内核版本对照(发布验证时用目标内核版本自带的 vde_plugin_tool --abi 记录基线):
| VDE 内核版本 | 宿主插件 ABI | 可接受的插件声明 |
|---|---|---|
| 1.0.79+(P4,ABI 1.4/1.5 已交付) | 1.5(部分版本 1.4) | 以该版本 --abi 为准;1.5 宿主接受 1.0–1.5 |
| 1.0.70–1.0.77 | 1.3 | 1.0 / 1.1 / 1.2 / 1.3;拒绝 2.0 |
| 旧内核(P1/P2 阶段,如 1.0.6x) | 以该版本 --abi 输出为准(1.1/1.2 随版本推进) |
仅接受 minor 不超过宿主的插件;1.3+ 插件需新宿主 |
| 更早(P0) | 1.0 | 仅 1.0 |
CI 矩阵实现方式:
- 同一源码 × ABI 声明:
-DVDE_PLUGIN_ABI_MINOR_OVERRIDE=0|1|2|3|4|5编出 1.0–1.5 六份真实 DLL(模板 A 已给矩阵; 模板工程需同时把构建产物清单abi.minor对齐到该值,否则--check会报清单/query 不一致);--check使用目标宿主工具验证兼容性; - 宿主 × 插件矩阵(可选):CI 取多个 VDE 版本的工具(各自
--abi),对同一插件包跑--check; 验证“旧宿主拒绝新 minor 插件、新宿主接受旧 minor 插件”; - 负例:清单声明
{ "major": 2, "minor": 0 }必须被拒绝(--check退出码 3;宿主加载前拒绝); monorepo 可用plugins/abi_matrix(宿主 1.5 接受 1.0–1.5 + 2.0 拒绝)作为真实宿主回归; - 发布物 ABI 策略:默认只发布清单声明的主 ABI(模板 1.5);若需兼容旧宿主,按目标宿主 ABI 分别发布
构建并用不同
key_id/索引条目(或同索引多版本)管理。
7. 缓存、并行与失败处理
- 缓存:CMake/Ninja 构建目录、VDE SDK/工具下载可缓存(按 VDE 版本+平台 key);不要缓存签名密钥;
- 矩阵裁剪:PR 只跑
ubuntu + 发布 ABI与负例;夜间/发布分支跑全 OS × ABI 矩阵; fail-fast: false保留矩阵全貌;任何--check/--verify-index非 0 必须 fail job;- 上传 artifact 用
if: always()保留失败现场(日志/--abi输出/索引); - Windows runner 注意 DLL 命名(无
lib前缀)与路径大小写;Linux 产物lib*.so与清单entry.linux一致。
8. 常见 CI 问题
| 现象 | 排查 |
|---|---|
vde_plugin_tool 不存在 |
配置需 -DVDE_BUILD_PLUGIN=ON(默认 ON);安装包需 VDE_INSTALL=ON;VDE_BUILD_LICENSE=OFF 时工具无 Ed25519(签名/验签退出码 4) |
| 签名/验签退出码 4 | 工具未链接 vde_license,或没提供 --pubkey;用默认全量构建/补公钥 |
--check 失败退出码 3 |
清单/query/ABI/artifacts 不一致;先 --inspect/--abi,注意对 build/plugin 目录执行 |
| GitHub Windows job 下载 SDK 失败 | Windows runner 用 PowerShell;curl 在 Windows runner 可用,但路径/解压用 Expand-Archive 更稳(可按 §3 改 shell: pwsh) |
| 在线 fetch 在 Linux/macOS 失败 | 当前 http(s) 获取仅 Windows(WinHTTP);CI 中用本地 file:///离线镜像,或宿主侧下载后再本地索引 |
ABI 矩阵 job 找不到 vde_plugin_abi_matrix |
未开 -DVDE_BUILD_ABI_MATRIX_TESTS=ON 或未指定 target;检查构建目录 plugins/abi_matrix/ |
9. 验收清单(复制到 PR 模板)
[ ] 四类模板/插件目标独立构建 0 error;plugins/templates 未被默认构建打包(如适用)
[ ] vde_plugin_tool --check 通过;--abi 基线记录进 CI 日志
[ ] ABI 1.0 / 1.1 / 1.2 / 1.3 / 1.4 / 1.5 构建矩阵通过;2.0 负例被拒
[ ] --build-index --sign 后 --verify-index --pubkey 通过;unsigned 负例被拒
[ ] 篡改 artifact / 坏签名 / 路径逃逸负例均非 0
[ ] --install 到干净目录后 --check 通过;宿主 scan/load 冒烟(如可用)
[ ] CI 不使用生产签名密钥;生产签名作业受保护分支+审批