Update import test workflow syntax for wp-env #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Import Test | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ main, master, modernize-parser-php8 ] | |
| workflow_dispatch: | |
| jobs: | |
| test-import: | |
| runs-on: ubuntu-latest | |
| env: | |
| WP_ENV_PHP_VERSION: '8.2' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install Node.js dependencies | |
| run: npm ci | |
| - name: Start WordPress environment | |
| run: | | |
| npm run wp-env start | |
| sleep 10 | |
| - name: Wait for WordPress to be ready | |
| run: | | |
| timeout 60 bash -c 'until curl -s http://localhost:8888 > /dev/null; do sleep 2; done' | |
| - name: Activate plugins | |
| run: | | |
| npm run wp-env run cli -- -- wp plugin activate phpdoc-parser posts-to-posts | |
| - name: Run sample import (subset of files) | |
| run: | | |
| # Import a small subset of WordPress core files for testing | |
| npm run wp-env run cli -- -- wp parser create /var/www/html/wp-includes/functions.php --user=admin --quick | |
| - name: Verify import worked | |
| run: | | |
| # Check that functions were imported | |
| FUNCTION_COUNT=$(npm run wp-env run cli -- -- wp post list --post_type=wp-parser-function --format=count | tail -1) | |
| echo "Functions imported: $FUNCTION_COUNT" | |
| if [ "$FUNCTION_COUNT" -lt 50 ]; then | |
| echo "ERROR: Expected at least 50 functions, got $FUNCTION_COUNT" | |
| exit 1 | |
| fi | |
| # Check that classes were imported | |
| CLASS_COUNT=$(npm run wp-env run cli -- -- wp post list --post_type=wp-parser-class --format=count | tail -1) | |
| echo "Classes imported: $CLASS_COUNT" | |
| # Check that hooks were imported | |
| HOOK_COUNT=$(npm run wp-env run cli -- -- wp post list --post_type=wp-parser-hook --format=count | tail -1) | |
| echo "Hooks imported: $HOOK_COUNT" | |
| # Check that methods were imported | |
| METHOD_COUNT=$(npm run wp-env run cli -- -- wp post list --post_type=wp-parser-method --format=count | tail -1) | |
| echo "Methods imported: $METHOD_COUNT" | |
| - name: Test parser command with error detection | |
| run: | | |
| # Run parser and capture both stdout and stderr | |
| if ! npm run wp-env run cli -- -- wp parser create /var/www/html/wp-includes/class-wp.php --user=admin 2>&1 | tee import_output.log; then | |
| echo "ERROR: Parser command failed" | |
| exit 1 | |
| fi | |
| # Check for PHP warnings or errors in output | |
| if grep -i "warning\|error\|fatal" import_output.log | grep -v "WP_CLI"; then | |
| echo "ERROR: PHP warnings or errors detected in parser output" | |
| cat import_output.log | |
| exit 1 | |
| fi | |
| echo "✓ Parser completed without PHP warnings or errors" | |
| - name: Verify specific function exists | |
| run: | | |
| # Test that a well-known WordPress function was parsed correctly from functions.php | |
| FUNCTION_EXISTS=$(npm run wp-env run cli -- -- wp post list --post_type=wp-parser-function --s=wp_date --format=count | tail -1) | |
| if [ "$FUNCTION_EXISTS" -eq 0 ]; then | |
| echo "ERROR: wp_date function not found in parsed data" | |
| exit 1 | |
| fi | |
| echo "✓ wp_date function successfully parsed" | |
| - name: Test database integrity | |
| run: | | |
| # Check that taxonomies are properly assigned | |
| FILE_TERMS=$(npm run wp-env run cli -- -- wp term list wp-parser-source-file --format=count | tail -1) | |
| echo "File taxonomy terms: $FILE_TERMS" | |
| if [ "$FILE_TERMS" -eq 0 ]; then | |
| echo "ERROR: No file taxonomy terms found" | |
| exit 1 | |
| fi | |
| echo "✓ Database integrity checks passed" | |
| - name: Test WP-CLI functionality | |
| run: | | |
| # Test that WP-CLI is working with the parser | |
| npm run wp-env run cli -- -- wp parser --help | grep -q "create" | |
| echo "✓ WP-CLI parser command available" | |
| - name: Cleanup on failure | |
| if: failure() | |
| run: | | |
| echo "Import test failed. Dumping logs..." | |
| npm run wp-env logs |