Skip to content
Merged
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
1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
.git
.gitignore
.gitattributes
.travis.yml
.DS_Store
.wordpress-org
.github
Expand Down
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
composer.json export-ignore
deploy.sh export-ignore
phpcs.xml.dist export-ignore
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/phpunit-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: PHPUnit Tests

on:
push:
branches:
- master
- release/*
pull_request:

jobs:
test:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wp }}
runs-on: ubuntu-latest

permissions:
contents: read

strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
wp: ['latest']
experimental: [false]
include:
# Test with older WordPress version
- php: '7.4'
wp: '4.9'
experimental: false
- php: '8.0'
wp: '4.9'
experimental: false
# Test with WordPress trunk/master (allow failures)
- php: '8.2'
wp: 'trunk'
experimental: true

continue-on-error: ${{ matrix.experimental }}

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: wordpress_tests
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mysqli
coverage: none
tools: composer

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: PHP Lint
run: find -L . -path ./vendor -prune -o -name '*.php' -not -name 'class-wp-ms-network-command.php' -print0 | xargs -0 -n 1 -P 4 php -l

- name: Setup WordPress test environment
env:
WP_VERSION: ${{ matrix.wp }}
run: |
if [[ "$WP_VERSION" == "latest" ]]; then
WP_VERSION=$(curl -s http://api.wordpress.org/core/version-check/1.7/ | grep -o '"version":"[^"]*' | sed 's/"version":"//' | head -1)
fi
if [[ "$WP_VERSION" == "trunk" ]]; then
WP_VERSION="master"
fi

# Get plugin slug from repository name
PLUGIN_SLUG=$(basename "$GITHUB_WORKSPACE")

# Clone WordPress
git clone --depth=1 --branch="$WP_VERSION" https://github.com/WordPress/wordpress-develop.git /tmp/wordpress

# Setup plugin directory
mkdir -p /tmp/wordpress/src/wp-content/mu-plugins
cp -r "$GITHUB_WORKSPACE" "/tmp/wordpress/src/wp-content/mu-plugins/$PLUGIN_SLUG"

# Configure tests
cd /tmp/wordpress
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
sed -i "s/yourusernamehere/root/" wp-tests-config.php
sed -i "s/yourpasswordhere//" wp-tests-config.php
sed -i "s/localhost/127.0.0.1/" wp-tests-config.php

- name: Run PHPUnit tests
run: |
PLUGIN_SLUG=$(basename "$GITHUB_WORKSPACE")
cd "/tmp/wordpress/src/wp-content/mu-plugins/$PLUGIN_SLUG"
vendor/bin/phpunit -c phpunit.xml.dist
95 changes: 0 additions & 95 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ This project provides workflows for:

* running integration tests (using PHPUnit)
* checking coding and documentation standards (using PHPCodeSniffer).
* static analysis (using PHPStan).

It is also integrated with Travis-CI to ensure those always pass.
It is also integrated with GitHub Actions to ensure those always pass.

### PHPUnit and PHPCS Workflows

Expand Down
1 change: 0 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ svn propset --quiet svn:ignore ".editorconfig
.git
.gitattributes
.gitignore
.travis.yml
composer.json
composer.lock
deploy.sh
Expand Down
Loading