Skip to content
Draft
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
41 changes: 41 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
groups:
wordpress:
patterns:
- "@wordpress/*"
update-types:
- "minor"
- "patch"

# Enable version updates for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
groups:
phpstan:
patterns:
- "phpstan/*"
update-types:
- "minor"
- "patch"
phpunit:
patterns:
- "phpunit/*"
update-types:
- "minor"
- "patch"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
130 changes: 130 additions & 0 deletions .github/workflows/import-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Import Test

on:
pull_request:
push:
branches: [ master ]
workflow_dispatch:

jobs:
test-import:
runs-on: ubuntu-latest
timeout-minutes: 10

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: Debug plugin and command availability
run: |
echo "Checking plugin status..."
npm run wp-env run cli -- -- wp plugin list
echo "Checking available commands..."
npm run wp-env run cli -- -- wp help
echo "Checking if parser command exists..."
npm run wp-env run cli -- -- wp help parser || echo "Parser command not found"

- 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. Checking environment status..."
docker ps
45 changes: 26 additions & 19 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@ name: Unit Tests
on:
pull_request:
push:
branches: [ master ]
workflow_dispatch:

jobs:
test-php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '7.4'

env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}

steps:
test-php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'

env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}

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

- name: Install
run: npm install
- 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: Setup Environment
run: |
rm composer.lock
npm run setup
- name: Setup WordPress environment
run: npm run setup

- name: Test
- name: Run tests
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor
coverage
node_modules
.phpunit.result.cache
composer.lock
14 changes: 14 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use exact versions for reproducible builds
save-exact=true

# Automatically install peer dependencies
auto-install-peers=true

# Use npm audit signatures
audit-level=moderate

# Progress display for CI environments
progress=false

# Engine strict mode
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
12 changes: 8 additions & 4 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"phpVersion": "7.4",
"phpVersion": "8.2",
"plugins": [
".",
"https://downloads.wordpress.org/plugin/posts-to-posts.latest-stable.zip"
]
"https://downloads.wordpress.org/plugin/posts-to-posts.latest-stable.zip",
"."
],
"config": {
"WP_DEBUG": false,
"WP_DEBUG_DISPLAY": false
}
}
Loading
Loading