Skip to content

Commit

Permalink
Updating CI for tree-sitter-teal (#30)
Browse files Browse the repository at this point in the history
(Pared down from original commit list)

 - Update and rename test.yml to ci.yml
 - Update ci.yml
 - Create lint.yml
 - Create publish.yml
 - trying to update for new tree-sitter
 - rust bindings
 - updating package.json
 - updated package lock
 - updating binding.gyp to include scanner and added eslint config
 - added scanner to Package.swift and setup.py
 - updated rust and python bindings with queries
 - updated js deps
  • Loading branch information
FourierTransformer authored Nov 14, 2024
1 parent 485fbdc commit a8901ac
Show file tree
Hide file tree
Showing 34 changed files with 8,997 additions and 7,487 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches: [main]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp

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@v2
- name: Run tests
uses: tree-sitter/parser-test-action@v2
with:
test-rust: true
test-node: true
test-python: true
test-go: true
test-swift: true
- name: Parse examples
uses: tree-sitter/parse-action@v4
with:
files: examples/*
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
branches: [main]
paths:
- grammar.js
pull_request:
paths:
- grammar.js

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{vars.NODE_VERSION}}
- name: Install modules
run: npm ci --legacy-peer-deps
- name: Run ESLint
run: npm run lint
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish packages

on:
push:
tags: ["*"]

permissions:
contents: write
id-token: write
attestations: write

jobs:
github:
uses: tree-sitter/workflows/.github/workflows/release.yml@main
with:
generate: true
attestations: true
# would need to setup the requisite tokens and then re-enable.
# npm:
# uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
# secrets:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# with:
# generate: true
# crates:
# uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
# secrets:
# CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
# with:
# generate: true
# pypi:
# uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
# secrets:
# PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
# with:
# generate: true
32 changes: 0 additions & 32 deletions .github/workflows/test.yml

This file was deleted.

43 changes: 37 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
node_modules
build
parser.so
Cargo.toml
Cargo.lock
# Rust artifacts
target/

# Node artifacts
build/
prebuilds/
node_modules/

# Swift artifacts
.build/

# Go artifacts
_obj/

# Python artifacts
.venv/
dist/
*.egg-info
*.whl

# C artifacts
*.a
*.so
*.so.*
*.dylib
*.dll
*.pc
src/*.o

# Example dirs
/examples/*/

# Grammar volatiles
*.wasm
*.obj
*.o

# Archives
*.tar.gz
*.tgz
*.zip
58 changes: 58 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.13)

project(tree-sitter-teal
VERSION "0.0.4"
DESCRIPTION "Tree sitter parser for Teal, a typed dialect of Lua."
HOMEPAGE_URL "https://github.com/tree-sitter/tree-sitter-teal"
LANGUAGES C)

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)

set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
unset(TREE_SITTER_ABI_VERSION CACHE)
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
endif()

find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")

add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
--abi=${TREE_SITTER_ABI_VERSION}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Generating parser.c")

add_library(tree-sitter-teal src/parser.c)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
target_sources(tree-sitter-teal PRIVATE src/scanner.c)
endif()
target_include_directories(tree-sitter-teal PRIVATE src)

target_compile_definitions(tree-sitter-teal PRIVATE
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)

set_target_properties(tree-sitter-teal
PROPERTIES
C_STANDARD 11
POSITION_INDEPENDENT_CODE ON
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
DEFINE_SYMBOL "")

configure_file(bindings/c/tree-sitter-teal.pc.in
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-teal.pc" @ONLY)

include(GNUInstallDirs)

install(FILES bindings/c/tree-sitter-teal.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-teal.pc"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
install(TARGETS tree-sitter-teal
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

add_custom_target(ts-test "${TREE_SITTER_CLI}" test
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "tree-sitter test")
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "tree-sitter-teal"
description = "Tree sitter parser for Teal, a typed dialect of Lua."
version = "0.0.4"
authors = ["euclidianAce"]
license = "MIT"
readme = "README.md"
keywords = ["incremental", "parsing", "tree-sitter", "teal"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-teal"
edition = "2021"
autoexamples = false

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

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

[dependencies]
tree-sitter-language = "0.1"

[build-dependencies]
cc = "1.1.22"

[dev-dependencies]
tree-sitter = "0.24.4"
60 changes: 25 additions & 35 deletions Package.swift

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

2 changes: 1 addition & 1 deletion binding.gyp

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

15 changes: 7 additions & 8 deletions bindings/c/tree-sitter-teal.pc.in

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

2 changes: 1 addition & 1 deletion bindings/go/binding.go

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

4 changes: 2 additions & 2 deletions bindings/go/binding_test.go

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

Loading

0 comments on commit a8901ac

Please sign in to comment.