mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
feat(tests)!: new infrastructure based on makefile
Problem: Not easy to run all checks and tests locally. Redundant CI workflows. Solution: Separate CI into two workflows: * lint: Lua files (stylua, luals), query files (valid captures, predicates, directives using tsqueryls), docs (SUPPORTED_LANGUAGES.md) -- does not need parser installation * tests: parsers (ABI compatibility), query files (tsqueryls on Linux/macOS; nvim on Windows), highlight and indent tests (separated for better readability) -- needs parser installation (but only once) Switch to https://github.com/nvim-treesitter/highlight-assertions fork with ABI 15 support. Run all tests (on Linux and macOS) through `make` (`formatlua`, `checklua`, `lintquery`, `formatquery`, `checkquery`, `docs`, `tests`), which downloads and caches all necessary dependencies. Remove `update-readme` workflow (replaced by lint job on PRs).
This commit is contained in:
parent
4e906caca3
commit
53dccb3a77
19 changed files with 269 additions and 272 deletions
68
.github/workflows/lint.yml
vendored
68
.github/workflows/lint.yml
vendored
|
|
@ -1,52 +1,50 @@
|
|||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
pull_request:
|
||||
branches:
|
||||
- "main"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
luacheck:
|
||||
name: Luacheck
|
||||
lua:
|
||||
name: Lint Lua files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Prepare
|
||||
- name: Format
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install luarocks -y
|
||||
sudo luarocks install luacheck
|
||||
|
||||
- name: Run Luacheck
|
||||
run: luacheck .
|
||||
|
||||
stylua:
|
||||
name: StyLua
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Lint with stylua
|
||||
uses: JohnnyMorganz/stylua-action@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: latest
|
||||
args: --check .
|
||||
|
||||
format-queries:
|
||||
name: Format queries
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
NVIM_TAG: nightly
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tree-sitter/setup-action/cli@v1
|
||||
- name: Prepare
|
||||
run: |
|
||||
bash ./scripts/ci-install.sh
|
||||
make formatlua
|
||||
git diff --exit-code
|
||||
|
||||
- name: Lint
|
||||
run: make checklua
|
||||
|
||||
queries:
|
||||
name: Lint query files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Format
|
||||
run: |
|
||||
nvim -l scripts/install-parsers.lua query
|
||||
nvim -l scripts/format-queries.lua
|
||||
make formatquery
|
||||
git diff --exit-code
|
||||
|
||||
- name: Lint
|
||||
run: make lintquery
|
||||
|
||||
readme:
|
||||
name: Lint docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check SUPPORTED_LANGUAGES
|
||||
run: |
|
||||
make docs
|
||||
git diff --exit-code
|
||||
|
|
|
|||
22
.github/workflows/test-core.yml
vendored
22
.github/workflows/test-core.yml
vendored
|
|
@ -35,7 +35,7 @@ jobs:
|
|||
name: Generate and compile parsers
|
||||
run: $NVIM -l ./scripts/install-parsers.lua --generate --max-jobs=2
|
||||
|
||||
- if: inputs.type == 'queries'
|
||||
- if: inputs.type == 'build'
|
||||
name: Setup Parsers Cache
|
||||
id: parsers-cache
|
||||
uses: actions/cache@v4
|
||||
|
|
@ -47,9 +47,25 @@ jobs:
|
|||
'./lua/nvim-treesitter/install.lua',
|
||||
'./lua/nvim-treesitter/parsers.lua') }}
|
||||
|
||||
- if: inputs.type == 'queries'
|
||||
- if: inputs.type == 'build'
|
||||
name: Compile parsers
|
||||
run: $NVIM -l ./scripts/install-parsers.lua
|
||||
|
||||
- name: Check query files
|
||||
- name: Check parsers
|
||||
run: $NVIM -l ./scripts/check-parsers.lua
|
||||
|
||||
- name: Check queries (nvim)
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: $NVIM -l ./scripts/check-queries.lua
|
||||
|
||||
- name: Check queries (tsqueryls)
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: make checkquery
|
||||
|
||||
- name: Run highlight tests
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: make tests TESTS=query NVIM_BIN=$NVIM
|
||||
|
||||
- name: Run indents tests
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: make tests TESTS=indent NVIM_BIN=$NVIM
|
||||
|
|
|
|||
6
.github/workflows/test-generate.yml
vendored
6
.github/workflows/test-generate.yml
vendored
|
|
@ -1,4 +1,4 @@
|
|||
name: Generate from grammar
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
|
@ -8,12 +8,12 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
group: ${{ github.workflow }}-generate-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
check_compilation:
|
||||
name: Build
|
||||
name: Generate
|
||||
if: contains(github.event.pull_request.labels.*.name, 'ci:generate') || github.event_name == 'workflow_dispatch'
|
||||
uses: ./.github/workflows/test-core.yml
|
||||
with:
|
||||
|
|
|
|||
10
.github/workflows/test-queries.yml
vendored
10
.github/workflows/test-queries.yml
vendored
|
|
@ -1,12 +1,16 @@
|
|||
name: Check queries
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
pull_request:
|
||||
branches:
|
||||
- "main"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
group: ${{ github.workflow }}-build-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
|
|
@ -14,4 +18,4 @@ jobs:
|
|||
name: Build
|
||||
uses: ./.github/workflows/test-core.yml
|
||||
with:
|
||||
type: "queries"
|
||||
type: "build"
|
||||
|
|
|
|||
60
.github/workflows/tests.yml
vendored
60
.github/workflows/tests.yml
vendored
|
|
@ -1,60 +0,0 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
# push:
|
||||
# branches:
|
||||
# - "main"
|
||||
pull_request:
|
||||
branches:
|
||||
- "main"
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-progress CI runs for a PR if it is updated
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check_compilation:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
|
||||
name: Run tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tree-sitter/setup-action/cli@v1
|
||||
|
||||
- name: Test Dependencies
|
||||
run: |
|
||||
mkdir -p ~/.local/share/nvim/site/pack/plenary.nvim/start
|
||||
cd ~/.local/share/nvim/site/pack/plenary.nvim/start
|
||||
git clone https://github.com/nvim-lua/plenary.nvim
|
||||
curl -L https://github.com/theHamsta/highlight-assertions/releases/download/v0.1.6/highlight-assertions_v0.1.6_x86_64-unknown-linux-gnu.tar.gz | tar -xz
|
||||
cp highlight-assertions /usr/local/bin
|
||||
|
||||
- name: Install and prepare Neovim
|
||||
env:
|
||||
NVIM_TAG: nightly
|
||||
TREE_SITTER_CLI_TAG: v0.20.8
|
||||
run: |
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Setup Parsers Cache
|
||||
id: parsers-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.local/share/nvim/site/parser/
|
||||
~/AppData/Local/nvim-data/site/parser/
|
||||
key: parsers-${{ join(matrix.*, '-') }}-${{ hashFiles(
|
||||
'./lua/nvim-treesitter/install.lua',
|
||||
'./lua/nvim-treesitter/parsers.lua') }}
|
||||
|
||||
- name: Compile parsers
|
||||
run: nvim -l ./scripts/install-parsers.lua
|
||||
|
||||
- name: Tests
|
||||
run: PATH=/usr/local/bin:$PATH ./scripts/run_tests.sh
|
||||
2
.github/workflows/update-parsers.yml
vendored
2
.github/workflows/update-parsers.yml
vendored
|
|
@ -2,7 +2,7 @@ name: Update parsers
|
|||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 6 * * *"
|
||||
- cron: "30 6 * * 6"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
|
|||
47
.github/workflows/update-readme.yml
vendored
47
.github/workflows/update-readme.yml
vendored
|
|
@ -1,47 +0,0 @@
|
|||
name: Update README
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update-readme:
|
||||
name: Update README
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/create-github-app-token@v2
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.TOKEN_ID }}
|
||||
private-key: ${{ secrets.TOKEN_PRIVATE_KEY }}
|
||||
|
||||
- name: Prepare
|
||||
env:
|
||||
NVIM_TAG: nightly
|
||||
run: |
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Check README
|
||||
run: |
|
||||
nvim -l scripts/update-readme.lua || echo 'Needs update'
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
add-paths: SUPPORTED_LANGUAGES.md
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
sign-commits: true
|
||||
commit-message: "bot(readme): update"
|
||||
title: Update SUPPORTED_LANGUAGES.md
|
||||
body: "[beep boop](https://github.com/peter-evans/create-pull-request)"
|
||||
branch: update-readme-pr
|
||||
base: ${{ github.head_ref }}
|
||||
|
||||
- name: Enable Pull Request Automerge
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
run: gh pr merge --rebase --auto update-readme-pr
|
||||
Loading…
Add table
Add a link
Reference in a new issue