Skip to content

Commit 0b96c0b

Browse files
committed
feat: make readme.txt version verification conditional and update version constant descriptions in the plugin version verification workflow.
1 parent 0340df9 commit 0b96c0b

2 files changed

Lines changed: 82 additions & 28 deletions

File tree

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Reusable workflow: runs `php -l` on every PHP source file across a matrix
2-
# of all supported PHP versions. Catches parse errors before any runtime
3-
# testing. No artifact needed — only requires a source checkout. Runs in
4-
# parallel with the build job in qa.yml.
1+
# Reusable workflow: runs `php -l` on every PHP source file for all supported
2+
# PHP versions in a single job (sequential). Catches parse errors before any
3+
# runtime testing. No artifact needed — only requires a source checkout.
4+
# Single job eliminates per-version runner startup overhead vs. a matrix.
55

66
name: QA - PHP Syntax Check
77

@@ -14,38 +14,83 @@ on:
1414
jobs:
1515
php-syntax-check:
1616
runs-on: ubuntu-24.04
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
php-version: ["7.4", "8.2", "8.5"]
21-
name: PHP ${{ matrix.php-version }} Syntax Check
17+
name: PHP Syntax Check (7.4, 8.2, 8.5)
2218
steps:
2319
- uses: actions/checkout@v4
2420

25-
- name: Setup PHP ${{ matrix.php-version }}
26-
uses: shivammathur/setup-php@v2
27-
with:
28-
php-version: ${{ matrix.php-version }}
29-
30-
- name: PHP Syntax Check (PHP ${{ matrix.php-version }})
21+
- name: Find PHP files
22+
id: find
3123
run: |
3224
FILES=$(find . -name "*.php" \
3325
-not -path "./vendor/*" \
3426
-not -path "./node_modules/*" \
3527
-not -path "./.git/*")
28+
echo "TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')" >> "$GITHUB_ENV"
29+
# Write file list to a temp file so all steps share it
30+
echo "$FILES" > /tmp/php_files.txt
31+
32+
# ── PHP 7.4 ────────────────────────────────────────────────────────────
33+
- name: Setup PHP 7.4
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: "7.4"
37+
38+
- name: PHP Syntax Check (PHP 7.4)
39+
run: |
40+
ERRORS=0
41+
while IFS= read -r file; do
42+
OUTPUT=$(php -l "$file" 2>&1)
43+
if [ $? -ne 0 ]; then
44+
echo "::error file=$file::$OUTPUT"
45+
ERRORS=$((ERRORS + 1))
46+
fi
47+
done < /tmp/php_files.txt
48+
if [ "$ERRORS" -gt 0 ]; then
49+
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 7.4"
50+
exit 1
51+
fi
52+
echo "✅ All $TOTAL PHP files passed syntax check on PHP 7.4"
3653
54+
# ── PHP 8.2 ────────────────────────────────────────────────────────────
55+
- name: Setup PHP 8.2
56+
uses: shivammathur/setup-php@v2
57+
with:
58+
php-version: "8.2"
59+
60+
- name: PHP Syntax Check (PHP 8.2)
61+
run: |
3762
ERRORS=0
3863
while IFS= read -r file; do
3964
OUTPUT=$(php -l "$file" 2>&1)
4065
if [ $? -ne 0 ]; then
4166
echo "::error file=$file::$OUTPUT"
4267
ERRORS=$((ERRORS + 1))
4368
fi
44-
done <<< "$FILES"
69+
done < /tmp/php_files.txt
70+
if [ "$ERRORS" -gt 0 ]; then
71+
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.2"
72+
exit 1
73+
fi
74+
echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.2"
75+
76+
# ── PHP 8.5 ────────────────────────────────────────────────────────────
77+
- name: Setup PHP 8.5
78+
uses: shivammathur/setup-php@v2
79+
with:
80+
php-version: "8.5"
4581

