Skip to content

Commit

Permalink
Improve developer experience (#100)
Browse files Browse the repository at this point in the history
* Make it easy to parse examples locally again

* Use correct linguist attributes for vendored files

* Ignore local test files

* Run github actions on developer branches

* Don't try to publish in forked repositories

* Run example tests in parallel

* Fix generate command
  • Loading branch information
314eter authored Sep 21, 2024
1 parent 14beb5e commit 19639e5
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 62 deletions.
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

grammars/ocaml/src/*.json linguist-generated
grammars/ocaml/src/parser.c linguist-generated
grammars/ocaml/src/tree_sitter/* linguist-generated
grammars/ocaml/src/tree_sitter/* linguist-vendored

grammars/interface/src/*.json linguist-generated
grammars/interface/src/parser.c linguist-generated
grammars/interface/src/tree_sitter/* linguist-generated
grammars/interface/src/tree_sitter/* linguist-vendored

grammars/type/src/*.json linguist-generated
grammars/type/src/parser.c linguist-generated
grammars/type/src/tree_sitter/* linguist-generated
grammars/type/src/tree_sitter/* linguist-vendored

bindings/** linguist-generated
binding.gyp linguist-generated
Expand Down
69 changes: 15 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
name: CI

on:
push:
branches: [master]
paths:
- "scripts.js"
- "common/*"
- "grammars/*/grammar.js"
- "grammars/*/src/**"
- "bindings/**"
- "binding.gyp"
pull_request:
paths:
- "scripts.js"
- "common/*"
- "grammars/*/grammar.js"
- "grammars/*/src/**"
- "bindings/**"
- "binding.gyp"
on: [push, pull_request]

concurrency:
group: ${{github.workflow}}-${{github.ref}}
Expand All @@ -31,46 +14,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
REPOSITORIES: |
0install/0install@225587e
BinaryAnalysisPlatform/bap@f969db3
janestreet/base@1311ac1
dbuenzli/cmdliner@c229193
ocaml/dune@58d1cd3
ocaml-multicore/eio@14ae3cf
ocsigen/js_of_ocaml@d2cf189
garrigue/lablgtk@e2d564b
ocsigen/lwt@73f1a0f
melange-re/melange@01d6ba4
ocaml/merlin@b274d31
ocaml/ocaml@18c4510
mirage/ocaml-cohttp@cf2ae33
ocaml/ocaml-lsp@ad20957
ocaml-ppx/ocamlformat@6ce00bf
ocaml/opam@eafdc81
owlbarn/owl@c66069e
ocaml-ppx/ppxlib@455f217
facebook/pyre-check@5cd77ed
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Set up examples
shell: bash
run: |
while IFS='@' read -r repo_url repo_sha || [ -n "$repo_url" ]; do
if [ -z "$repo_url" ]; then
continue
fi
repo_name=$(basename "$repo_url")
git clone --filter=blob:none --no-checkout "https://github.com/$repo_url" "examples/$repo_name"
(
cd "examples/$repo_name"
git checkout "$repo_sha"
)
done <<< "$REPOSITORIES"
- name: Run tests
uses: tree-sitter/parser-test-action@v2
with:
Expand All @@ -79,8 +27,21 @@ jobs:
test-python: true
test-go: true
test-swift: ${{runner.os == 'macOS'}}
parse-examples:
name: Parse examples
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Parse examples
id: test
uses: tree-sitter/parse-action@v4
with:
files-list: test/files.txt
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ concurrency:

jobs:
npm:
if: github.repository_owner == 'tree-sitter'
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
secrets:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
crates:
if: github.repository_owner == 'tree-sitter'
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
secrets:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
pypi:
if: github.repository_owner == 'tree-sitter'
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
secrets:
PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ dist/
*.dll
*.pc

# Example dirs
/examples/*/

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

# Test files
/test.ml
/test.mli
57 changes: 57 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[submodule "examples/0install"]
path = examples/0install
url = https://github.com/0install/0install
[submodule "examples/bap"]
path = examples/bap
url = https://github.com/BinaryAnalysisPlatform/bap
[submodule "examples/cmdliner"]
path = examples/cmdliner
url = https://github.com/dbuenzli/cmdliner
[submodule "examples/pyre-check"]
path = examples/pyre-check
url = https://github.com/facebook/pyre-check
[submodule "examples/lablgtk"]
path = examples/lablgtk
url = https://github.com/garrigue/lablgtk
[submodule "examples/base"]
path = examples/base
url = https://github.com/janestreet/base
[submodule "examples/melange"]
path = examples/melange
url = https://github.com/melange-re/melange
[submodule "examples/ocaml-cohttp"]
path = examples/ocaml-cohttp
url = https://github.com/mirage/ocaml-cohttp
[submodule "examples/dune"]
path = examples/dune
url = https://github.com/ocaml/dune
[submodule "examples/merlin"]
path = examples/merlin
url = https://github.com/ocaml/merlin
[submodule "examples/ocaml"]
path = examples/ocaml
url = https://github.com/ocaml/ocaml
[submodule "examples/ocaml-lsp"]
path = examples/ocaml-lsp
url = https://github.com/ocaml/ocaml-lsp
[submodule "examples/opam"]
path = examples/opam
url = https://github.com/ocaml/opam
[submodule "examples/eio"]
path = examples/eio
url = https://github.com/ocaml-multicore/eio
[submodule "examples/ocamlformat"]
path = examples/ocamlformat
url = https://github.com/ocaml-ppx/ocamlformat
[submodule "examples/ppxlib"]
path = examples/ppxlib
url = https://github.com/ocaml-ppx/ppxlib
[submodule "examples/js_of_ocaml"]
path = examples/js_of_ocaml
url = https://github.com/ocsigen/js_of_ocaml
[submodule "examples/lwt"]
path = examples/lwt
url = https://github.com/ocsigen/lwt
[submodule "examples/owl"]
path = examples/owl
url = https://github.com/owlbarn/owl
1 change: 1 addition & 0 deletions examples/0install
Submodule 0install added at 225587
1 change: 1 addition & 0 deletions examples/bap
Submodule bap added at aa2165
1 change: 1 addition & 0 deletions examples/base
Submodule base added at 5154f5
1 change: 1 addition & 0 deletions examples/cmdliner
Submodule cmdliner added at cb235b
1 change: 1 addition & 0 deletions examples/dune
Submodule dune added at ec309e
1 change: 1 addition & 0 deletions examples/eio
Submodule eio added at 534f89
1 change: 1 addition & 0 deletions examples/js_of_ocaml
Submodule js_of_ocaml added at c76f8c
1 change: 1 addition & 0 deletions examples/lablgtk
Submodule lablgtk added at afbd6d
1 change: 1 addition & 0 deletions examples/lwt
Submodule lwt added at 48abed
1 change: 1 addition & 0 deletions examples/melange
Submodule melange added at 180707
1 change: 1 addition & 0 deletions examples/merlin
Submodule merlin added at 671ef6
1 change: 1 addition & 0 deletions examples/ocaml
Submodule ocaml added at 74a76c
1 change: 1 addition & 0 deletions examples/ocaml-cohttp
Submodule ocaml-cohttp added at 940ec3
1 change: 1 addition & 0 deletions examples/ocaml-lsp
Submodule ocaml-lsp added at 3dc1a6
1 change: 1 addition & 0 deletions examples/ocamlformat
Submodule ocamlformat added at 923486
1 change: 1 addition & 0 deletions examples/opam
Submodule opam added at ba40b3
1 change: 1 addition & 0 deletions examples/owl
Submodule owl added at 08375e
1 change: 1 addition & 0 deletions examples/ppxlib
Submodule ppxlib added at d940f0
1 change: 1 addition & 0 deletions examples/pyre-check
Submodule pyre-check added at eb1a03
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
},
"scripts": {
"install": "node-gyp-build",
"generate": "for dir in ocaml ocaml_interface ocaml_type; do cd $dir && tree-sitter generate --no-bindings && cd ..; done",
"generate": "for dir in grammars/ocaml grammars/interface grammars/type; do cd $dir; tree-sitter generate --no-bindings; cd -; done",
"prestart": "tree-sitter build ocaml --wasm -o ocaml/tree-sitter-ocaml.wasm",
"start": "tree-sitter playground --grammar-path ocaml",
"test": "node --test bindings/node/*_test.js"
"test": "node --test bindings/node/*_test.js",
"parse-examples": "test/parse-examples.sh"
},
"tree-sitter": [
{
Expand Down

0 comments on commit 19639e5

Please sign in to comment.