-
Notifications
You must be signed in to change notification settings - Fork 11
131 lines (129 loc) · 4.23 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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