Skip to content

Commit 409c16a

Browse files
committed
Added workflow
1 parent 650315b commit 409c16a

File tree

6 files changed

+78
-1398
lines changed

6 files changed

+78
-1398
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
- test_on_cpp2_files.sh
13+
pull_request:
14+
paths:
15+
- grammar.js
16+
- src/**
17+
- test/**
18+
- bindings/**
19+
- binding.gyp
20+
- test_on_cpp2_files.sh
21+
22+
concurrency:
23+
group: ${{github.workflow}}-${{github.ref}}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
test:
28+
name: Test parser
29+
runs-on: ${{matrix.os}}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os: [ubuntu-latest]
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
- name: Checkout tree-sitter-c
38+
uses: actions/checkout@v4
39+
with:
40+
repository: tree-sitter/tree-sitter-c
41+
path: node_modules/tree-sitter-c
42+
sparse-checkout: queries/
43+
ref: v0.21.4
44+
- name: Checkout tree-sitter-cpp
45+
uses: actions/checkout@v4
46+
with:
47+
repository: tree-sitter/tree-sitter-cpp
48+
path: node_modules/tree-sitter-cpp
49+
sparse-checkout: queries/
50+
ref: v0.22.3
51+
- name: Set up tree-sitter
52+
uses: tree-sitter/setup-action/cli@v1
53+
- name: Run tests
54+
uses: tree-sitter/parser-test-action@v2
55+
with:
56+
test-rust: ${{runner.os == 'Linux'}}
57+
test-node: true
58+
test-python: true
59+
test-go: true
60+
- name: Clone cppfront
61+
run: git clone https://github.com/hsutter/cppfront.git
62+
- name: Find and parse cpp2 files
63+
run: ./test_on_cpp2_files.sh ./cppfront

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ dist/
4242
example-file.txt
4343
log.html
4444
cppfront
45+
cpp2_files.txt

TODO.md

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

test.cpp2

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

test_on_cpp2_files.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/bash
22
set -e
33

4-
echo "Generating parser ..."
5-
tree-sitter generate
6-
echo "Done"
7-
84
# Directory to search
95
search_dir="$1"
106
echo "Looking for files in \"${search_dir}\""
@@ -25,9 +21,21 @@ for pattern in "${exclude_patterns[@]}"; do
2521
find_command+=" ! -name \"$pattern\""
2622
done
2723

28-
find_command="$find_command -exec sh -c 'tree-sitter parse -q "\$1" || exit 255' _ {} \;"
24+
if [ -f cpp2_files.txt ]; then
25+
echo "Aborting: 'cpp2_files.txt' already exists"
26+
exit 1
27+
fi
28+
29+
# find_command="$find_command -exec sh -c 'tree-sitter parse -q "\$1" || exit 255' _ {} \;"
2930
echo "Command: " $find_command
30-
eval $find_command
31+
eval $find_command > cpp2_files.txt
32+
33+
while IFS= read -r file; do
34+
echo "Parsing '$file'"
35+
tree-sitter parse -q "$file"
36+
done < cpp2_files.txt
37+
38+
rm cpp2_files.txt
3139

3240
echo "Done"
3341

0 commit comments

Comments
 (0)