Skip to content

Commit 437fd6d

Browse files
authored
Workflows
1 parent 770663e commit 437fd6d

File tree

4 files changed

+51
-30
lines changed

4 files changed

+51
-30
lines changed

.github/workflows/php-code-quality.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,23 @@ jobs:
8787
8888
- name: Run PHP Compatibility Check
8989
run: |
90-
# Install PHP compatibility standards if they're not already installed
90+
# Install PHP compatibility standards and required packages
9191
composer require --dev phpcompatibility/php-compatibility wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer --no-interaction || true
9292
93-
# Set up PHPCompatibility standard
94-
vendor/bin/phpcs --config-set installed_paths $(pwd)/vendor/phpcompatibility/php-compatibility || true
93+
# Set up PHPCompatibility standards - need to set correct paths
94+
INSTALLED_PATHS=$(composer config vendor-dir)/phpcompatibility/php-compatibility,$(composer config vendor-dir)/wp-coding-standards/wpcs
95+
vendor/bin/phpcs --config-set installed_paths $INSTALLED_PATHS || true
96+
97+
# Verify configured standards
98+
echo "Available coding standards:"
99+
vendor/bin/phpcs -i
95100
96101
# Try to auto-fix compatibility issues where possible
97-
vendor/bin/phpcbf --standard=PHPCompatibilityWP --extensions=php --ignore=vendor/,node_modules/ --runtime-set testVersion 7.4-8.4 . || true
102+
vendor/bin/phpcbf --standard=phpcs.xml --extensions=php --ignore=vendor/,node_modules/ . || true
98103
99104
# Run the actual compatibility check
100-
vendor/bin/phpcs --standard=PHPCompatibilityWP --extensions=php --ignore=vendor/,node_modules/ --runtime-set testVersion 7.4-8.4 .
105+
# Use project phpcs.xml which already includes PHPCompatibility with correct testVersion
106+
vendor/bin/phpcs --standard=phpcs.xml --extensions=php --ignore=vendor/,node_modules/ .
101107
102108
- name: Fix text argument escaping issues
103109
run: |

.github/workflows/wordpress-tests.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ jobs:
174174
# Make the install script executable
175175
chmod +x bin/install-wp-tests.sh
176176
177+
# Verify that the local db.php file exists
178+
if [ ! -f "bin/db.php" ]; then
179+
echo "::error::bin/db.php not found! This is required for the WordPress test environment setup."
180+
ls -la bin/ || echo "bin directory not found or empty"
181+
exit 1
182+
else
183+
echo "Local db.php file found - it will be used for the MySQL database driver"
184+
fi
185+
177186
# Create and fix permissions for /tmp directory
178187
sudo mkdir -p /tmp/wordpress-tests-lib
179188
sudo chmod 1777 /tmp
@@ -209,12 +218,22 @@ jobs:
209218
exit 1
210219
fi
211220
212-
# Check WordPress core installation
221+
# Check WordPress core installation and verify db.php was copied
213222
if [ ! -d "/tmp/wordpress" ]; then
214223
echo "::error::WordPress core directory not created."
215224
exit 1
216225
fi
217226
227+
# Verify db.php was copied successfully to WordPress content directory
228+
if [ ! -f "/tmp/wordpress/wp-content/db.php" ]; then
229+
echo "::error::db.php file not copied to WordPress content directory."
230+
echo "Copying the db.php file manually as a final fallback..."
231+
mkdir -p /tmp/wordpress/wp-content/
232+
cp bin/db.php /tmp/wordpress/wp-content/db.php || echo "Failed to copy db.php manually"
233+
else
234+
echo "db.php file successfully installed in WordPress content directory."
235+
fi
236+
218237
echo "WordPress test environment successfully set up:"
219238
ls -la /tmp/wordpress-tests-lib/
220239

bin/install-wp-tests.sh

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,27 @@ install_wp() {
170170
fi
171171
fi
172172

173-
echo "Downloading extra MySQL database driver..."
173+
echo "Setting up MySQL database driver..."
174174
# Create directory if it doesn't exist
175175
mkdir -p $WP_CORE_DIR/wp-content/
176176

177-
# Try to download the db.php file with verification
178-
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
179-
180-
# Check if download was successful and file is not empty
181-
if [ ! -s "$WP_CORE_DIR/wp-content/db.php" ]; then
182-
echo "Warning: Downloaded db.php file is empty or download failed."
177+
# Use local db.php file from the repository
178+
if [ -f "bin/db.php" ]; then
179+
echo "Using local db.php from bin/db.php"
180+
cp bin/db.php $WP_CORE_DIR/wp-content/db.php
181+
elif [ -f "${0%/*}/db.php" ]; then
182+
# Try to find db.php in the same directory as the script
183+
echo "Using local db.php from script directory"
184+
cp "${0%/*}/db.php" $WP_CORE_DIR/wp-content/db.php
185+
else
186+
echo "Error: Local db.php file not found in expected locations"
187+
echo "Expected locations checked:"
188+
echo " - bin/db.php"
189+
echo " - ${0%/*}/db.php"
183190

184-
# Check if we have a local copy in the repository
185-
if [ -f "bin/db.php" ]; then
186-
echo "Using local fallback copy of db.php from bin/db.php"
187-
cp bin/db.php $WP_CORE_DIR/wp-content/db.php
188-
elif [ -f "${0%/*}/db.php" ]; then
189-
# Try to find db.php in the same directory as the script
190-
echo "Using local fallback copy of db.php from script directory"
191-
cp "${0%/*}/db.php" $WP_CORE_DIR/wp-content/db.php
192-
else
193-
# Create a simple db.php file inline as last resort
194-
echo "Creating a minimal db.php file as fallback"
195-
cat > $WP_CORE_DIR/wp-content/db.php << 'EOL'
191+
# Create a simple db.php file inline as last resort
192+
echo "Creating a minimal db.php file as fallback"
193+
cat > $WP_CORE_DIR/wp-content/db.php << 'EOL'
196194
<?php
197195
/**
198196
* Fallback database driver to ensure tests can run
@@ -207,11 +205,8 @@ EOL
207205
if [ ! -s "$WP_CORE_DIR/wp-content/db.php" ]; then
208206
echo "Error: Failed to create a valid db.php file. Tests may not work correctly."
209207
else
210-
echo "Fallback db.php file created successfully."
208+
echo "db.php file created successfully."
211209
fi
212-
else
213-
echo "db.php downloaded successfully."
214-
fi
215210

216211
echo "WordPress core installation complete!"
217212
}

phpcs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<rule ref="WordPress.Security.ValidatedSanitizedInput" />
2424

2525
<!-- PHP compatibility checks -->
26-
<rule ref="PHPCompatibilityWP" />
26+
<rule ref="PHPCompatibility" />
27+
<config name="testVersion" value="7.4-8.4"/>
2728

2829
<!-- Files to check -->
2930
<arg name="extensions" value="php" />

0 commit comments

Comments
 (0)