Skip to content

Commit a464c07

Browse files
committed
ci: package Blink native libraries
1 parent 808a186 commit a464c07

5 files changed

Lines changed: 168 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ directories. The plugin cache is keyed by OS, architecture, Neovim version, and
200200
[nvim-pack-lock.json](nvim-pack-lock.json), with a same-version fallback so
201201
unchanged plugins can be reused when the lockfile changes.
202202

203+
The packaging job also preloads and verifies Blink native libraries before
204+
building artifacts, so packaged installs include the Rust fuzzy matcher for
205+
`blink.cmp` and the native matcher used by `blink.pairs`.
206+
203207
The workflow can be triggered in three ways:
204208

205209
1. Manually push a tag such as `v0.12.1.0`.

scripts/ci-ensure-blink-native.lua

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
local uv = vim.uv or vim.loop
2+
3+
local function fail(message)
4+
local messages = vim.api.nvim_exec2("messages", { output = true }).output
5+
if messages ~= "" then
6+
vim.api.nvim_err_writeln(messages)
7+
end
8+
vim.api.nvim_err_writeln(message)
9+
vim.cmd("cquit")
10+
end
11+
12+
local function assert_file(path, label)
13+
local stat = uv.fs_stat(path)
14+
if not stat or stat.type ~= "file" then
15+
fail(("Missing %s: %s"):format(label, path))
16+
end
17+
print(("Found %s: %s"):format(label, path))
18+
end
19+
20+
local function wait_for(label, start)
21+
local done = false
22+
local err = nil
23+
local result = nil
24+
25+
local ok, start_err = pcall(start, function(callback_err, callback_result)
26+
err = callback_err
27+
result = callback_result
28+
done = true
29+
end)
30+
31+
if not ok then
32+
fail(("Failed to start %s: %s"):format(label, start_err))
33+
end
34+
35+
if not vim.wait(180000, function()
36+
return done
37+
end, 250, false) then
38+
fail(("Timed out waiting for %s"):format(label))
39+
end
40+
41+
if err then
42+
fail(("Failed to prepare %s: %s"):format(label, err))
43+
end
44+
45+
return result
46+
end
47+
48+
local function native_extension()
49+
local sysname = uv.os_uname().sysname:lower()
50+
if sysname == "darwin" then
51+
return ".dylib"
52+
end
53+
if sysname:find("windows", 1, true) then
54+
return ".dll"
55+
end
56+
return ".so"
57+
end
58+
59+
local function packadd(plugin)
60+
local ok, err = pcall(vim.cmd.packadd, plugin)
61+
if not ok then
62+
fail(("Failed to load %s: %s"):format(plugin, err))
63+
end
64+
end
65+
66+
packadd("blink.lib")
67+
packadd("blink.cmp")
68+
packadd("blink.pairs")
69+
70+
if vim.v.errmsg ~= "" then
71+
fail(vim.v.errmsg)
72+
end
73+
74+
local ok_cmp_config, cmp_config = pcall(require, "blink.cmp.config")
75+
if not ok_cmp_config then
76+
fail("blink.cmp config is not available: " .. tostring(cmp_config))
77+
end
78+
79+
cmp_config.fuzzy.implementation = "rust"
80+
cmp_config.fuzzy.prebuilt_binaries.force_version = cmp_config.fuzzy.prebuilt_binaries.force_version
81+
or "v*"
82+
83+
local ok_cmp_download, cmp_download = pcall(require, "blink.cmp.fuzzy.download")
84+
if not ok_cmp_download then
85+
fail("blink.cmp fuzzy downloader is not available: " .. tostring(cmp_download))
86+
end
87+
88+
local cmp_implementation = wait_for("blink.cmp fuzzy native library", function(done)
89+
cmp_download.ensure_downloaded(done)
90+
end)
91+
92+
if cmp_implementation ~= "rust" then
93+
fail(
94+
("blink.cmp fuzzy matcher resolved to %s, expected rust"):format(
95+
tostring(cmp_implementation)
96+
)
97+
)
98+
end
99+
100+
local cmp_files = require("blink.cmp.fuzzy.download.files")
101+
assert_file(cmp_files.lib_path, "blink.cmp fuzzy library")
102+
assert_file(cmp_files.checksum_path, "blink.cmp fuzzy checksum")
103+
assert_file(cmp_files.version_path, "blink.cmp fuzzy version")
104+
105+
local ok_pairs, pairs = pcall(require, "blink.pairs")
106+
if not ok_pairs then
107+
fail("blink.pairs is not available: " .. tostring(pairs))
108+
end
109+
110+
wait_for("blink.pairs native library", function(done)
111+
pairs.download_if_available(function(err)
112+
done(err, true)
113+
end)
114+
end)
115+
116+
local ok_pairs_rust, pairs_rust_err = pcall(require, "blink.pairs.rust")
117+
if not ok_pairs_rust then
118+
fail("blink.pairs native library is not loadable: " .. tostring(pairs_rust_err))
119+
end
120+
121+
local pairs_source = debug.getinfo(pairs.download_if_available, "S").source:gsub("^@", "")
122+
local pairs_root = pairs_source:gsub("/lua/blink/pairs/init%.lua$", "")
123+
if pairs_root == pairs_source then
124+
fail("Failed to resolve blink.pairs plugin root from " .. pairs_source)
125+
end
126+
127+
assert_file(
128+
pairs_root .. "/target/release/libblink_pairs" .. native_extension(),
129+
"blink.pairs native library"
130+
)
131+
assert_file(pairs_root .. "/target/release/version", "blink.pairs native version")

