mirror of
https://github.com/nvim-treesitter/nvim-treesitter-context
synced 2024-09-16 14:14:03 +02:00
feat(ci): check queries for all languages
This commit is contained in:
parent
00cb0522a8
commit
37da716804
3 changed files with 134 additions and 18 deletions
36
.github/workflows/nightly.yml
vendored
Normal file
36
.github/workflows/nightly.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: Nightly
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
NVIM_TS_SHA: master
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: leafo/gh-actions-lua@v10
|
||||
with:
|
||||
luaVersion: "5.1.5"
|
||||
|
||||
- uses: leafo/gh-actions-luarocks@v4
|
||||
|
||||
- name: Download nvim-test
|
||||
run: make nvim-test
|
||||
|
||||
- name: Run Test
|
||||
run: make test NVIM_TS_SHA=$NVIM_TS_SHA
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "docs: Update README.md"
|
||||
file_pattern: README.md
|
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
|||
|
||||
NEOVIM_VERSION := v0.9.5
|
||||
|
||||
NVIM_TS_SHA := 883c72cd
|
||||
NVIM_TS_SHA := 98460428
|
||||
|
||||
FILTER=.*
|
||||
|
||||
|
|
|
@ -6,8 +6,51 @@ local exec_lua = helpers.exec_lua
|
|||
local cmd = helpers.api.nvim_command
|
||||
local feed = helpers.feed
|
||||
|
||||
local function get_langs()
|
||||
local f = assert(io.open('README.md', 'r'))
|
||||
local readme_langs = {} --- @type table<string,true>
|
||||
for l in f:lines() do
|
||||
--- @type string?
|
||||
local lang = l:match('%- %[x%] `([^`]+)`')
|
||||
if lang then
|
||||
readme_langs[lang] = true
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
||||
f = assert(io.open('nvim-treesitter/lockfile.json', 'r'))
|
||||
local txt = f:read('*a')
|
||||
local j = vim.json.decode(txt)
|
||||
|
||||
local langs = {} --- @type string[]
|
||||
for k in pairs(j) do
|
||||
if readme_langs[k] then
|
||||
langs[#langs+1] = k
|
||||
readme_langs[k] = nil
|
||||
end
|
||||
end
|
||||
print('Invalid languages:', table.concat(vim.tbl_keys(readme_langs), ', '))
|
||||
return langs
|
||||
end
|
||||
|
||||
describe('ts_context', function()
|
||||
local screen --- @type test.screen
|
||||
local langs --- @type string[]
|
||||
|
||||
setup(function()
|
||||
clear()
|
||||
cmd [[set runtimepath+=.,./nvim-treesitter]]
|
||||
|
||||
langs = get_langs()
|
||||
|
||||
exec_lua([[
|
||||
local langs = ...
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = langs,
|
||||
sync_install = true,
|
||||
}
|
||||
]], langs)
|
||||
end)
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
|
@ -33,23 +76,10 @@ describe('ts_context', function()
|
|||
|
||||
cmd [[set runtimepath+=.,./nvim-treesitter]]
|
||||
|
||||
exec_lua[[
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = {
|
||||
"c",
|
||||
"lua",
|
||||
"rust",
|
||||
"cpp",
|
||||
"typescript",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"html",
|
||||
"javascript",
|
||||
"php",
|
||||
},
|
||||
sync_install = true,
|
||||
}
|
||||
]]
|
||||
exec_lua([[
|
||||
require'nvim-treesitter.configs'.setup {}
|
||||
]])
|
||||
|
||||
-- Required for the proper Markdown support
|
||||
exec_lua [[require'nvim-treesitter'.setup()]]
|
||||
|
||||
|
@ -103,6 +133,56 @@ describe('ts_context', function()
|
|||
]]}
|
||||
end)
|
||||
|
||||
describe('query:', function()
|
||||
local readme_lines = {} --- @type string[]
|
||||
|
||||
setup(function()
|
||||
local f = assert(io.open('README.md', 'r'))
|
||||
for l in f:lines() do
|
||||
readme_lines[#readme_lines+1] = l
|
||||
end
|
||||
f:close()
|
||||
end)
|
||||
|
||||
for _, lang in ipairs(langs) do
|
||||
it(lang, function()
|
||||
local index --- @type integer
|
||||
local line_orig --- @type string
|
||||
|
||||
for i, l in pairs(readme_lines) do
|
||||
--- @type string?
|
||||
local lang1 = l:match('%- %[x%] `([^`]+)`')
|
||||
if lang1 == lang then
|
||||
l = l:gsub(' %(broken%)', '')
|
||||
index, line_orig = i, l
|
||||
readme_lines[i] = l..' (broken)'
|
||||
else
|
||||
readme_lines[i] = l
|
||||
end
|
||||
end
|
||||
|
||||
assert(index)
|
||||
|
||||
exec_lua([[
|
||||
local lang = ...
|
||||
vim.treesitter.query.get(lang, 'context')
|
||||
]], lang)
|
||||
|
||||
readme_lines[index] = line_orig
|
||||
end)
|
||||
end
|
||||
|
||||
teardown(function()
|
||||
local f = assert(io.open('README.md', 'w'))
|
||||
for _, l in ipairs(readme_lines) do
|
||||
f:write(l)
|
||||
f:write('\n')
|
||||
end
|
||||
f:close()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
describe('language:', function()
|
||||
before_each(function()
|
||||
exec_lua[[require'treesitter-context'.setup{
|
||||
|
|
Loading…
Reference in a new issue