Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/release-rust-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Releases the official Rust plugin SDK (`sdk/rust/plugin-sdk`) through its
# own tag series (`sdk-rust-v<version>`). Plugin repositories either depend
# on the tag through Git, which their Cargo.lock pins to the commit, or pin
# `lithe-plugin-sdk-rust-<version>.crate` by its `.sha256` and vendor the
# unpacked crate; the SDK is not published to crates.io.
name: Release Rust Plugin SDK

on:
push:
tags:
- "sdk-rust-v*"

permissions:
contents: read

concurrency:
group: release-rust-plugin-sdk-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
name: Release ${{ github.ref_name }}
if: github.repository == 'Lithe-IDEA/lithe-plugin-docs'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: write

steps:
- name: Check out source
uses: actions/checkout@v7

# The release is tested on the oldest supported Rust.
- uses: dtolnay/rust-toolchain@1.87

- name: Require the tag to match the SDK version
id: version
env:
TAG: ${{ github.ref_name }}
run: |
version=$(cargo +1.87 metadata --locked --no-deps --format-version 1 --manifest-path sdk/rust/Cargo.toml \
| jq -r '.packages[] | select(.name == "lithe-plugin-sdk") | .version')
test "$TAG" = "sdk-rust-v$version" || { echo "Tag $TAG does not match sdk/rust version $version"; exit 1; }
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Test
run: cargo +1.87 test --locked --manifest-path sdk/rust/Cargo.toml

# `cargo package` only builds the archive; `publish = false` keeps the
# SDK off crates.io. The repository LICENSE is copied in so the archive
# carries its own license text.
- name: Collect the release assets
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
cp LICENSE sdk/rust/plugin-sdk/LICENSE
cargo +1.87 package --locked --allow-dirty --manifest-path sdk/rust/Cargo.toml -p lithe-plugin-sdk
mkdir -p dist
asset="lithe-plugin-sdk-rust-$VERSION.crate"
cp "sdk/rust/target/package/lithe-plugin-sdk-$VERSION.crate" "dist/$asset"
tar -tzf "dist/$asset" | sort
(cd dist && sha256sum "$asset" | cut -d' ' -f1 > "$asset.sha256")

- name: Publish the SDK release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
VERSION: ${{ steps.version.outputs.version }}
run: |
asset="lithe-plugin-sdk-rust-$VERSION.crate"
gh release create "$TAG" "dist/$asset" "dist/$asset.sha256" \
--title "Rust plugin SDK $VERSION" \
--notes "Official Rust plugin SDK $VERSION for Lithe plugin backends. Requires Rust 1.87 or newer and depends only on serde_json. Depend on the tag through Git, or pin the archive by its SHA-256 (\`$asset.sha256\`) and vendor the unpacked crate; see sdk/rust/README.md."
22 changes: 21 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ jobs:
JAVA8: ${{ steps.java8.outputs.path }}/bin/java
run: mvn -B -ntp -f sdk/java/pom.xml verify -Djvm="$JAVA8"

sdk-rust:
name: Rust SDK
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
# The SDK supports Rust 1.87 and newer: the tests run on that release,
# and formatting and lints on the current stable toolchain.
- uses: dtolnay/rust-toolchain@1.87
- name: Test on the oldest supported Rust
run: cargo +1.87 test --locked --manifest-path sdk/rust/Cargo.toml
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Check formatting and lints
run: |
cargo fmt --manifest-path sdk/rust/Cargo.toml --all -- --check
cargo clippy --locked --manifest-path sdk/rust/Cargo.toml --all-targets -- -D warnings

sdk-e2e:
name: SDK end-to-end with Rust Core
runs-on: ubuntu-latest
Expand Down Expand Up @@ -113,7 +132,8 @@ jobs:
~/.cargo/registry
~/.cargo/git
.artifacts/lithe/rust/target
key: sdk-e2e-${{ runner.os }}-${{ hashFiles('contract.lock.json') }}
sdk/rust/target
key: sdk-e2e-${{ runner.os }}-${{ hashFiles('contract.lock.json', 'sdk/rust/Cargo.lock') }}
restore-keys: sdk-e2e-${{ runner.os }}-

