Skip to content

Commit f0e043f

Browse files
committed
ci: add corpus test
Problem: PRs are not tested against the variety of queries in the wild. Solution: Include a corpus test using nvim-treesitter's queries.
1 parent bf20dcd commit f0e043f

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches: ['master']
55
pull_request:
66
branches: ['master']
7+
78
permissions:
89
contents: read
910

@@ -42,6 +43,54 @@ jobs:
4243
id: toolchain
4344
- run: cargo test
4445

46+
corpus:
47+
name: Corpus test
48+
runs-on: ubuntu-latest
49+
timeout-minutes: 10
50+
env:
51+
NVIM_TS_DIR: .test/nvim-treesitter
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: tree-sitter/setup-action/cli@v1
55+
- uses: dtolnay/rust-toolchain@1.86.0
56+
id: toolchain
57+
58+
- name: Compile
59+
run: |
60+
cargo build --release
61+
echo ${{ github.workspace }}/target/release >> $GITHUB_PATH
62+
63+
- name: Clone nvim-treesitter corpus
64+
uses: actions/checkout@v4
65+
with:
66+
repository: nvim-treesitter/nvim-treesitter
67+
ref: main
68+
path: ${{ env.NVIM_TS_DIR }}
69+
70+
- name: Setup parsers cache
71+
id: parsers-cache
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.local/share/nvim/site/parser/
75+
key: parsers-${{ hashFiles('**/lua/nvim-treesitter/parsers.lua') }}
76+
77+
- name: Compile parsers
78+
if: steps.parsers-cache.outputs.cache-hit != 'true'
79+
working-directory: ${{ env.NVIM_TS_DIR }}
80+
run: |
81+
bash ./scripts/ci-install.sh
82+
nvim -l ./scripts/install-parsers.lua
83+
84+
- name: Check corpus
85+
working-directory: ${{ env.NVIM_TS_DIR }}
86+
run: ts_query_ls check runtime/queries
87+
88+
- name: Format corpus
89+
working-directory: ${{ env.NVIM_TS_DIR }}
90+
run: |
91+
ts_query_ls format runtime/queries
92+
git diff --exit-code
93+
4594
generate-schema:
4695
name: Generate schema
4796
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)