Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions .github/workflows/wordpress-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: WordPress smoke

on:
workflow_dispatch:
pull_request:
paths:
- 'credits_shortcode.php'
- 'css/**'
- 'js/**'
- 'block.json'
- '.cursor/**'
- 'scripts/**'
- '.github/workflows/wordpress-smoke.yml'
push:
branches:
- master
Expand All @@ -18,15 +27,45 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 25

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: credits_wp
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=5

env:
WP_DB_HOST: 127.0.0.1
WP_DB_NAME: credits_wp
WP_DB_USER: root
WP_DB_PASSWORD: root

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mysqli, mbstring, xml, curl, intl, zip
coverage: none

- name: Install MySQL client
run: sudo apt-get update -qq && sudo apt-get install -y -qq default-mysql-client

- name: Composer install
run: composer install --prefer-dist --no-interaction --no-progress

- name: WordPress install and smoke tests
run: |
chmod +x .cursor/cloud-agent-install.sh .cursor/cloud-agent-start.sh \
chmod +x scripts/ci-wordpress-smoke.sh \
.cursor/cloud-agent-verify.sh .cursor/cloud-agent-test-variations.sh
./.cursor/cloud-agent-install.sh
./.cursor/cloud-agent-start.sh
./.cursor/cloud-agent-verify.sh
./.cursor/cloud-agent-test-variations.sh
bash scripts/ci-wordpress-smoke.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The block E2E runner sets site default type to **Via** when `.wordpress/` exists

### Optional CI: WordPress smoke workflow

On GitHub, run **Actions → WordPress smoke → Run workflow** (`workflow_dispatch`) to install MariaDB, boot a fresh WordPress copy, and run verify + variation tests. Day-to-day PRs still use fast PHPUnit only.
On GitHub, run **Actions → WordPress smoke → Run workflow** (`workflow_dispatch`) or rely on pushes to `master` that touch plugin paths. The workflow uses a **MySQL 8 service** and `scripts/ci-wordpress-smoke.sh` (PHPUnit + WP shortcode smoke + 21 variation tests). Day-to-day PRs still use fast PHPUnit only.

### Translation template

Expand Down
78 changes: 78 additions & 0 deletions scripts/ci-wordpress-smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash
# Boot WordPress against a TCP MySQL instance (GitHub Actions service or local).
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WP_DIR="$ROOT/.wordpress"
PLUGIN_LINK="$WP_DIR/wp-content/plugins/credits-shortcode"

DB_HOST="${WP_DB_HOST:-127.0.0.1}"
DB_NAME="${WP_DB_NAME:-credits_wp}"
DB_USER="${WP_DB_USER:-root}"
DB_PASS="${WP_DB_PASSWORD:-root}"
WP_URL="${WP_URL:-http://127.0.0.1:8080}"

mkdir -p "$ROOT/.cursor/bin"
export PATH="$ROOT/.cursor/bin:${PATH}"

if ! command -v wp >/dev/null 2>&1; then
curl -fsSL -o "$ROOT/.cursor/bin/wp" https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x "$ROOT/.cursor/bin/wp"
fi

wait_for_mysql() {
local attempt
for attempt in $(seq 1 45); do
if mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" -e "SELECT 1" >/dev/null 2>&1; then
return 0
fi
sleep 2
done
echo "MySQL not reachable at ${DB_HOST} as ${DB_USER}" >&2
return 1
}

if [ -n "${GITHUB_ACTIONS:-}" ]; then
rm -rf "$WP_DIR"
fi

mkdir -p "$WP_DIR/wp-content/plugins"

if [ ! -f "$WP_DIR/wp-load.php" ]; then
wp core download --path="$WP_DIR" --version=6.7 --quiet
fi

wait_for_mysql

if [ ! -f "$WP_DIR/wp-config.php" ]; then
wp config create \
--path="$WP_DIR" \
--dbname="$DB_NAME" \
--dbuser="$DB_USER" \
--dbpass="$DB_PASS" \
--dbhost="$DB_HOST" \
--skip-check \
--quiet
fi

if ! wp core is-installed --path="$WP_DIR" 2>/dev/null; then
wp core install \
--path="$WP_DIR" \
--url="$WP_URL" \
--title="Credits Plugin CI" \
--admin_user="admin" \
--admin_password="admin" \
--admin_email="ci@example.test" \
--skip-email \
--quiet
fi

ln -sfn "$ROOT" "$PLUGIN_LINK"

if ! wp plugin is-active credits-shortcode --path="$WP_DIR" 2>/dev/null; then
wp plugin activate credits-shortcode --path="$WP_DIR" --quiet
fi

echo "WordPress smoke: core ready at ${WP_URL}"
bash "$ROOT/.cursor/cloud-agent-verify.sh"
bash "$ROOT/.cursor/cloud-agent-test-variations.sh"
Loading