Skip to content

Commit fd97ffd

Browse files
authored
Merge pull request #266 from WPDevelopers/qa-hurayra
feat: Introduce GitHub Actions for EmbedPress compatibility testing and PCP plugin checks, and make the archive workflow reusable
2 parents e1be260 + a5a06b7 commit fd97ffd

3 files changed

Lines changed: 249 additions & 4 deletions

File tree

.github/workflows/dist-archive.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
name: Generate WordPress Archive
22
on:
3-
workflow_dispatch
3+
workflow_dispatch:
4+
workflow_call:
5+
# This allows other workflows to call this and get the zip
6+
outputs:
7+
artifact-name:
8+
description: 'The name of the uploaded artifact'
9+
value: ${{ github.event.repository.name }}
410

511
jobs:
612
generate-archive:
7-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-24.04
814
steps:
915
- name: Checkout repository
10-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4 # Updated to v4 for better performance
1117

1218
- name: Generating zip
13-
uses: rudlinkon/action-wordpress-build-zip@master
19+
uses: rudlinkon/action-wordpress-build-zip@master
20+
with:
21+
# npm-run-build: true
22+
install-composer: false
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: QA - EmbedPress Compatibility Testing
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
# pull_request:
6+
# branches: ["main", "dev"]
7+
# push:
8+
# branches: ["main"]
9+
10+
env:
11+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
12+
13+
jobs:
14+
# 1. First, we call the existing Archive workflow to get the built zip
15+
build:
16+
uses: ./.github/workflows/dist-archive.yml
17+
18+
compatibility-test:
19+
needs: build
20+
runs-on: ubuntu-24.04
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- wp-version: "6.9.4"
26+
php-version: "7.4"
27+
- wp-version: "6.9.4"
28+
php-version: "8.0"
29+
- wp-version: "6.9.4"
30+
php-version: "8.2"
31+
- wp-version: "6.9.4"
32+
php-version: "8.4"
33+
- wp-version: "6.9.4"
34+
php-version: "8.5"
35+
- wp-version: "6.5.5"
36+
php-version: "8.1"
37+
- wp-version: "6.0.9"
38+
php-version: "7.4"
39+
40+
name: WP ${{ matrix.wp-version }} / PHP ${{ matrix.php-version }}
41+
42+
steps:
43+
# 2. Setup PHP environment
44+
- name: Setup PHP Runtime
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php-version }}
48+
extensions: mysqli, mbstring, xml, gd
49+
tools: wp-cli
50+
51+
# 3. Download the built artifact from the 'build' job
52+
- name: Download Built EmbedPress
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: ${{ needs.build.outputs.artifact-name }}
56+
path: ./embedpress-dist
57+
58+
- name: Start Database
59+
run: |
60+
sudo systemctl start mysql
61+
mysql -u root -proot -e "CREATE DATABASE wordpress_test;"
62+
63+
- name: Install WordPress Core
64+
run: |
65+
wp core download --version=${{ matrix.wp-version }} --path=./test-site --allow-root
66+
cd test-site
67+
wp config create --dbname=wordpress_test --dbuser=root --dbpass=root --dbhost=127.0.0.1 --allow-root
68+
wp core install --url=http://localhost:8080 --title="EmbedPress Test" --admin_user=admin --admin_password=password --admin_email=hurayra@wpdeveloper.com --allow-root
69+
70+
# 4. Move the built plugin to the WP folder
71+
- name: Install and Activate EmbedPress
72+
run: |
73+
# 1. Create the plugin directory
74+
mkdir -p ./test-site/wp-content/plugins/embedpress
75+
76+
# 2. Move the contents from the nested folder.
77+
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):"
81+
ls ./test-site/wp-content/plugins/embedpress | head -n 10
82+
83+
# 4. Activate
84+
cd test-site
85+
wp plugin activate embedpress --allow-root
86+
87+
- name: Run Integrity Check
88+
run: |
89+
cd test-site
90+
WP_STATUS=$(wp eval 'echo "Ready";' --quiet --allow-root)
91+
if [[ "$WP_STATUS" != "Ready" ]]; then
92+
echo "::error::WordPress crashed after activating EmbedPress."
93+
exit 1
94+
fi
95+
echo "✅ EmbedPress is active and stable on WP ${{ matrix.wp-version }} / PHP ${{ matrix.php-version }}"
96+
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
114+
115+
- name: Check for PHP Warnings & Deprecations
116+
run: |
117+
cd test-site
118+
wp config set WP_DEBUG true --raw --allow-root
119+
wp config set WP_DEBUG_LOG true --raw --allow-root
120+
wp eval 'do_action("admin_init"); echo "Bootstrap OK\n";' --allow-root
121+
122+
if [ -f wp-content/debug.log ]; then
123+
FATALS=$(grep -c "PHP Fatal" wp-content/debug.log || true)
124+
if [ "$FATALS" -gt 0 ]; then
125+
grep "PHP Fatal" wp-content/debug.log
126+
exit 1
127+
fi
128+
fi
129+
echo "✅ No fatal PHP errors under WP_DEBUG"
130+
131+
- name: Verify REST API Health
132+
run: |
133+
cd test-site
134+
wp eval '
135+
$request = new WP_REST_Request("GET", "/wp/v2/posts");
136+
$response = rest_do_request($request);
137+
if ($response->is_error()) {
138+
echo "::error::REST API broken: " . $response->as_error()->get_error_message() . "\n";
139+
exit(1);
140+
}
141+
echo "✅ REST API responding normally\n";
142+
' --allow-root

