Skip to content

Commit 14bd133

Browse files
committed
fix: add PHP syntax checking before auto-fixing with Rector and ECS
1 parent c310ac9 commit 14bd133

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

booster/.github/actions/php-auto-fix/action.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,37 @@ runs:
109109
echo "files=$EXISTING_FILES" >> $GITHUB_OUTPUT
110110
echo "Changed files: $EXISTING_FILES"
111111
112+
- name: Check PHP syntax
113+
if: steps.get-files.outputs.files != ''
114+
shell: bash
115+
run: |
116+
CHANGED_FILES="${{ steps.get-files.outputs.files }}"
117+
if [ -n "$CHANGED_FILES" ]; then
118+
echo "🔍 Checking PHP syntax..."
119+
SYNTAX_ERRORS=0
120+
for file in $CHANGED_FILES; do
121+
if ! php -l "$file" > /dev/null 2>&1; then
122+
echo "❌ Syntax error in: $file"
123+
php -l "$file"
124+
SYNTAX_ERRORS=1
125+
fi
126+
done
127+
128+
if [ $SYNTAX_ERRORS -eq 1 ]; then
129+
echo "❌ Cannot auto-fix files with syntax errors. Please fix syntax errors first."
130+
exit 1
131+
fi
132+
echo "✅ All files have valid PHP syntax"
133+
fi
134+
112135
- name: Run Rector
113136
if: steps.get-files.outputs.files != '' && inputs.skip-rector != 'true'
114137
shell: bash
115138
run: |
116139
CHANGED_FILES="${{ steps.get-files.outputs.files }}"
117140
if [ -n "$CHANGED_FILES" ] && [ -f "vendor/bin/rector" ]; then
118141
echo "🔧 Running Rector on: $CHANGED_FILES"
119-
./vendor/bin/rector process $CHANGED_FILES --no-progress-bar --ansi || true
142+
./vendor/bin/rector process $CHANGED_FILES --no-progress-bar --ansi
120143
else
121144
echo "ℹ️ Rector not available or no files to process"
122145
fi
@@ -128,7 +151,7 @@ runs:
128151
CHANGED_FILES="${{ steps.get-files.outputs.files }}"
129152
if [ -n "$CHANGED_FILES" ] && [ -f "vendor/bin/ecs" ]; then
130153
echo "🔧 Running ECS on: $CHANGED_FILES"
131-
./vendor/bin/ecs check --fix $CHANGED_FILES --ansi || true
154+
./vendor/bin/ecs check --fix $CHANGED_FILES --ansi
132155
else
133156
echo "ℹ️ ECS not available or no files to process"
134157
fi

0 commit comments

Comments
 (0)