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:
Christian Clason 2025-04-29 19:40:18 +02:00
parent 4e906caca3
commit 53dccb3a77
19 changed files with 269 additions and 272 deletions

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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"

View file

@ -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

View file

@ -2,7 +2,7 @@ name: Update parsers
on:
schedule:
- cron: "30 6 * * *"
- cron: "30 6 * * 6"
workflow_dispatch:
env:

View file

@ -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