- name: Run against the pinned Lithe commit
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
*.tmp
.artifacts/
sdk/java/**/target/
sdk/rust/target/
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ Schema 只检查 JSON 结构。ID 引用、权限、激活事件、模板变量

## 插件后端 SDK(可选)

只用语言服务器、运行和测试的插件不需要后端。需要构建后端(`buildProviders`)或插件函数时,用官方 SDK 写:协议、取消、进程清理和错误处理由 SDK 负责,你只写处理函数。
只用语言服务器、运行和测试的插件不需要后端。需要构建后端(`buildProviders`)、插件函数,或给插件自己的网页配一个后端进程(`backend`)时,用官方 SDK 写:协议、取消、进程清理和错误处理由 SDK 负责,你只写处理函数。

| SDK | 运行时 | Release 标签 | 下载内容 | 怎么放进插件 |
| --- | --- | --- | --- | --- |
| [Node.js](sdk/node/README.md) | Node.js 20.3+ | `sdk-node-v<版本>` | `lithe-plugin-sdk-node-<版本>.tgz` 和 `.sha256` | 解压后把 `package/` 复制进插件包,用相对路径导入 |
| [Java](sdk/java/README.md) | Java 8+ | `sdk-java-v<版本>` | `lithe-plugin-sdk-java-<版本>.jar` 和 `.sha256` | shade 进后端 JAR |
| [Rust](sdk/rust/README.md) | Rust 1.87+ | `sdk-rust-v<版本>` | `lithe-plugin-sdk-rust-<版本>.crate` 和 `.sha256` | 用 Git 依赖锁定标签(`Cargo.lock` 记录 commit),或解压后作为 `path` 依赖;编译成每个平台各一份的插件后端可执行文件 |

