Skip to content

Commit a0531b6

Browse files
committed
fix: prevent PHP syntax check from failing on success
The grep command was returning exit code 1 when no syntax errors were found, causing the workflow to fail. Fixed by: - Capturing output in a variable with '|| true' to handle grep exit codes - Checking if errors exist before failing - Providing clear success/failure messages
1 parent edb11d5 commit a0531b6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ jobs:
6464
# Check PHP syntax
6565
if command -v php &> /dev/null; then
6666
echo "Checking PHP syntax..."
67-
find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; | grep -v "No syntax errors"
67+
ERRORS=$(find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; 2>&1 | grep -v "No syntax errors" || true)
68+
if [ -n "$ERRORS" ]; then
69+
echo "PHP syntax errors found:"
70+
echo "$ERRORS"
71+
exit 1
72+
else
73+
echo "✅ All PHP files have valid syntax"
74+
fi
6875
else
6976
echo "PHP not installed, skipping syntax check"
7077
fi

0 commit comments

Comments
 (0)