Skip to content

Commit df4e4c8

Browse files
authored
chore: CI workflow update (#213)
Include language binding tests and parsing statistics of [nushell/nu_scripts](https://github.com/nushell/nu_scripts)
1 parent 436b3f9 commit df4e4c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2515
-882
lines changed

.editorconfig

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ root = true
22

33
[*]
44
charset = utf-8
5-
end_of_line = lf
6-
insert_final_newline = true
7-
trim_trailing_whitespace = true
85

96
[*.{json,toml,yml,gyp}]
107
indent_style = space
@@ -14,14 +11,18 @@ indent_size = 2
1411
indent_style = space
1512
indent_size = 2
1613

17-
[*.rs]
14+
[*.scm]
1815
indent_style = space
19-
indent_size = 4
16+
indent_size = 2
2017

2118
[*.{c,cc,h}]
2219
indent_style = space
2320
indent_size = 4
2421

22+
[*.rs]
23+
indent_style = space
24+
indent_size = 4
25+
2526
[*.{py,pyi}]
2627
indent_style = space
2728
indent_size = 4
@@ -37,3 +38,9 @@ indent_size = 8
3738
[Makefile]
3839
indent_style = tab
3940
indent_size = 8
41+
42+
[parser.c]
43+
indent_size = 2
44+
45+
[{alloc,array,parser}.h]
46+
indent_size = 2

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
# Example of a `.gitattributes` file which reclassifies `.nu` files as Nushell:
44
*.nu linguist-language=Nushell
5+
6+
# Zig bindings
7+
build.zig linguist-generated
8+
build.zig.zon linguist-generated

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- grammar.js
8+
- src/**
9+
- test/**
10+
- bindings/**
11+
- binding.gyp
12+
pull_request:
13+
paths:
14+
- grammar.js
15+
- src/**
16+
- test/**
17+
- bindings/**
18+
- binding.gyp
19+
20+
concurrency:
21+
group: ${{github.workflow}}-${{github.ref}}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
test:
26+
name: Test parser
27+
runs-on: ${{matrix.os}}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [ubuntu-latest, windows-latest, macos-14]
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
- name: Set up tree-sitter
36+
uses: tree-sitter/setup-action/cli@v2
37+
- name: Set up examples
38+
shell: bash
39+
run: |-
40+
git clone https://github.com/nushell/nu_scripts examples/nu_scripts -q --single-branch --depth=1
41+
- name: Run tests
42+
uses: tree-sitter/parser-test-action@v2
43+
with:
44+
generate: false
45+
test-rust: true
46+
test-node: true
47+
test-python: true
48+
test-go: true
49+
test-swift: false
50+
- name: Parse examples
51+
uses: tree-sitter/parse-action@v4
52+
with:
53+
files: |-
54+
examples/nu_scripts/**/*.nu
55+
invalid-files-list: script/known-failures.txt

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- grammar.js
8+
pull_request:
9+
paths:
10+
- grammar.js
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
cache: npm
22+
node-version: ${{vars.NODE_VERSION}}
23+
- name: Install modules
24+
run: npm ci --legacy-peer-deps
25+
- name: Run ESLint
26+
run: npm run lint
27+
- name: Run Prettier
28+
run: npm run format

.github/workflows/main.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish packages
2+
3+
on:
4+
push:
5+
tags: ['*']
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
attestations: write
11+
12+
jobs:
13+
github:
14+
uses: tree-sitter/workflows/.github/workflows/release.yml@main
15+
with:
16+
generate: true
17+
attestations: true
18+
# npm:
19+
# uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
20+
# secrets:
21+
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
22+
# with:
23+
# generate: true
24+
# crates:
25+
# uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
26+
# secrets:
27+
# CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
28+
# with:
29+
# generate: true
30+
# pypi:
31+
# uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
32+
# secrets:
33+
# PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
34+
# with:
35+
# generate: true

.gitignore

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
1-
node_modules/
2-
log.html
1+
# Rust artifacts
32
target/
43

5-
/build/
4+
# Node artifacts
5+
build/
6+
prebuilds/
7+
node_modules/
8+
9+
# Swift artifacts
10+
.build/
11+
12+
# Go artifacts
13+
_obj/
14+
15+
# Python artifacts
16+
.venv/
17+
dist/
18+
*.egg-info
19+
*.whl
20+
21+
# C artifacts
22+
*.a
23+
*.so
24+
*.so.*
25+
*.dylib
26+
*.dll
27+
*.pc
28+
*.exp
29+
*.lib
630

7-
# C lsp cache
8-
.ccls-cache/
31+
# Zig artifacts
32+
.zig-cache/
33+
zig-cache/
34+
zig-out/
935

10-
# Workspace Config
11-
.nvim/
12-
# .vscode/
36+
# Example dirs
37+
/examples/*/
38+
/script/example-files.txt
1339

14-
# MSVC compile output
15-
/parser.exp
16-
/parser.lib
17-
/parser.obj
40+
# Grammar volatiles
1841
*.wasm
42+
*.obj
43+
*.o
1944

20-
# macOS junk
21-
.DS_Store
45+
# Archives
46+
*.tar.gz
47+
*.tgz
48+
*.zip

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"printWidth": 80,
6+
"trailingComma": "all"
7+
}

CMakeLists.txt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(tree-sitter-nu
4+
VERSION "0.0.1"
5+
DESCRIPTION "Nu grammar for tree-sitter"
6+
HOMEPAGE_URL "https://github.com/nushell/tree-sitter-nu"
7+
LANGUAGES C)
8+
9+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
10+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)
11+
12+
set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
13+
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
14+
unset(TREE_SITTER_ABI_VERSION CACHE)
15+
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
16+
endif()
17+
18+
find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")
19+
20+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
21+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
22+
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
23+
--abi=${TREE_SITTER_ABI_VERSION}
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
25+
COMMENT "Generating parser.c")
26+
27+
add_library(tree-sitter-nu src/parser.c)
28+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
29+
target_sources(tree-sitter-nu PRIVATE src/scanner.c)
30+
endif()
31+
target_include_directories(tree-sitter-nu
32+
PRIVATE src
33+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/bindings/c>
34+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
35+
36+
37+
target_compile_definitions(tree-sitter-nu PRIVATE
38+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
39+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
40+
41+
set_target_properties(tree-sitter-nu
42+
PROPERTIES
43+
C_STANDARD 11
44+
POSITION_INDEPENDENT_CODE ON
45+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
46+
DEFINE_SYMBOL "")
47+
48+
configure_file(bindings/c/tree-sitter-nu.pc.in
49+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-nu.pc" @ONLY)
50+
51+
include(GNUInstallDirs)
52+
53+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bindings/c/tree_sitter"
54+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
55+
FILES_MATCHING PATTERN "*.h")
56+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-nu.pc"
57+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
58+
install(TARGETS tree-sitter-nu
59+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
60+
61+
add_custom_target(ts-test "${TREE_SITTER_CLI}" test
62+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
63+
COMMENT "tree-sitter test")

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "nu grammar for the tree-sitter parsing library"
44
version = "0.0.1"
55
keywords = ["incremental", "parsing", "nu"]
66
categories = ["parsing", "text-editors"]
7-
repository = "https://github.com/tree-sitter/tree-sitter-nu"
7+
repository = "https://github.com/nushell/tree-sitter-nu"
88
edition = "2018"
99
license = "MIT"
1010

0 commit comments

Comments
 (0)