46-
TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')
82+
- name: PHP Syntax Check (PHP 8.5)
83+
run: |
84+
ERRORS=0
85+
while IFS= read -r file; do
86+
OUTPUT=$(php -l "$file" 2>&1)
87+
if [ $? -ne 0 ]; then
88+
echo "::error file=$file::$OUTPUT"
89+
ERRORS=$((ERRORS + 1))
90+
fi
91+
done < /tmp/php_files.txt
4792
if [ "$ERRORS" -gt 0 ]; then
48-
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP ${{ matrix.php-version }}"
93+
echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.5"
4994
exit 1
5095
fi
51-
echo "✅ All $TOTAL PHP files passed syntax check on PHP ${{ matrix.php-version }}"
96+
echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.5"

.github/workflows/plugin-version-verification.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Reusable workflow: verifies that the version string is identical across
2-
# embedpress.php (plugin header), includes/Plugin.php ($version property),
3-
# and readme.txt (Stable tag, if the file exists). Fast, no server required
2+
# embedpress.php (plugin header), includes.php (EMBEDPRESS_VERSION constant),
3+
# embedpress.php (EMBEDPRESS_PLUGIN_VERSION constant), and readme.txt
4+
# (Stable tag, checked only if the file exists). Fast, no server required
45
# — runs in parallel with the build job in qa.yml.
56

67
name: QA - Plugin Version Verification
@@ -23,18 +24,26 @@ jobs:
2324
# Extract each version string from its canonical location
2425
V_HEADER=$(grep -oP "^\s*\*\s*Version:\s*\K[\d.]+" embedpress.php | head -1)
2526
V_CONST=$(grep -oP "define\('EMBEDPRESS_VERSION',\s*\"?\K[\d.]+" includes.php | head -1)
26-
V_PLG=$(grep -oP "define\('EMBEDPRESS_PLUGIN_VERSION',\s*'?\K[\d.]+" embedpress.php | head -1)
27-
V_README=$(grep -oP "Stable tag:\s*\K[\d.]+" readme.txt | head -1)
27+
# Anchor to the quoted production string to avoid matching the time() dev-mode line
28+
V_PLG=$(grep -oP "define\('EMBEDPRESS_PLUGIN_VERSION',\s*'\K[\d.]+" embedpress.php | head -1)
29+
# V_PKG=$(grep -oP '"version":\s*"\K[\d.]+' package.json | head -1)
2830
2931
echo "Plugin header (Version:): $V_HEADER"
3032
echo "EMBEDPRESS_VERSION (includes): $V_CONST"
3133
echo "EMBEDPRESS_PLUGIN_VERSION (main): $V_PLG"
32-
echo "readme.txt Stable tag: $V_README"
3334
3435
MISMATCH=0
35-
[ "$V_HEADER" != "$V_CONST" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_VERSION ($V_CONST)" && MISMATCH=1
36-
[ "$V_HEADER" != "$V_PLG" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_PLUGIN_VERSION ($V_PLG)" && MISMATCH=1
37-
[ "$V_HEADER" != "$V_README" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ readme.txt Stable tag ($V_README)" && MISMATCH=1
36+
[ "$V_HEADER" != "$V_CONST" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_VERSION ($V_CONST)" && MISMATCH=1
37+
[ "$V_HEADER" != "$V_PLG" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_PLUGIN_VERSION ($V_PLG)" && MISMATCH=1
38+
# [ "$V_HEADER" != "$V_PKG" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ package.json version ($V_PKG)" && MISMATCH=1
39+
40+
# readme.txt is optional — only check if present
41+
if [ -f readme.txt ]; then
42+
V_README=$(grep -oP "Stable tag:\s*\K[\d.]+" readme.txt | head -1)
43+
echo "readme.txt Stable tag: $V_README"
44+
[ "$V_HEADER" != "$V_README" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ readme.txt Stable tag ($V_README)" && MISMATCH=1
45+
fi
46+
3847
[ "$MISMATCH" -eq 1 ] && exit 1
3948
40-
echo "✅ All version numbers are consistent: $V_HEADER"
49+
echo "✅ All version numbers are consistent: $V_HEADER"

0 commit comments

Comments
 (0)