-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from resolritter/ci
Test parsing for external sources on CI
- Loading branch information
Showing
5 changed files
with
177 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- unlocked | ||
- ready_for_review | ||
|
||
jobs: | ||
test-parsing: | ||
if: github.event.pull_request.draft != true | ||
concurrency: | ||
group: ci-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install the tools | ||
run: npm install | ||
|
||
- name: Run the parsing tests | ||
run: | | ||
npm run generate | ||
npm run test-parsing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ target | |
/bindings/c/tree-sitter-*.pc | ||
/build | ||
/node_modules | ||
/test/sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
zig/test/cases/safety/slice with sentinel out of bounds - runtime len.zig | ||
zig/test/behavior/struct.zig | ||
zig/test/behavior/slice.zig | ||
zig/test/behavior/array.zig | ||
zig/test/behavior/pointers.zig | ||
zig/test/behavior/slice_sentinel_comptime.zig | ||
zig/test/behavior/bugs/12972.zig | ||
zig/test/behavior/packed_struct_explicit_backing_int.zig | ||
zig/lib/std/os.zig | ||
zig/lib/std/array_hash_map.zig | ||
zig/lib/std/hash/auto_hash.zig | ||
zig/lib/std/fs.zig | ||
zig/lib/std/mem.zig | ||
zig/lib/std/zig/c_translation.zig | ||
zig/lib/std/zig/system/windows.zig | ||
zig/lib/std/os/test.zig | ||
zig/lib/std/os/linux/bpf/btf.zig | ||
zig/lib/std/os/linux/bpf.zig | ||
zig/lib/std/os/windows.zig | ||
zig/lib/std/os/uefi/protocols/ip6_protocol.zig | ||
zig/lib/std/os/uefi/protocols/hii.zig | ||
zig/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig | ||
zig/lib/std/os/uefi/protocols/simple_network_protocol.zig | ||
zig/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig | ||
zig/lib/std/os/uefi/protocols/edid_override_protocol.zig | ||
zig/lib/std/os/uefi/tables/boot_services.zig | ||
zig/lib/std/unicode.zig | ||
zig/lib/std/meta/trait.zig | ||
zig/lib/std/Thread.zig | ||
zig/lib/std/mem/Allocator.zig | ||
zig/lib/std/json/test.zig | ||
zig/lib/std/child_process.zig | ||
zig/lib/std/macho.zig | ||
zig/lib/std/process.zig | ||
zig/lib/std/dwarf.zig | ||
zig/lib/std/json.zig | ||
zig/lib/std/c/openbsd.zig | ||
zig/lib/std/meta.zig | ||
zig/src/main.zig | ||
zig/src/link/Wasm/Object.zig | ||
zig/src/link/Wasm/Archive.zig | ||
zig/src/link/MachO/Archive.zig | ||
zig/src/Air.zig | ||
zig/src/codegen/llvm/bindings.zig | ||
zig/src/Autodoc.zig | ||
zig/src/Zir.zig | ||
zig/tools/process_headers.zig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/env bash | ||
# adapted from tree-sitter-typescript/script/parse-examples | ||
|
||
set -Eeu -o pipefail | ||
shopt -s inherit_errexit | ||
|
||
this_file="${BASH_SOURCE[0]}" | ||
if [ "${this_file::1}" != '/' ]; then | ||
this_file="$PWD/$this_file" | ||
fi | ||
|
||
this_dir="${this_file%/*}" | ||
project_root="${this_dir%/*}" | ||
sources_dir="$project_root/test/sources" | ||
|
||
cd "$project_root" | ||
|
||
clone_repo() { | ||
local owner=$1 | ||
local name=$2 | ||
local sha=$3 | ||
local path="$sources_dir/$name" | ||
|
||
if [ -d "$path" ]; then | ||
pushd "$path" > /dev/null | ||
if [ "$(git rev-parse HEAD 2>/dev/null)" == "$sha" ]; then | ||
popd > /dev/null | ||
return | ||
else | ||
popd > /dev/null | ||
rm -rf "$path" | ||
echo "Updating $owner/$name to $sha" | ||
fi | ||
else | ||
echo "Cloning $owner/$name" | ||
fi | ||
|
||
mkdir -p "$path" | ||
pushd "$path" > /dev/null | ||
git init --quiet | ||
git remote add origin "https://github.com/$owner/$name" | ||
git pull --quiet --ff-only --depth 1 origin "$sha" | ||
popd > /dev/null | ||
} | ||
|
||
# zig 0.10.1 -> https://github.com/ziglang/zig/releases/tag/0.10.1 | ||
clone_repo ziglang zig b57081f039bd3f8f82210e8896e336e3c3a6869b | ||
|
||
known_failures=() | ||
while IFS= read -r line; do | ||
if [[ "$line" =~ [^[:space:]] ]]; then | ||
full_path="$sources_dir/$line" | ||
if [ -e "$full_path" ]; then | ||
if tree-sitter parse -q "$full_path" &>/dev/null; then | ||
>&2 echo "File $full_path can be parsed without errors, but it's listed in $this_dir/known-parsing-failures.txt" | ||
saw_error=true | ||
else | ||
known_failures+=("$sources_dir/$line") | ||
fi | ||
else | ||
>&2 echo "File $full_path (listed in $this_dir/known-parsing-failures.txt) does not exist" | ||
saw_error=true | ||
fi | ||
fi | ||
done < "$this_dir/known-parsing-failures.txt" | ||
if [ "${saw_error:-}" ]; then | ||
exit 1 | ||
fi | ||
|
||
while IFS= read -r line; do | ||
for known_failure in "${known_failures[@]}"; do | ||
if [ "$known_failure" == "$line" ]; then | ||
continue 2 | ||
fi | ||
done | ||
parse_args+=("$line") | ||
done < <( | ||
find "$sources_dir" \ | ||
-name "*.zig" \ | ||
-not -path "$sources_dir/zig/test/cases/compile_errors/**" | ||
) | ||
if [ ${#parse_args[*]} -eq 0 ]; then | ||
>&2 echo "No files found to test" | ||
exit 1 | ||
fi | ||
|
||
echo "[STEP] The following files will be tested:" | ||
printf "%s\n" "${parse_args[@]}" | ||
|
||
tree-sitter parse -q "${parse_args[@]}" |