Skip to content

Commit b54cec3

Browse files
committed
ci: migrate to nvim-treesitter
1 parent 3f62d56 commit b54cec3

File tree

8 files changed

+119
-219
lines changed

8 files changed

+119
-219
lines changed

.github/workflows/check_query_files.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,40 @@
1-
name: Linting and style checking
1+
name: Lint
22

33
on:
4+
push:
5+
branches:
6+
- "main"
47
pull_request:
58
branches:
69
- "main"
10+
workflow_dispatch:
711

812
jobs:
9-
luacheck:
10-
name: Luacheck
13+
lua:
14+
name: Lint Lua files
1115
runs-on: ubuntu-latest
1216
steps:
1317
- uses: actions/checkout@v4
1418

15-
- name: Prepare
19+
- name: Format
1620
run: |
17-
sudo apt-get update
18-
sudo add-apt-repository universe
19-
sudo apt install luarocks -y
20-
sudo luarocks install luacheck
21+
make formatlua
22+
git diff --exit-code
2123
22-
- name: Run Luacheck
23-
run: sudo ./scripts/style-check.sh
24+
- name: Lint
25+
run: make checklua
2426

25-
stylua:
26-
name: StyLua
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v4
30-
- name: Lint with stylua
31-
uses: JohnnyMorganz/stylua-action@v4
32-
with:
33-
token: ${{ secrets.GITHUB_TOKEN }}
34-
version: latest
35-
args: --check .
36-
37-
format-queries:
38-
name: Lint queries
27+
queries:
28+
name: Lint query files
3929
runs-on: ubuntu-latest
40-
env:
41-
NVIM_TAG: stable
4230
steps:
4331
- uses: actions/checkout@v4
44-
- name: Prepare
45-
run: |
46-
bash ./scripts/ci-install-ubuntu-latest.sh
47-
wget -P scripts/ https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/main/scripts/format-queries.lua
48-
mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start
49-
cd ~/.local/share/nvim/site/pack/nvim-treesitter/start
50-
git clone https://github.com/nvim-treesitter/nvim-treesitter.git
5132

52-
- name: Lint
33+
- name: Format
5334
run: |
54-
nvim --headless -c "TSInstallSync query" -c "q"
55-
nvim -l scripts/format-queries.lua queries
35+
make formatquery
5636
git diff --exit-code
37+
38+
- name: Lint
39+
run: make lintquery
40+

.github/workflows/test.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-build-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
jobs:
21+
check_compilation:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-latest]
26+
nvim_tag: [nightly]
27+
name: ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
29+
env:
30+
NVIM_TS_DIR: .test-deps/nvim-treesitter
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: tree-sitter/setup-action/cli@v1
35+
- uses: ilammy/msvc-dev-cmd@v1
36+
37+
- name: Install and prepare Neovim
38+
env:
39+
NVIM_TAG: ${{ matrix.nvim_tag }}
40+
run: |
41+
bash ./scripts/ci-install.sh
42+
43+
- name: Install nvim-treesitter
44+
uses: actions/checkout@v4
45+
with:
46+
repository: nvim-treesitter/nvim-treesitter
47+
ref: main
48+
path: ${{ env.NVIM_TS_DIR }}
49+
50+
- name: Setup Parsers Cache
51+
id: parsers-cache
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.local/share/nvim/site/parser/
55+
key: parsers-${{ hashFiles('parsers.lua') }}
56+
57+
- name: Compile parsers
58+
if: steps.parsers-cache.outputs.cache-hit != 'true'
59+
working-directory: ${{ env.NVIM_TS_DIR }}
60+
run: nvim -l ./scripts/install-parsers.lua --max-jobs=10
61+
62+
- name: Lint docs
63+
run: |
64+
make docs
65+
git diff --exit-code
66+
67+
- name: Check queries
68+
run: make checkquery
69+
70+
- name: Run tests
71+
run: make tests

.github/workflows/tests.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/update-readme.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.luacheckrc

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/ci-install.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
NVIM_TAG=${NVIM_TAG-nightly}
6+
7+
os=$(uname -s)
8+
if [[ $os == Linux ]]; then
9+
wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim-linux-x86_64.tar.gz"
10+
tar -zxf nvim-linux-x86_64.tar.gz
11+
sudo ln -s "$PWD"/nvim-linux-x86_64/bin/nvim /usr/local/bin
12+
rm -rf "$PWD"/nvim-linu-x86_x64/lib/nvim/parser
13+
elif [[ $os == Darwin ]]; then
14+
RELEASE_NAME="nvim-macos-$(uname -m)"
15+
curl -L "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/$RELEASE_NAME.tar.gz" | tar -xz
16+
sudo ln -s "$PWD/$RELEASE_NAME/bin/nvim" /usr/local/bin
17+
rm -rf "$PWD/$RELEASE_NAME/lib/nvim/parser"
18+
else
19+
curl -L "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim-win64.zip" -o nvim-win64.zip
20+
unzip nvim-win64
21+
fi

scripts/install_parsers.lua

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
#!/usr/bin/env -S nvim -l
2+
vim.opt.runtimepath:append(os.getenv('NVIM_TS'))
3+
vim.opt.runtimepath:append('.')
24

3-
local languages = _G.arg
4-
languages[0] = nil
5+
local parsers = {}
6+
for i = 1, #_G.arg do
7+
parsers[#parsers + 1] = _G.arg[i] ---@type string
8+
end
59

6-
-- needed on CI
7-
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
8-
9-
local done = false
10-
require('nvim-treesitter.install').install(languages, { force = true }, function()
11-
done = true
12-
end)
13-
14-
vim.wait(6000000, function()
15-
return done
16-
end)
10+
require('nvim-treesitter').install(parsers, { force = true }):wait(1800000) -- wait max. 30 minutes

0 commit comments

Comments
 (0)