Skip to content

Commit d661064

Browse files
committed
fix: replace broken install-wp-tests.sh with direct WP test suite download
The wp-cli/scaffold-command install-wp-tests.sh script silently fails on current GitHub Actions runners, producing no test library files. Replace with curl-based downloads from wordpress.org and GitHub archives.
1 parent 8285517 commit d661064

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,50 @@ jobs:
5555
- name: Install Composer dependencies
5656
run: composer install --no-progress --prefer-dist
5757

58-
- name: Install system dependencies
59-
run: |
60-
sudo apt-get update
61-
sudo apt-get install -y subversion
62-
6358
- name: Install WordPress test suite
6459
run: |
65-
bash <(curl -s https://raw.githubusercontent.com/wp-cli/scaffold-command/main/templates/install-wp-tests.sh) wordpress_test root root 127.0.0.1 latest true
60+
WP_TESTS_DIR=/tmp/wordpress-tests-lib
61+
WP_CORE_DIR=/tmp/wordpress
62+
63+
# Download WordPress
64+
mkdir -p "$WP_CORE_DIR"
65+
curl -sL https://wordpress.org/latest.tar.gz | tar xz --strip-components=1 -C "$WP_CORE_DIR"
66+
67+
# Download WordPress test suite
68+
mkdir -p "$WP_TESTS_DIR"
69+
WP_VERSION=$(php -r "require '$WP_CORE_DIR/wp-includes/version.php'; echo \$wp_version;")
70+
WP_BRANCH="${WP_VERSION%.*}"
71+
curl -sL "https://github.com/WordPress/wordpress-develop/archive/refs/heads/${WP_BRANCH}.tar.gz" | tar xz --strip-components=1 -C "$WP_TESTS_DIR" "wordpress-develop-${WP_BRANCH}/tests/phpunit/includes" "wordpress-develop-${WP_BRANCH}/tests/phpunit/data"
72+
# Move extracted contents to expected layout
73+
mv "$WP_TESTS_DIR/tests/phpunit/includes" "$WP_TESTS_DIR/includes"
74+
mv "$WP_TESTS_DIR/tests/phpunit/data" "$WP_TESTS_DIR/data"
75+
rm -rf "$WP_TESTS_DIR/tests"
76+
77+
# Create wp-tests-config.php
78+
cat > "$WP_TESTS_DIR/wp-tests-config.php" <<'WPCONFIG'
79+
<?php
80+
define( 'ABSPATH', '/tmp/wordpress/' );
81+
define( 'DB_NAME', 'wordpress_test' );
82+
define( 'DB_USER', 'root' );
83+
define( 'DB_PASSWORD', 'root' );
84+
define( 'DB_HOST', '127.0.0.1' );
85+
define( 'DB_CHARSET', 'utf8' );
86+
define( 'DB_COLLATE', '' );
87+
$table_prefix = 'wptests_';
88+
define( 'WP_TESTS_DOMAIN', 'example.org' );
89+
define( 'WP_TESTS_EMAIL', 'admin@example.org' );
90+
define( 'WP_TESTS_TITLE', 'Test Blog' );
91+
define( 'WP_PHP_BINARY', 'php' );
92+
define( 'WPLANG', '' );
93+
WPCONFIG
94+
95+
# Verify installation
96+
if [ ! -f "$WP_TESTS_DIR/includes/functions.php" ]; then
97+
echo "ERROR: WordPress test suite installation failed"
98+
ls -la "$WP_TESTS_DIR/" || true
99+
exit 1
100+
fi
101+
echo "WordPress test suite installed successfully"
66102
67103
- name: Run PHPUnit
68104
run: vendor/bin/phpunit

0 commit comments

Comments
 (0)