-
Notifications
You must be signed in to change notification settings - Fork 10
96 lines (85 loc) · 3.5 KB
/
php-syntax-check.yml
File metadata and controls
96 lines (85 loc) · 3.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
89
90
91
92
93
94
95
96
# Reusable workflow: runs `php -l` on every PHP source file for all supported
# PHP versions in a single job (sequential). Catches parse errors before any
# runtime testing. No artifact needed — only requires a source checkout.
# Single job eliminates per-version runner startup overhead vs. a matrix.
name: QA - PHP Syntax Check
permissions: read-all
on:
workflow_dispatch:
workflow_call:
jobs:
php-syntax-check:
runs-on: ubuntu-24.04
name: PHP Syntax Check (7.4, 8.2, 8.5)
steps:
- uses: actions/checkout@v4
- name: Find PHP files
id: find
run: |
FILES=$(find . -name "*.php" \
-not -path "./vendor/*" \
-not -path "./node_modules/*" \
-not -path "./.git/*")
echo "TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')" >> "$GITHUB_ENV"
# Write file list to a temp file so all steps share it
echo "$FILES" > /tmp/php_files.txt
# ── PHP 7.4 ────────────────────────────────────────────────────────────
- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
- name: PHP Syntax Check (PHP 7.4)
run: |
ERRORS=0
while IFS= read -r file; do
OUTPUT=$(php -l "$file" 2>&1)
if [ $? -ne 0 ]; then
echo "::error file=$file::$OUTPUT"
ERRORS=$((ERRORS + 1))
fi
done < /tmp/php_files.txt
if [ "$ERRORS" -gt 0 ]; then
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 7.4"
exit 1
fi
echo "✅ All $TOTAL PHP files passed syntax check on PHP 7.4"
# ── PHP 8.2 ────────────────────────────────────────────────────────────
- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
- name: PHP Syntax Check (PHP 8.2)
run: |
ERRORS=0
while IFS= read -r file; do
OUTPUT=$(php -l "$file" 2>&1)
if [ $? -ne 0 ]; then
echo "::error file=$file::$OUTPUT"
ERRORS=$((ERRORS + 1))
fi
done < /tmp/php_files.txt
if [ "$ERRORS" -gt 0 ]; then
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.2"
exit 1
fi
echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.2"
# ── PHP 8.5 ────────────────────────────────────────────────────────────
- name: Setup PHP 8.5
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
- name: PHP Syntax Check (PHP 8.5)
run: |
ERRORS=0
while IFS= read -r file; do
OUTPUT=$(php -l "$file" 2>&1)
if [ $? -ne 0 ]; then
echo "::error file=$file::$OUTPUT"
ERRORS=$((ERRORS + 1))
fi
done < /tmp/php_files.txt
if [ "$ERRORS" -gt 0 ]; then
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.5"
exit 1
fi
echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.5"