Skip to content

Add ?format=markdown query parameter support (#2) #2

Add ?format=markdown query parameter support (#2)

Add ?format=markdown query parameter support (#2) #2

Workflow file for this run

name: Test Plugin
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup PHP (for composer build)
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
- name: Install composer dependencies
run: composer install --optimize-autoloader
- name: Build prefixed vendor
run: composer run build
- name: Install wp-playground CLI
run: npm install -g @wp-playground/cli
- name: Start wp-playground with blueprint
run: |
echo "Starting wp-playground server in background..."
PLUGIN_PATH=$(realpath .)
echo "Plugin path: $PLUGIN_PATH"
npx @wp-playground/cli server --mount="$PLUGIN_PATH:/wordpress/wp-content/plugins/post-content-to-markdown" --blueprint=blueprint.json &
WP_PID=$!
echo $WP_PID > wp-playground.pid
echo "Started with PID: $WP_PID"
# Wait for wp-playground to be ready
echo "Waiting for wp-playground to start..."
for i in {1..30}; do
if curl -s http://localhost:9400 > /dev/null; then
echo "wp-playground is ready!"
break
fi
echo "Waiting... ($i/30)"
sleep 2
done
- name: Wait for WordPress
run: |
# Wait for WordPress to be ready
sleep 10
- name: Test single post markdown output
run: |
echo "Testing single post with ?format=markdown"
# Check if server is responding
echo "Checking server status..."
curl -v "http://localhost:9400/" || echo "Server not responding"
echo "Testing markdown endpoint..."
response=$(curl -s "http://localhost:9400/hello-world/?format=markdown")
echo "Response received: $response"
if [[ "$response" == *"# Hello world"* ]] && [[ "$response" == *"WordPress"* ]]; then
echo "✅ Single post markdown query parameter test passed"
else
echo "❌ Single post markdown query parameter test failed"
exit 1
fi
- name: Test single post with Accept header
run: |
echo "Testing single post with Accept: text/markdown header"
response=$(curl -s -H "Accept: text/markdown" "http://localhost:9400/hello-world/")
if [[ "$response" == *"# Hello world"* ]] && [[ "$response" == *"WordPress"* ]]; then
echo "✅ Single post Accept header test passed"
else
echo "❌ Single post Accept header test failed"
exit 1
fi
- name: Test main feed markdown
run: |
echo "Testing main feed with ?format=markdown"
response=$(curl -s "http://localhost:9400/feed/?format=markdown")
if [[ "$response" == *"Markdown Feed"* ]] && [[ "$response" == *"Hello world"* ]]; then
echo "✅ Main feed markdown test passed"
else
echo "❌ Main feed markdown test failed"
exit 1
fi
- name: Test dedicated markdown feed
run: |
echo "Testing dedicated /feed/markdown/ endpoint"
response=$(curl -s "http://localhost:9400/feed/markdown/")
if [[ "$response" == *"Markdown Feed"* ]] && [[ "$response" == *"Hello world"* ]]; then
echo "✅ Dedicated markdown feed test passed"
else
echo "❌ Dedicated markdown feed test failed"
exit 1
fi
- name: Test content type headers
run: |
echo "Testing Content-Type headers"
content_type=$(curl -s -I "http://localhost:9400/hello-world/?format=markdown" | grep -i "content-type")
if [[ "$content_type" == *"text/markdown"* ]]; then
echo "✅ Content-Type header test passed"
else
echo "❌ Content-Type header test failed"
exit 1
fi
- name: Cleanup
if: always()
run: |
if [ -f wp-playground.pid ]; then
kill $(cat wp-playground.pid) || true
fi