Skip to content

Add & reorganize syntax tests #426

Add & reorganize syntax tests

Add & reorganize syntax tests #426

Workflow file for this run

name: Build & Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false
steps:
# Dependencies
- name: Clone repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
if: matrix.os != 'windows-latest' # Windows is slow
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup rust
run: rustup default stable
- name: Install setuptools for Windows build
if: matrix.os == 'windows-latest'
run: python -m pip install --upgrade setuptools
- name: Install Dependencies & Build
run: npm install
# Validation
- name: Unit Tests
run: ./node_modules/.bin/tree-sitter test
- name: Crash Regression Tests
shell: bash
run: |
./node_modules/.bin/tree-sitter init-config
./node_modules/.bin/tree-sitter parse -q test/crash_regressions/QEDErrorRecovery.tla || (($? == 1))
./node_modules/.bin/tree-sitter parse -q test/crash_regressions/QEDErrorRecovery2.tla || (($? == 1))
- name: Corpus Tests (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: .\test\run-corpus.ps1
- name: Corpus Tests (Linux & macOS)
if: matrix.os != 'windows-latest'
shell: bash
run: ./test/run-corpus.sh
- name: Query File Tests
shell: pwsh
run: |
$query_files = Get-ChildItem `
-Path @(".\queries", ".\integrations") `
-Filter "*.scm" `
-Recurse
$results = $query_files.FullName `
|% { `
Write-Host (Resolve-Path -Path $_ -Relative); `
./node_modules/.bin/tree-sitter query $_ ./test/examples/Highlight.tla | Out-Null; `
$lastexitcode `
}
$failures = $results |? {$_ -ne 0}
exit $failures.length
- name: Generate parser code
run: |
./node_modules/.bin/tree-sitter --version
./node_modules/.bin/tree-sitter generate
- name: Renormalize line endings
shell: bash
run: |
git status
git add --renormalize .
- name: List parser info & changes
shell: bash
run: |
# Print size - the generated parser is quite large!
ls -sh src/parser.c
# Hash (for debugging issues like https://github.com/tree-sitter/tree-sitter/issues/2755)
openssl dgst -sha256 src/parser.c
# List differences caused by regenerating parser
git status
git diff | wc
- name: Check grammar/code sync
shell: bash
run: |
# Command from https://stackoverflow.com/a/62768943/2852699
diff_count=$(git status --porcelain=v1 2>/dev/null | wc -l)
exit $diff_count
- name: Test rust consumer
working-directory: test/consumers/rust
run: cargo run
- name: Test node.js consumer
working-directory: test/consumers/node
run: |
npm install
node index.js
- name: Test TypeScript consumer
working-directory: test/consumers/typescript
run: |
npm install
npx tsx app.ts
- name: Test python consumer
working-directory: test/consumers/python
run: |
pip install -r requirements.txt
python main.py
- name: Check python package
run: pip wheel .
- name: Check rust package
run: cargo check
- name: Install Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.6
actions-cache-folder: 'emsdk-cache'
- name: Generate parser WASM
run: npx tree-sitter build --wasm
- name: Package node tarball
run: npm pack
- name: Upload node tarball to workflow artifacts
uses: actions/upload-artifact@v4
with:
name: tlaplus-tree-sitter-tlaplus-${{matrix.os}}.tgz
path: '*.tgz'
if-no-files-found: error