Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,41 @@ jobs:
- name: Run unit tests
run: uv run pytest tests/unit/ -v --tb=short

# ---------------------------------------------------------------------------
# tree-sitter floor — installs the declared minimum tree-sitter version and
# compiles every language's query against it. `uv sync` alone always
# resolves the newest tree-sitter, which is why #2165 (13 of 27 language
# queries failing to compile against tree-sitter 0.23.x/0.24.x, with each
# failure silently indexing the language at zero symbols) went uncaught.
# Deliberately narrow: only tree-sitter itself is pinned down to the floor,
# not `--resolution lowest-direct` for the whole dependency set, which
# would fail on unrelated loose floors elsewhere in this repo.
# ---------------------------------------------------------------------------
test-tree-sitter-floor:
name: tree-sitter floor (query compilation)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true

- name: Install dependencies
run: uv sync --all-packages

- name: Pin tree-sitter to the declared floor
run: uv pip install "tree-sitter==0.25.0"

- name: Run query-compilation test
# --no-sync: plain `uv run` re-syncs the venv from uv.lock before
# running, which would silently reinstall the newest tree-sitter and
# undo the pin above.
run: uv run --no-sync pytest tests/unit/ingestion/parser/test_query_compilation.py -v --tb=short

# ---------------------------------------------------------------------------
# Python lint — ruff. Deliberately its own job rather than a step inside the
# test matrix: the result is identical on 3.11/3.12/3.13 (target-version is
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
# HTTP client
"httpx>=0.27,<1",
# AST parsing
"tree-sitter>=0.23,<1",
"tree-sitter>=0.25,<1",
"tree-sitter-python>=0.23,<1",
"tree-sitter-typescript>=0.23,<1",
"tree-sitter-javascript>=0.23,<1",
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/ingestion/parser/test_query_compilation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Every language's tree-sitter query must compile against its grammar.

Regression test for #2165: with `tree-sitter` 0.23.x/0.24.x installed, 13 of
the 27 language queries failed to compile (`Impossible pattern`), and
`_load_compiled_query` swallows that failure and returns `None` — so every
file in the affected languages silently indexed with zero symbols. This
walks the full language registry, compiles each language's query directly,
and asserts on the return value rather than expecting an exception, since
that's exactly what production does.
"""

from __future__ import annotations

import pytest

from repowise.core.ingestion.languages.registry import REGISTRY
from repowise.core.ingestion.parser import QUERIES_DIR, _load_compiled_query


def _languages_with_queries() -> list[str]:
tags = []
for spec in REGISTRY.all_specs():
scm_name = spec.scm_file or f"{spec.tag}.scm"
if (QUERIES_DIR / scm_name).exists():
tags.append(spec.tag)
return sorted(tags)


@pytest.mark.parametrize("lang", _languages_with_queries())
def test_query_compiles(lang: str) -> None:
query = _load_compiled_query(lang)
assert query is not None, f"{lang}: query failed to compile against its grammar"
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading