Skip to content

Commit d53a103

Browse files
authored
feat(linux): add ARM64 and x64 Java Support Lite packages (#10)
* feat(linux): package and verify ARM64 and x64 plugin support * docs(linux): record successful native architecture checks
1 parent d41ae0f commit d53a103

11 files changed

Lines changed: 160 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [ubuntu-latest, windows-latest]
18+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest]
1919
runs-on: ${{ matrix.os }}
2020
timeout-minutes: 15
2121
steps:
@@ -29,10 +29,18 @@ jobs:
2929
- name: Vet
3030
run: go vet ./...
3131
- name: Test
32-
run: go test -race -count=1 ./...
32+
run: go test -timeout=120s -race -count=1 ./...
3333

3434
package:
35-
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include:
39+
- os: ubuntu-latest
40+
arch: x64
41+
- os: ubuntu-24.04-arm
42+
arch: arm64
43+
runs-on: ${{ matrix.os }}
3644
timeout-minutes: 10
3745
steps:
3846
- uses: actions/checkout@v4
@@ -44,6 +52,10 @@ jobs:
4452
node-version: 22
4553
- name: Check manifest and build the archives
4654
run: node scripts/package.mjs
55+
- name: Verify Linux release archives
56+
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
57+
- name: Start the packaged Linux language server
58+
run: node scripts/package/smoke-linux.mjs dist/*-linux-${{ matrix.arch }}.zip
4759
- name: Validate against Lithe Store rules
4860
run: |
4961
git clone --depth 1 https://github.com/Lithe-IDEA/Lithe-store "$RUNNER_TEMP/store"

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ jobs:
2525
with:
2626
node-version: 22
2727
- name: Test
28-
run: go test -count=1 ./...
28+
run: go test -timeout=120s -count=1 ./...
2929
- name: Build archives
3030
run: |
3131
set -o pipefail
3232
node scripts/package.mjs --expect-tag "$GITHUB_REF_NAME" | tee "$RUNNER_TEMP/checksums.txt"
33+
- name: Verify Linux release archives
34+
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
35+
- name: Start the packaged Linux x64 language server
36+
run: node scripts/package/smoke-linux.mjs dist/*-linux-x64.zip
3337
- name: Publish release
3438
env:
3539
GH_TOKEN: ${{ github.token }}
3640
# Releases on plugin contract v0, which only the new desktop client
3741
# installs, and that client ships as desktop-v* pre-releases.
38-
PRERELEASE_TAGS: v0.0.1 v0.0.2 v0.0.3
42+
PRERELEASE_TAGS: v0.0.1 v0.0.2 v0.0.3 v0.1.0
3943
run: |
4044
prerelease=false
4145
for tag in $PRERELEASE_TAGS; do

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,7 @@ go run ./cmd/java-navigation --version
164164
## 许可
165165

166166
Apache License 2.0,见 `LICENSE`。`internal/codenav` 等来自 Viff 的代码按 MIT 许可,见 `THIRD_PARTY_NOTICES.md`。
167+
168+
## Linux ARM64 / x64
169+
170+
Linux 构建、资源归属与原生验证入口见 [Linux 构建与验证](docs/linux-packaging.md)。

‎docs/feature-matrix.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 功能验证矩阵
2+
3+
## Linux 安装包
4+
5+
| 能力 | Linux ARM64 | Linux x64 | 验证入口 |
6+
| --- | --- | --- | --- |
7+
| 构建与安装包 | [已实现并通过原生 CI](https://github.com/Lithe-IDEA/lithe-plugin-java-navigation/actions/runs/43619383227) | [已实现并通过原生 CI](https://github.com/Lithe-IDEA/lithe-plugin-java-navigation/actions/runs/43619383227) | `.github/workflows/ci.yml`、[资源说明](linux-packaging.md) |
8+
| 真实工具/语言服务器流程 | [已通过原生 CI](https://github.com/Lithe-IDEA/lithe-plugin-java-navigation/actions/runs/43619383227) | [已通过原生 CI](https://github.com/Lithe-IDEA/lithe-plugin-java-navigation/actions/runs/43619383227) | `scripts/package/` 和现有集成测试 |
9+
10+
跨架构本地包检查通过不等于原生工作流验收。既有平台验证记录保持不变。

‎docs/linux-packaging.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Linux 构建与验证
2+
3+
`node scripts/package.mjs` 使用 `CGO_ENABLED=0` 交叉编译 Linux ARM64 与 x64 语言服务器,分别产生 `-linux-arm64.zip`、`-linux-x64.zip`。归档检查校验 ELF64 架构、包内启动路径与解压后的执行权限。
4+
5+
`node scripts/package/smoke-linux.mjs <zip>` 在对应原生 Linux runner 上启动包内程序,完成 LSP initialize、文档符号与 shutdown,验证安装目录文件内容与权限不变,并清理进程组和临时工作区。
6+
7+
## 资源与验证边界
8+
9+
所有下载、解压、编译与归档都属于本插件仓库的构建阶段。`dist/` 为输出包;`.artifacts/`、`.cache/`、`target/` 或工具自身缓存为本地构建状态,不跨工作树共享可变状态。校验过的下载以固定来源与摘要识别,提取结果不作为可信下载源。运行时只读取已安装插件,缓存、日志、索引和工作区状态归用户可写目录。Linux 不使用 macOS 代码签名或 Sparkle;本次不改变 macOS 包签名与更新基线。
10+
11+
原生 ARM64 和 x64 验证由 `.github/workflows/ci.yml` 执行;本机的交叉编译与归档检查不能替代原生运行结果。只有目标平台 CI 成功后才能宣称该平台通过。发布新版本后,使用实际 Release 附件的 SHA-256 更新 Store,保留所有旧版本与既有平台。

‎docs/releases/v0.1.0.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Java Support Lite 0.1.0
2+
3+
## 中文
4+
5+
- 新增 Linux ARM64 和 x64 安装包,兼容现有插件契约 v0 与 Lithe 桌面预览版。
6+
- 保留已支持平台;安装包在构建时验证,运行时状态保存在用户目录。
7+
8+
---
9+
10+
## English
11+
12+
- Add Linux ARM64 and x64 packages for the existing plugin contract v0 and Lithe desktop preview.
13+
- Keep existing platforms; verify release archives at build time and keep runtime state in user directories.

‎io.github.lithe-idea.java-navigation/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": 0,
33
"id": "io.github.lithe-idea.java-navigation",
44
"displayName": "Java Support Lite",
5-
"version": "0.0.3",
5+
"version": "0.1.0",
66
"pluginAPIVersion": 0,
77
"requires": {
88
"languageServers": 0,

‎scripts/package.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const PACKAGE_DIR = "io.github.lithe-idea.java-navigation";
2121
const ASSET_PREFIX = "java-navigation";
2222
const BINARY = "java-navigation";
2323
const TARGETS = [
24+
{ platform: "linux-arm64", goos: "linux", goarch: "arm64" },
25+
{ platform: "linux-x64", goos: "linux", goarch: "amd64" },
2426
{ platform: "darwin-arm64", goos: "darwin", goarch: "arm64" },
2527
{ platform: "darwin-x64", goos: "darwin", goarch: "amd64" },
2628
{ platform: "windows-x64", goos: "windows", goarch: "amd64" },
@@ -66,7 +68,7 @@ for (const target of targets) {
6668
execFileSync(
6769
"go",
6870
["build", "-trimpath", "-ldflags", `-s -w -buildid= -X main.version=${manifest.version}`, "-o", join(pkg, "bin", exe), "./cmd/java-navigation"],
69-
{ stdio: "inherit", env: { ...process.env, CGO_ENABLED: "0", GOOS: target.goos, GOARCH: target.goarch } },
71+
{ stdio: "inherit", timeout: 120_000, env: { ...process.env, CGO_ENABLED: "0", GOOS: target.goos, GOARCH: target.goarch } },
7072
);
7173
chmodSync(join(pkg, "bin", exe), 0o755);
7274
const platformManifest = structuredClone(manifest);
@@ -78,7 +80,7 @@ for (const target of targets) {
7880
const asset = resolve("dist", name);
7981
// -X drops extra file attributes; -y stores a symbolic link as a link so
8082
// Lithe refuses it instead of the archive silently carrying its target.
81-
execFileSync("zip", ["-qrXy", asset, PACKAGE_DIR, "-x", "*.DS_Store"], { cwd: staging });
83+
execFileSync("zip", ["-qrXy", asset, PACKAGE_DIR, "-x", "*.DS_Store"], { cwd: staging, timeout: 30_000 });
8284
const sha256 = createHash("sha256").update(readFileSync(asset)).digest("hex");
8385
console.log(`dist/${name} ${sha256}`);
8486
}

‎scripts/package/linux.test.mjs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Integration checks of the release archives, after scripts/package.mjs.
2+
import test from 'node:test';
3+
import assert from 'node:assert/strict';
4+
import {execFileSync} from 'node:child_process';
5+
import {readFileSync,mkdtempSync,rmSync,statSync} from 'node:fs';
6+
import {tmpdir} from 'node:os';
7+
import {join,resolve} from 'node:path';
8+
import {createHash} from 'node:crypto';
9+
const id="io.github.lithe-idea.java-navigation";
10+
const version=JSON.parse(readFileSync(`${id}/plugin.json`)).version;
11+
const read=(archive,path)=>execFileSync('unzip',['-p',archive,`${id}/${path}`],{timeout:10000,maxBuffer:16*1024*1024});
12+
for (const [arch,machine] of [['arm64',183],['x64',62]]) {
13+
test(`Linux ${arch} archive contains an executable ELF language server`,t=>{
14+
const archive=resolve(`dist/java-navigation-${version}-linux-${arch}.zip`);
15+
const manifest=JSON.parse(read(archive,'plugin.json'));
16+
assert.equal(manifest.version,version);
17+
const path=manifest.languageServers[0].launch.path;
18+
assert.equal(path,'bin/java-navigation');
19+
const binary=read(archive,path);
20+
assert.deepEqual([...binary.subarray(0,6)],[127,69,76,70,2,1]);
21+
assert.equal(binary.readUInt16LE(18),machine);
22+
const stage=mkdtempSync(join(tmpdir(),'lithe-linux-archive-'));
23+
t.after(()=>rmSync(stage,{recursive:true,force:true}));
24+
execFileSync('unzip',['-q',archive,'-d',stage],{timeout:10000});
25+
assert.ok(statSync(join(stage,id,path)).mode & 0o111);
26+
});
27+
}

‎scripts/package/lsp-client.mjs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Bounded integration-test client. Each child owns a process group; cleanup
2+
// runs after success, protocol failure, and request timeout.
3+
import {spawn} from 'node:child_process';
4+
export class Client {
5+
constructor(executable,args=[],options={}){
6+
this.next=1;this.pending=new Map();this.buffer=Buffer.alloc(0);this.stderr='';
7+
this.child=spawn(executable,args,{...options,detached:true,stdio:['pipe','pipe','pipe']});
8+
this.exited=new Promise(resolve=>{this.child.once('exit',(code,signal)=>{this.fail(Error(`Process exited: ${code}/${signal}: ${this.stderr}`));resolve();});this.child.once('error',error=>{this.fail(error);resolve();});});
9+
this.child.stdin.on('error',error=>this.fail(error));
10+
this.child.stderr.on('data',bytes=>{this.stderr=(this.stderr+bytes).slice(-65536);});
11+
this.child.stdout.on('data',bytes=>{
12+
try{
13+
this.buffer=Buffer.concat([this.buffer,bytes]);if(this.buffer.length>16*1024*1024)throw Error('Protocol frame exceeds 16 MiB');
14+
while(true){
15+
const end=this.buffer.indexOf('\r\n\r\n');if(end<0)return;
16+
const length=Number(/Content-Length: (\d+)/i.exec(this.buffer.subarray(0,end).toString())?.[1]);
17+
if(!Number.isSafeInteger(length)||length>16*1024*1024)throw Error('Invalid protocol length');
18+
if(this.buffer.length<end+4+length)return;
19+
const message=JSON.parse(this.buffer.subarray(end+4,end+4+length));this.buffer=this.buffer.subarray(end+4+length);
20+
if(message.method && message.id!==undefined){
21+
const result=message.method==='workspace/configuration'?(message.params?.items??[]).map(()=>({})):null;
22+
this.send({id:message.id,result});
23+
}else if(message.id!==undefined){const item=this.pending.get(message.id);if(item){this.pending.delete(message.id);clearTimeout(item.timer);message.error?item.reject(Error(JSON.stringify(message.error))):item.resolve(message.result);}}
24+
}
25+
}catch(error){this.fail(error);}
26+
});
27+
}
28+
fail(error){this.failure=error;for(const item of this.pending.values()){clearTimeout(item.timer);item.reject(error);}this.pending.clear();}
29+
send(message){const body=JSON.stringify({jsonrpc:'2.0',...message});this.child.stdin.write(`Content-Length: ${Buffer.byteLength(body)}\r\n\r\n${body}`);}
30+
notify(method,params){this.send({method,params});}
31+
request(method,params,timeout=60000){
32+
if(this.failure)return Promise.reject(this.failure);
33+
const id=this.next++;return new Promise((resolve,reject)=>{
34+
const timer=setTimeout(()=>{this.pending.delete(id);reject(Error(`${method} timed out: ${this.stderr}`));},timeout);
35+
this.pending.set(id,{resolve,reject,timer});this.send({id,method,params});
36+
});
37+
}
38+
async close(){
39+
this.fail(Error('Client closed'));
40+
if(this.child.pid){try{process.kill(-this.child.pid,'SIGKILL');}catch(error){if(error.code!=='ESRCH')throw error;}}
41+
let timer;try{await Promise.race([this.exited,new Promise((_,reject)=>{timer=setTimeout(()=>reject(Error('Process cleanup timed out')),5000);})]);}finally{clearTimeout(timer);}
42+
}
43+
}

0 commit comments

Comments
 (0)