1111 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
1212
1313jobs :
14- # 1. First, we call the existing Archive workflow to get the built zip
14+ # ──────────────────────────────────────────────────────────────────────────
15+ # Job 0: Version consistency (fast, no server required, runs before matrix)
16+ # ──────────────────────────────────────────────────────────────────────────
17+ version-check :
18+ runs-on : ubuntu-24.04
19+ name : Version Consistency Check
20+ steps :
21+ - uses : actions/checkout@v4
22+
23+ - name : Check all version numbers are consistent
24+ run : |
25+ # Extract each version string from its canonical location
26+ V_HEADER=$(grep -oP "^\s*\*\s*Version:\s*\K[\d.]+" embedpress.php | head -1)
27+ V_CONST=$(grep -oP "define\('EMBEDPRESS_VERSION',\s*\"?\K[\d.]+" includes.php | head -1)
28+ V_PLG=$(grep -oP "define\('EMBEDPRESS_PLUGIN_VERSION',\s*'?\K[\d.]+" embedpress.php | head -1)
29+ V_README=$(grep -oP "Stable tag:\s*\K[\d.]+" readme.txt | head -1)
30+
31+ echo "Plugin header (Version:): $V_HEADER"
32+ echo "EMBEDPRESS_VERSION (includes): $V_CONST"
33+ echo "EMBEDPRESS_PLUGIN_VERSION (main): $V_PLG"
34+ echo "readme.txt Stable tag: $V_README"
35+
36+ MISMATCH=0
37+ [ "$V_HEADER" != "$V_CONST" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_VERSION ($V_CONST)" && MISMATCH=1
38+ [ "$V_HEADER" != "$V_PLG" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ EMBEDPRESS_PLUGIN_VERSION ($V_PLG)" && MISMATCH=1
39+ [ "$V_HEADER" != "$V_README" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ readme.txt Stable tag ($V_README)" && MISMATCH=1
40+ [ "$MISMATCH" -eq 1 ] && exit 1
41+
42+ echo "✅ All version numbers are consistent: $V_HEADER"
43+
44+ # ──────────────────────────────────────────────────────────────────────────
45+ # Job 1: PHP syntax lint (fast, no server, runs in parallel with version-check)
46+ # ──────────────────────────────────────────────────────────────────────────
47+ php-syntax-check :
48+ runs-on : ubuntu-24.04
49+ strategy :
50+ fail-fast : false
51+ matrix :
52+ php-version : ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]
53+ name : PHP Syntax (${{ matrix.php-version }})
54+ steps :
55+ - uses : actions/checkout@v4
56+
57+ - name : Setup PHP ${{ matrix.php-version }}
58+ uses : shivammathur/setup-php@v2
59+ with :
60+ php-version : ${{ matrix.php-version }}
61+
62+ - name : Lint all PHP files
63+ run : |
64+ # Find every .php file, excluding vendor (third-party) and node_modules
65+ FILES=$(find . -name "*.php" \
66+ -not -path "./vendor/*" \
67+ -not -path "./node_modules/*" \
68+ -not -path "./.git/*")
69+
70+ ERRORS=0
71+ while IFS= read -r file; do
72+ OUTPUT=$(php -l "$file" 2>&1)
73+ if [ $? -ne 0 ]; then
74+ echo "::error file=$file::$OUTPUT"
75+ ERRORS=$((ERRORS + 1))
76+ fi
77+ done <<< "$FILES"
78+
79+ TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')
80+ if [ "$ERRORS" -gt 0 ]; then
81+ echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP ${{ matrix.php-version }}"
82+ exit 1
83+ fi
84+ echo "✅ All $TOTAL PHP files passed syntax check on PHP ${{ matrix.php-version }}"
85+
86+ # ──────────────────────────────────────────────────────────────────────────
87+ # Job 2: Build the plugin zip
88+ # ──────────────────────────────────────────────────────────────────────────
1589 build :
1690 uses : ./.github/workflows/dist-archive.yml
1791
92+ # ──────────────────────────────────────────────────────────────────────────
93+ # Job 2: Matrix compatibility tests
94+ # ──────────────────────────────────────────────────────────────────────────
1895 compatibility-test :
19- needs : build
96+ needs : [version-check, php-syntax-check, build]
2097 runs-on : ubuntu-24.04
2198 strategy :
2299 fail-fast : false
@@ -40,15 +117,15 @@ jobs:
40117 name : WP ${{ matrix.wp-version }} / PHP ${{ matrix.php-version }}
41118
42119 steps :
43- # 2. Setup PHP environment
120+ # Setup PHP environment
44121 - name : Setup PHP Runtime
45122 uses : shivammathur/setup-php@v2
46123 with :
47124 php-version : ${{ matrix.php-version }}
48125 extensions : mysqli, mbstring, xml, gd
49126 tools : wp-cli
50127
51- # 3. Download the built artifact from the 'build' job
128+ # Download the built artifact from the 'build' job
52129 - name : Download Built EmbedPress
53130 uses : actions/download-artifact@v4
54131 with :
@@ -67,23 +144,17 @@ jobs:
67144 wp config create --dbname=wordpress_test --dbuser=root --dbpass=root --dbhost=127.0.0.1 --allow-root
68145 wp core install --url=http://localhost:8080 --title="EmbedPress Test" --admin_user=admin --admin_password=password --admin_email=hurayra@wpdeveloper.com --allow-root
69146
70- # 4. Move the built plugin to the WP folder
147+ # Move the built plugin to the WP folder and activate
71148 - name : Install and Activate EmbedPress
72149 run : |
73- # 1. Create the plugin directory
74150 mkdir -p ./test-site/wp-content/plugins/embedpress
75-
76- # 2. Move the contents from the nested folder.
77151 cp -r ./embedpress-dist/embedpress/. ./test-site/wp-content/plugins/embedpress/
78-
79- # 3. Debug: This should now show embedpress.php directly
80- echo "Checking plugin directory structure (Fixed):"
152+ echo "Checking plugin directory structure:"
81153 ls ./test-site/wp-content/plugins/embedpress | head -n 10
82-
83- # 4. Activate
84154 cd test-site
85155 wp plugin activate embedpress --allow-root
86156
157+ # ── Check 1: Basic WordPress + plugin integrity ──────────────────────
87158 - name : Run Integrity Check
88159 run : |
89160 cd test-site
@@ -94,40 +165,130 @@ jobs:
94165 fi
95166 echo "✅ EmbedPress is active and stable on WP ${{ matrix.wp-version }} / PHP ${{ matrix.php-version }}"
96167
97- # 5. Updated specific EmbedPress logic checks
98- # - name: Verify EmbedPress Constants & Options
99- # run: |
100- # cd test-site
101- # wp eval '
102- # // Check critical constants (Adjust these based on your actual plugin code)
103- # $constants = ["EMBEDPRESS_VERSION", "EMBEDPRESS_PATH", "EMBEDPRESS_URL"];
104- # foreach ($constants as $c) {
105- # if (!defined($c)) { echo "::error::Missing constant: $c\n"; exit(1); }
106- # }
107- # echo "✅ All EmbedPress constants defined\n";
108-
109- # // Check default options
110- # $val = get_option("embedpress_options", "__MISSING__");
111- # if ($val === "__MISSING__") { echo "::error::Missing option: embedpress_options\n"; exit(1); }
112- # echo "✅ Default options saved\n";
113- # ' --allow-root
168+ # ── Check 2: Critical constants and default DB option ────────────────
169+ - name : Verify EmbedPress Constants & Options
170+ run : |
171+ cd test-site
172+ wp eval '
173+ $constants = [
174+ "EMBEDPRESS_VERSION",
175+ "EMBEDPRESS_PLUGIN_VERSION",
176+ "EMBEDPRESS_PATH_CORE",
177+ "EMBEDPRESS_PLUGIN_DIR_PATH",
178+ "EMBEDPRESS_PLUGIN_DIR_URL",
179+ "EMBEDPRESS_SHORTCODE",
180+ "EMBEDPRESS_IS_LOADED",
181+ ];
182+ $failed = false;
183+ foreach ($constants as $c) {
184+ if (!defined($c)) {
185+ echo "::error::Missing constant: $c\n";
186+ $failed = true;
187+ }
188+ }
189+ if ($failed) exit(1);
190+ echo "✅ All EmbedPress constants defined\n";
114191
192+ // The activation hook saves default settings under the plugin slug
193+ $val = get_option("embedpress", "__MISSING__");
194+ if ($val === "__MISSING__") {
195+ echo "::error::Missing DB option: embedpress (activation hook may not have run)\n";
196+ exit(1);
197+ }
198+ echo "✅ Default plugin options found in DB\n";
199+ ' --allow-root
200+
201+ # ── Check 3: All shortcodes must be registered ───────────────────────
202+ - name : Verify EmbedPress Shortcodes Registered
203+ run : |
204+ cd test-site
205+ wp eval '
206+ $shortcodes = ["embed", "embedpress", "embedpress_pdf", "embedpress_doc", "embed_oembed_html"];
207+ $failed = false;
208+ foreach ($shortcodes as $sc) {
209+ if (!shortcode_exists($sc)) {
210+ echo "::error::Shortcode not registered: [$sc]\n";
211+ $failed = true;
212+ }
213+ }
214+ if ($failed) exit(1);
215+ echo "✅ All EmbedPress shortcodes registered\n";
216+ ' --allow-root
217+
218+ # ── Check 4: Custom REST routes must be registered ───────────────────
219+ - name : Verify EmbedPress REST API Routes Registered
220+ run : |
221+ cd test-site
222+ wp eval '
223+ $server = rest_get_server();
224+ $routes = $server->get_routes();
225+ // The oEmbed route is the backbone of the entire embed pipeline
226+ $expected = "/embedpress/v1/oembed/(?P<provider>[a-zA-Z0-9\-]+)";
227+ if (!isset($routes[$expected])) {
228+ echo "::error::EmbedPress REST route not registered: $expected\n";
229+ echo "Registered routes with embedpress namespace:\n";
230+ foreach (array_keys($routes) as $r) {
231+ if (strpos($r, "embedpress") !== false) echo " - $r\n";
232+ }
233+ exit(1);
234+ }
235+ echo "✅ EmbedPress oEmbed REST route is registered\n";
236+ ' --allow-root
237+
238+ # ── Check 5: Analytics DB tables must exist after activation ─────────
239+ - name : Verify EmbedPress Analytics DB Tables
240+ run : |
241+ cd test-site
242+ wp eval '
243+ global $wpdb;
244+ $tables = [
245+ $wpdb->prefix . "embedpress_analytics_content",
246+ $wpdb->prefix . "embedpress_analytics_views",
247+ $wpdb->prefix . "embedpress_analytics_browser_info",
248+ $wpdb->prefix . "embedpress_analytics_milestones",
249+ $wpdb->prefix . "embedpress_analytics_referrers",
250+ ];
251+ $failed = false;
252+ foreach ($tables as $table) {
253+ $exists = $wpdb->get_var("SHOW TABLES LIKE \"$table\"");
254+ if ($exists !== $table) {
255+ echo "::error::Missing analytics DB table: $table\n";
256+ $failed = true;
257+ }
258+ }
259+ if ($failed) exit(1);
260+ echo "✅ All EmbedPress analytics DB tables exist\n";
261+ ' --allow-root
262+
263+ # ── Check 6: PHP warnings & deprecations under WP_DEBUG ─────────────
115264 - name : Check for PHP Warnings & Deprecations
116265 run : |
117266 cd test-site
118267 wp config set WP_DEBUG true --raw --allow-root
119268 wp config set WP_DEBUG_LOG true --raw --allow-root
120- wp eval 'do_action("admin_init"); echo "Bootstrap OK\n";' --allow-root
269+ # Trigger both frontend and admin bootstrap paths
270+ wp eval 'do_action("init"); do_action("admin_init"); echo "Bootstrap OK\n";' --allow-root
121271
122272 if [ -f wp-content/debug.log ]; then
123273 FATALS=$(grep -c "PHP Fatal" wp-content/debug.log || true)
124- if [ "$FATALS" -gt 0 ]; then
274+ DEPRECATED=$(grep -c "PHP Deprecated" wp-content/debug.log || true)
275+
276+ if [ "$FATALS" -gt 0 ]; then
277+ echo "::error::PHP Fatal errors detected:"
125278 grep "PHP Fatal" wp-content/debug.log
126279 exit 1
127280 fi
281+
282+ # Surface deprecations as workflow warnings (not failures)
283+ # so they can be addressed before they become errors on the next PHP version
284+ if [ "$DEPRECATED" -gt 0 ]; then
285+ echo "::warning::PHP Deprecation notices found ($DEPRECATED total). Review before upgrading PHP."
286+ grep "PHP Deprecated" wp-content/debug.log | head -20
287+ fi
128288 fi
129289 echo "✅ No fatal PHP errors under WP_DEBUG"
130290
291+ # ── Check 7: REST API general health ────────────────────────────────
131292 - name : Verify REST API Health
132293 run : |
133294 cd test-site
0 commit comments