两个 SDK 的源码在本仓库的 `sdk/` 下,发布在[本仓库的 Releases](https://github.com/Lithe-IDEA/lithe-plugin-docs/releases) 里,不在 npm 或 Maven 仓库上。Java SDK 0.1.0 是搬到这里之前从 Lithe 主仓库发布的,[那个 Release](https://github.com/1lck/Lithe-IDEA/releases/tag/sdk-java-v0.1.0) 继续可用,已经锁定它的插件不用改。
SDK 的源码都在本仓库的 `sdk/` 下,发布在[本仓库的 Releases](https://github.com/Lithe-IDEA/lithe-plugin-docs/releases) 里,不在 npm、Maven 或 crates.io 上。Rust SDK 目前只实现插件后端(`backend`):插件函数和宿主凭据服务;构建后端和 VCS 后端请用 Node.js 或 Java SDK。Java SDK 0.1.0 是搬到这里之前从 Lithe 主仓库发布的,[那个 Release](https://github.com/1lck/Lithe-IDEA/releases/tag/sdk-java-v0.1.0) 继续可用,已经锁定它的插件不用改。

规则只有一条:**在构建时下载,并按你锁定的 SHA-256 校验;运行时不下载任何东西。** 插件包安装后没有 `npm install` 步骤,也必须能离线运行。
规则只有一条:**在构建时下载,并按你锁定的 SHA-256(或 Git commit)校验;运行时不下载任何东西。** 插件包安装后没有 `npm install` 步骤,也必须能离线运行。

[Maven 插件](https://github.com/Lithe-IDEA/lithe-plugin-maven) 的 `sdk.lock.json` 是锁定 Java SDK 的现成例子。

Expand Down Expand Up @@ -169,12 +170,13 @@ node scripts/contract.mjs sync --revision <主仓库的完整 commit>
| --- | --- |
| `node --test sdk/node/test/*.test.mjs` | Node.js SDK 的单元测试 |
| `mvn -B -ntp -f sdk/java/pom.xml verify -Djvm=<java>` | Java SDK 的单元测试;`-Djvm` 指定运行测试的 Java(CI 用 Java 8) |
| `node scripts/sdk-e2e.mjs` | 端到端测试:两个示例后端接入真实的 Lithe Rust Core,跑 `sdk/e2e` 里的同一套场景 |
| `cargo test --locked --manifest-path sdk/rust/Cargo.toml` | Rust SDK 的单元测试(CI 用 Rust 1.87,另用 stable 跑 `cargo fmt` 和 `cargo clippy`) |
| `node scripts/sdk-e2e.mjs` | 端到端测试:各 SDK 的示例后端接入真实的 Lithe Rust Core。Node.js 和 Java 跑 `sdk/e2e` 里同一套构建后端场景,Rust 跑插件后端场景(`plugin_sdk/backend.rs`),测试代替宿主应答凭据请求 |
| `node scripts/sdk-e2e.mjs --ref preview` | 同上,但用主仓库 `preview` 分支的最新 Core |

端到端测试需要 Rust、Node.js 20.3+、Java 和 Maven。Rust Core 在主仓库,脚本会把锁文件锁定的那个主仓库 commit 稀疏检出到 `.artifacts/lithe`(只取 `rust/` 和 `shared/`),把 `sdk/e2e` 复制进它的 `rust/lithe-core/tests/` 再运行,所以 SDK 测的是和契约副本同一个版本的 Core。`LITHE_PLUGIN_SDK_JAVA_RUNTIME` 指定运行 Java 示例的 Java;已有主仓库本地克隆时可以加 `--source <克隆目录>`。CI 每次提交跑锁定版本,每周一再跑一次主仓库 `preview` 的最新版本,Core 改动影响 SDK 时会提前发现。
端到端测试需要 Rust、Node.js 20.3+、Java 和 Maven。Rust Core 在主仓库,脚本会把锁文件锁定的那个主仓库 commit 稀疏检出到 `.artifacts/lithe`(只取 `rust/` 和 `shared/`),把 `sdk/e2e` 复制进它的 `rust/lithe-core/tests/` 再运行,所以 SDK 测的是和契约副本同一个版本的 Core。`LITHE_PLUGIN_SDK_JAVA_RUNTIME` 指定运行 Java 示例的 Java,`LITHE_PLUGIN_SDK_RUST_SAMPLE` 可以指定已编译好的 Rust 示例后端(否则脚本用 Cargo 编译);已有主仓库本地克隆时可以加 `--source <克隆目录>`。CI 每次提交跑锁定版本,每周一再跑一次主仓库 `preview` 的最新版本,Core 改动影响 SDK 时会提前发现。

发版:先改版本号(Node.js 改 `sdk/node/package.json`;Java 运行 `mvn -f sdk/java/pom.xml versions:set -DnewVersion=<版本> -DgenerateBackupPoms=false`,三个 pom 一起改),合并后推送对应标签 `sdk-node-v<版本>` 或 `sdk-java-v<版本>`。发版工作流会检查标签和版本一致,测试通过后把包和 `.sha256` 发到本仓库的 Releases。
发版:先改版本号(Node.js 改 `sdk/node/package.json`;Java 运行 `mvn -f sdk/java/pom.xml versions:set -DnewVersion=<版本> -DgenerateBackupPoms=false`,三个 pom 一起改;Rust 改 `sdk/rust/Cargo.toml` 的 `workspace.package.version` 并更新 `Cargo.lock`),合并后推送对应标签 `sdk-node-v<版本>`、`sdk-java-v<版本>` 或 `sdk-rust-v<版本>`。发版工作流会检查标签和版本一致,测试通过后把包和 `.sha256` 发到本仓库的 Releases。

## 许可证

Expand Down
54 changes: 49 additions & 5 deletions contract.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"source": {
"repository": "https://github.com/1lck/Lithe-IDEA",
"directory": "shared/contracts/plugins/v1",
"revision": "18345cc96a89e1af3b04b48aacd9af89350202cb"
"revision": "d046fd1768d00a52b1fc99d45067d06cf535bc23"
},
"files": [
{
"path": "README.md",
"sha256": "21fc28bb9c7299959adbe0223c348ff0b1f0764f16fa87e21bbebf50256a49e2"
"sha256": "87b6738fdd0d764b93f33556992d0586dfb97e68abb58e0bc3a5ac690ec97aab"
},
{
"path": "fixtures/backend.plugin.json",
"sha256": "c83d455cd1981407e903f28b6bfdb38309715856499feba5d76af85a097e1977"
},
{
"path": "fixtures/build-command-output-file.plugin.json",
Expand Down Expand Up @@ -48,15 +52,15 @@
},
{
"path": "fixtures/function-protocol.json",
"sha256": "278a56b3705be4187ec8ed8fc1ed4b788f019f375c71e87f7f50701fb3cdbea0"
"sha256": "980e8d39db2af9d7f922cdc01b0ec06e2cb8c33da2142ec8040befa975b7eae5"
},
{
"path": "fixtures/hello-lithe.plugin.json",
"sha256": "e56a4c2df075c14f059eefd73e916215f6e1594f047617c76b518fa21cc2a065"
},
{
"path": "fixtures/invalid-manifests.json",
"sha256": "ae5e5021d1f62fbf4f5ca0a8529a27ca045810346e16751644f6651dff00bdd4"
"sha256": "107afd7d3f440a87aab3611a80aa5e92c067cd719019dafd94bda8cdbd6b842f"
},
{
"path": "fixtures/language-host-integration.plugin.json",
Expand Down Expand Up @@ -90,10 +94,46 @@
"path": "fixtures/marketplace/source-urls.json",
"sha256": "88a1b00fc443a65ca5faa8ac519e93de4e6abca8297abb9045613317747f41b5"
},
{
"path": "fixtures/native-controls.plugin.json",
"sha256": "fc160a33d801d44222d20d6c79b1726e8e9dceb929fa99695a7990b3f4cb57cb"
},
{
"path": "fixtures/native-form.plugin.json",
"sha256": "082dd621eadad410a0aadc08e35e213e6818853ae4c18a2d38ce7c6f5bd8946d"
},
{
"path": "fixtures/native-panel.plugin.json",
"sha256": "b35c69c85f4e53f4ccd31e320e2f91387dde1935e10bde5b13019fd6e925fe1d"
},
{
"path": "fixtures/node-runtime.plugin.json",
"sha256": "3cbc80303dca796302653982d3f55fdc2072aea69a2517286a06e73fbc3c4499"
},
{
"path": "fixtures/project-generator-templates/.gitattributes",
"sha256": "5ab88980b2cd4db0455bb2d5c3703db6668d28f254c41a92a6feff64604af9f7"
},
{
"path": "fixtures/project-generator-templates/app/README.md",
"sha256": "c02eaa65ce4ba3a06c92c8fc5825508347437a5f3a2b1870e11f6510947e4fb7"
},
{
"path": "fixtures/project-generator-templates/app/dot-gitignore",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
{
"path": "fixtures/project-generator-templates/main/Main.java",
"sha256": "5435c9be433e0a1cadbeccc701451b21d53d8519e1516c58960af944fe0bf616"
},
{
"path": "fixtures/project-generator.plugin.json",
"sha256": "1e5598cfe85e62711c8f5e4090dc229df732380b75d519a0e95f7a8345740c5b"
},
{
"path": "fixtures/project-plans.json",
"sha256": "14c6fa8b073732f93b85b30e4fa9e8384ce094f2fb6fe833e41476f12c8d2132"
},
{
"path": "fixtures/runtime-versions.json",
"sha256": "a19c1c057ab54a2b24a4a0e5a0d7764f0b9063bb6dd356baf19f5f6e37a76e19"
Expand All @@ -110,13 +150,17 @@
"path": "fixtures/web-panel.plugin.json",
"sha256": "1ccaf5bb58e0296b8d244e6951d62c1f8e9e35e2e2bd467d4368fc31d7f42fd8"
},
{
"path": "native-ui.schema.json",
"sha256": "62c6e49ec274c52efb70cc3562f261e11d4dfb8cc59c8e13f7774321266f2837"
},
{
"path": "plugin-index.schema.json",
"sha256": "6771cb0e8c1ba101e6fc90b436de1b74f057ff0d58cc90f92e669edc9a102fc6"
},
{
"path": "plugin-manifest.schema.json",
"sha256": "27b01d48b99377eeaf473b1b670c4c19dbf86df81c6623205401226d13d351c8"
"sha256": "a70921c16f1d45e342777fc6f8fe9fc91efa82427d377461d356b8f00054008f"
}
]
}
Loading
Loading