.github/workflows/plugin-check.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: QA - Plugin Check (PCP)
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
# push:
6+
# branches: ["main"]
7+
8+
env:
9+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10+
11+
jobs:
12+
# 1. Build the plugin zip using the existing dist-archive workflow
13+
build:
14+
uses: ./.github/workflows/dist-archive.yml
15+
16+
plugin-check:
17+
needs: build
18+
runs-on: ubuntu-latest
19+
name: Plugin Check - WP Latest / PHP 8.4
20+
21+
steps:
22+
# 2. Setup PHP 8.4 + WP-CLI
23+
- name: Setup PHP Runtime
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: "8.4"
27+
extensions: mysqli, mbstring, xml, gd
28+
tools: wp-cli
29+
30+
# 3. Download the built EmbedPress zip artifact
31+
- name: Download Built EmbedPress
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: ${{ needs.build.outputs.artifact-name }}
35+
path: ./embedpress-dist
36+
37+
# 4. Start MySQL and create the database
38+
- name: Start Database
39+
run: |
40+
sudo systemctl start mysql
41+
mysql -u root -proot -e "CREATE DATABASE wordpress_test;"
42+
43+
# 5. Download and configure WordPress (latest)
44+
- name: Install WordPress Core
45+
run: |
46+
wp core download --path=./test-site --allow-root
47+
cd test-site
48+
wp config create --dbname=wordpress_test --dbuser=root --dbpass=root --dbhost=127.0.0.1 --allow-root
49+
wp core install \
50+
--url=http://localhost:8080 \
51+
--title="EmbedPress Plugin Check" \
52+
--admin_user=admin \
53+
--admin_password=password \
54+
--admin_email=test@example.com \
55+
--allow-root
56+
57+
# 6. Install and activate EmbedPress from the built dist zip
58+
- name: Install and Activate EmbedPress
59+
run: |
60+
mkdir -p ./test-site/wp-content/plugins/embedpress
61+
cp -r ./embedpress-dist/embedpress/. ./test-site/wp-content/plugins/embedpress/
62+
63+
echo "Plugin directory contents:"
64+
ls ./test-site/wp-content/plugins/embedpress | head -n 15
65+
66+
cd test-site
67+
wp plugin activate embedpress --allow-root
68+
69+
# 7. Install and activate the Plugin Check plugin from WordPress.org
70+
- name: Install Plugin Check Plugin
71+
run: |
72+
cd test-site
73+
wp plugin install plugin-check --activate --allow-root
74+
75+
# 8. Run Plugin Check against EmbedPress
76+
# NOTE: We are only checking errors for now.
77+
# We will also address warnings once all errors are resolved.
78+
- name: Run Plugin Check
79+
run: |
80+
cd test-site
81+
82+
# Redirect full output to a file — errors can be large (thousands of lines)
83+
wp plugin check embedpress --ignore-warnings --allow-root 2>&1 | tee /tmp/pcp-output.txt || true
84+
85+
# Pass only if the output contains the exact success message
86+
if grep -qF "Success: Checks complete. No errors found." /tmp/pcp-output.txt; then
87+
echo "✅ Plugin Check passed — no errors found."
88+
else
89+
echo "❌ Plugin Check found errors:"
90+
echo "------------------------------------------------------------"
91+
cat /tmp/pcp-output.txt
92+
echo "------------------------------------------------------------"
93+
exit 1
94+
fi

0 commit comments

Comments
 (0)