Skip to content

Update PHP and Node.js setup in GitHub Actions workflow and enhance P… #2

Update PHP and Node.js setup in GitHub Actions workflow and enhance P…

Update PHP and Node.js setup in GitHub Actions workflow and enhance P… #2

Workflow file for this run

name: PHP Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
# dorny/test-reporter needs these to post check runs and PR annotations.
permissions:
checks: write
pull-requests: write
jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none
- name: Install npm dependencies
run: npm ci
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Start WordPress environment
run: npm run env:start
- name: Wait for WordPress to be ready
run: |
echo "Waiting for WordPress test environment to be ready..."
timeout 120 bash -c 'until curl -s http://localhost:3333 > /dev/null; do sleep 2; done'
echo "WordPress is ready!"
- name: Run PHPUnit
run: npm run test:php
- name: Publish test results
uses: dorny/test-reporter@v1
if: always()
with:
name: PHPUnit Results
path: phpunit-results.xml
reporter: java-junit
fail-on-error: true