-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (74 loc) · 2.5 KB
/
antlr-lint.yml
File metadata and controls
88 lines (74 loc) · 2.5 KB
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
name: ANTLR Grammar Lint
on:
push:
paths:
- '**/*.g4'
pull_request:
paths:
- '**/*.g4'
workflow_dispatch:
jobs:
lint-grammars:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- dialect: redshift
path: redshift
steps:
- name: Checkout parser repository
uses: actions/checkout@v4
with:
path: parser
- name: Checkout antlr-v4-linter repository
uses: actions/checkout@v4
with:
repository: bytebase/antlr-v4-linter
path: antlr-v4-linter
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install antlr-v4-linter
run: |
cd antlr-v4-linter
pip install -e .
# Verify installation
which antlr-lint
antlr-lint --version || true
- name: Lint ${{ matrix.dialect }} grammar files
working-directory: parser
run: |
echo "Linting ANTLR grammar files for ${{ matrix.dialect }}"
# Track if any errors occurred
has_errors=false
# Find all .g4 files in the dialect directory
for file in $(find ${{ matrix.path }} -name "*.g4" -type f); do
echo "Checking: $file"
# Run antlr-lint on the grammar file
if antlr-lint lint "$file"; then
echo "✅ $file: Passed linting"
else
echo "❌ $file: Failed linting"
echo "::error file=$file::ANTLR grammar linting failed"
has_errors=true
fi
done
if [ "$has_errors" = true ]; then
echo "❌ Grammar linting failed for ${{ matrix.dialect }}"
exit 1
else
echo "✅ All grammar files for ${{ matrix.dialect }} passed linting"
fi
- name: Summary
if: always()
working-directory: parser
run: |
echo "## ANTLR Grammar Lint Results" >> $GITHUB_STEP_SUMMARY
echo "Dialect: **${{ matrix.dialect }}**" >> $GITHUB_STEP_SUMMARY
echo "Path: \`${{ matrix.path }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Files checked:" >> $GITHUB_STEP_SUMMARY
find ${{ matrix.path }} -name "*.g4" -type f | while read -r file; do
echo "- \`$file\`" >> $GITHUB_STEP_SUMMARY
done