Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CI workflow, and update tree-sitter #4

Merged
merged 9 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,toml,yml,gyp}]
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.rs]
indent_style = space
indent_size = 4

[*.{c,cc,h}]
indent_style = space
indent_size = 4

[*.{py,pyi}]
indent_style = space
indent_size = 4

[*.swift]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
indent_size = 8

[Makefile]
indent_style = tab
indent_size = 8
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text eol=lf

src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated
Package.swift linguist-generated
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
pull_request:
branches:
- "**"
push:
branches:
- "main"

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
test:
name: Test parser
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Run parser and binding tests
uses: tree-sitter/parser-test-action@v2
with:
test-rust: ${{runner.os == 'Linux'}}
test-swift: ${{runner.os == 'macOS'}}
- name: Parse sample files
uses: tree-sitter/parse-action@v4
id: parse-files
with:
files: examples/**
- name: Upload failures artifact
uses: actions/upload-artifact@v4
if: "!cancelled() && steps.parse-files.outcome == 'failure'"
with:
name: failures-${{runner.os}}
path: ${{steps.parse-files.outputs.failures}}
fuzz:
name: Fuzz scanner
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for scanner changes
id: scanner-check
run: |-
if git diff --quiet HEAD^ -- src/scanner.c; then
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
else
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
fi
- name: Run the fuzzer
uses: tree-sitter/fuzz-action@v4
if: steps.scanner-check.outputs.changed == 'true'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
target/
71 changes: 71 additions & 0 deletions Cargo.lock

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

25 changes: 11 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
[package]
name = "tree-sitter-ql-dbscheme"
description = "ql dbscheme grammar for the tree-sitter parsing library"
name = "tree-sitter-dbscheme"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this rename. The repo is still called tree-sitter-ql-dbscheme, after all.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the parser is. Having the repo named different from the language is not really intended.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is because the name in gammar.js is wrong. The generate script is copy-pasting from there.
I'm fixing it.

Copy link
Collaborator

@tausbn tausbn May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. The parser is what? (Edit: Ah, @erik-krogh's interim answer cleared this up for me.)

Currently, the name of the parser is tree-sitter-ql-dbscheme. This is also how the (to my knowledge) only downstream user refers to it.

To be clear, I would be happy to see this renamed to tree-sitter-dbscheme. The original name contained -ql- out of an abundance of caution, in case some other user of dbscheme was out there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the grammar is named dbscheme.
I cannot change it to ql-dbscheme, because then tree-sitter gives me the following error:
Error: Grammar's 'name' property must not start with a digit and cannot contain non-word characters..

What can we do?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try underscore instead? ql_dbscheme

Copy link

@clason clason May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(To be clear, I'm not saying you're doing it wrong; I'm just pointing out that the tooling is built with different expectations, so you can't trust it blindly if you deviate. You'll just have to postprocess manually.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Underscore seem to work

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, a number of other grammars use that trick.

description = "Dbscheme grammar for tree-sitter"
version = "0.0.1"
keywords = ["incremental", "parsing", "ql"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tausbn/tree-sitter-ql-dbscheme"
edition = "2018"
license = "MIT"
readme = "README.md"
keywords = ["incremental", "parsing", "tree-sitter", "dbscheme"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-dbscheme"
tausbn marked this conversation as resolved.
Show resolved Hide resolved
edition = "2021"
autoexamples = false

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = ">= 0.20, < 0.21"
tree-sitter = ">=0.22.5"

[build-dependencies]
cc = "1.0"
cc = "1.0.87"
112 changes: 112 additions & 0 deletions Makefile

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

47 changes: 47 additions & 0 deletions Package.swift

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

Loading
Loading