@@ -20,38 +20,62 @@ jobs:
2020 path : redshift
2121
2222 steps :
23- - name : Checkout code
23+ - name : Checkout parser repository
2424 uses : actions/checkout@v4
25+ with :
26+ path : parser
27+
28+ - name : Checkout antlr-v4-linter repository
29+ uses : actions/checkout@v4
30+ with :
31+ repository : bytebase/antlr-v4-linter
32+ path : antlr-v4-linter
2533
2634 - name : Set up Python
2735 uses : actions/setup-python@v5
2836 with :
29- python-version : ' 3.x '
37+ python-version : ' 3.10 '
3038
3139 - name : Install antlr-v4-linter
3240 run : |
33- pip install antlr4-python3-runtime
34- pip install antlr-v4-linter
41+ cd antlr-v4-linter
42+ pip install -e .
43+ # Verify installation
44+ which antlr-lint
45+ antlr-lint --version || true
3546
3647 - name : Lint ${{ matrix.dialect }} grammar files
48+ working-directory : parser
3749 run : |
3850 echo "Linting ANTLR grammar files for ${{ matrix.dialect }}"
3951
52+ # Track if any errors occurred
53+ has_errors=false
54+
4055 # Find all .g4 files in the dialect directory
41- find ${{ matrix.path }} -name "*.g4" -type f | while read -r file ; do
56+ for file in $( find ${{ matrix.path }} -name "*.g4" -type f) ; do
4257 echo "Checking: $file"
43- antlr-v4-linter "$file" || exit_code=$?
4458
45- if [ "${exit_code:-0}" -ne 0 ]; then
59+ # Run antlr-lint on the grammar file
60+ if antlr-lint "$file"; then
61+ echo "✅ $file: Passed linting"
62+ else
63+ echo "❌ $file: Failed linting"
4664 echo "::error file=$file::ANTLR grammar linting failed"
47- exit 1
65+ has_errors=true
4866 fi
4967 done
5068
51- echo "✅ All grammar files for ${{ matrix.dialect }} passed linting"
69+ if [ "$has_errors" = true ]; then
70+ echo "❌ Grammar linting failed for ${{ matrix.dialect }}"
71+ exit 1
72+ else
73+ echo "✅ All grammar files for ${{ matrix.dialect }} passed linting"
74+ fi
5275
5376 - name : Summary
5477 if : always()
78+ working-directory : parser
5579 run : |
5680 echo "## ANTLR Grammar Lint Results" >> $GITHUB_STEP_SUMMARY
5781 echo "Dialect: **${{ matrix.dialect }}**" >> $GITHUB_STEP_SUMMARY
0 commit comments