Skip to content

Commit 287317a

Browse files
author
Venkata Subramani Renduchintala
committed
fix(ci): fix treesitter parser installation in headless CI
TSUpdateSync does not exist in this nvim-treesitter version. Replace with a Lua script (test/install_parsers.lua) that calls TSInstall! per parser and polls parser .so files via vim.wait() until compiled or timeout. Also fix validate_treesitter.lua to handle nil return from get_parser (parser not installed) in addition to pcall errors.
1 parent 8bb4485 commit 287317a

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/validate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ jobs:
7979
-v "${{ github.workspace }}:/home/dev/.config/nvim:ro" \
8080
-v "$HOME/.local/share/nvim-ci:/home/dev/.local/share/nvim" \
8181
nvim-config:ci \
82-
nvim --headless -c "TSUpdateSync" -c "qall"
82+
nvim --headless \
83+
-c "luafile /home/dev/.config/nvim/test/install_parsers.lua" \
84+
-c "qall"
8385
timeout-minutes: 10
8486

8587
- name: Test Go and Terraform treesitter parsers

test/install_parsers.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- Headless treesitter parser installer for CI.
2+
-- Uses TSInstall! + vim.wait() polling parser .so files on disk.
3+
-- Exit code 1 on timeout so the CI step fails visibly.
4+
local langs = { 'go', 'terraform', 'hcl' }
5+
local parser_dir = vim.fn.stdpath('data') .. '/lazy/nvim-treesitter/parser/'
6+
7+
local function installed(lang)
8+
return vim.fn.filereadable(parser_dir .. lang .. '.so') == 1
9+
end
10+
11+
for _, lang in ipairs(langs) do
12+
if installed(lang) then
13+
print('SKIP [' .. lang .. ']: already compiled')
14+
else
15+
print('INST [' .. lang .. ']: installing...')
16+
pcall(vim.cmd, 'TSInstall! ' .. lang)
17+
end
18+
end
19+
20+
local ok = vim.wait(300000, function()
21+
for _, lang in ipairs(langs) do
22+
if not installed(lang) then return false end
23+
end
24+
return true
25+
end, 2000)
26+
27+
if not ok then
28+
for _, lang in ipairs(langs) do
29+
if not installed(lang) then
30+
io.stderr:write('FAIL [' .. lang .. ']: compile timed out\n')
31+
end
32+
end
33+
vim.cmd('cquit 1')
34+
else
35+
for _, lang in ipairs(langs) do
36+
print('OK [' .. lang .. ']: parser ready')
37+
end
38+
end

test/validate_treesitter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local function test_parser(lang, filepath)
1313
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
1414

1515
local ok, result = pcall(vim.treesitter.get_parser, buf, lang)
16-
if not ok then
16+
if not ok or result == nil then
1717
table.insert(errors, string.format('[%s] parser load failed: %s', lang, tostring(result)))
1818
vim.api.nvim_buf_delete(buf, { force = true })
1919
return

0 commit comments

Comments
 (0)