scripts/ci-ensure-blink-native.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
log_file="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/nvime-ci-blink-native.log"
7+
8+
NVIM_LOG_FILE="$log_file" nvim --headless -u NONE -i NONE \
9+
-S "$repo_root/scripts/ci-ensure-blink-native.lua" \
10+
'+qa'

scripts/ci-package.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ case "$os" in
2323
Linux)
2424
platform="linux"
2525
package_ext="tar.gz"
26+
native_ext=".so"
2627
;;
2728
Darwin)
2829
platform="macos"
2930
package_ext="dmg"
31+
native_ext=".dylib"
3032
;;
3133
*)
3234
echo "Unsupported operating system: $os" >&2
@@ -79,6 +81,7 @@ cp -R "$repo_root/." "$config_root"
7981

8082
echo "Bootstrapping packaged config in $config_root"
8183
run_headless_nvim
84+
bash "$repo_root/scripts/ci-ensure-blink-native.sh"
8285
run_headless_nvim
8386

8487
rsync -a \
@@ -96,6 +99,23 @@ if [[ -d "$data_root" ]]; then
9699
rsync -a "$data_root/" "$payload_data_root/"
97100
fi
98101

102+
require_payload_file() {
103+
local pattern="$1"
104+
local label="$2"
105+
local match
106+
107+
match="$(find "$payload_data_root" -name "$pattern" -type f -print -quit)"
108+
if [[ -z "$match" ]]; then
109+
echo "Packaged payload is missing $label ($pattern)" >&2
110+
exit 1
111+
fi
112+
113+
echo "Included $label: $match"
114+
}
115+
116+
require_payload_file "libblink_cmp_fuzzy${native_ext}" "blink.cmp fuzzy native library"
117+
require_payload_file "libblink_pairs${native_ext}" "blink.pairs native library"
118+
99119
cp "$repo_root/scripts/install-bundle.sh" "$bundle_root/install.sh"
100120
chmod +x "$bundle_root/install.sh"
101121

scripts/ci-smoke.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ echo "Using temporary data root: $XDG_DATA_HOME"
3838
echo "Bootstrapping plugins from nvim-pack-lock.json"
3939
run_headless_nvim
4040

41+
echo "Ensuring Blink native libraries are available"
42+
bash "$repo_root/scripts/ci-ensure-blink-native.sh"
43+
4144
echo "Verifying clean headless startup"
4245
run_headless_nvim

0 commit comments

Comments
 (0)