Skip to content

Commit

Permalink
Refactor PHPUnit GitHub workflow for simplicity
Browse files Browse the repository at this point in the history
The PHPUnit GitHub workflow was significantly simplified by reducing the amount of work done in the YAML file. The previous workflow was manually setting up the test environment (downloading WordPress, setting up MySQL, etc.) within this file.

The updated workflow uses a custom GitHub action that handles these setup steps, resulting in a cleaner and easier to read workflow file.

Moreover, the PHP versions and WordPress version for testing have been updated to reflect more current versions.
  • Loading branch information
attackant committed Oct 30, 2023
1 parent a988b0b commit 8b86909
Showing 1 changed file with 11 additions and 46 deletions.
57 changes: 11 additions & 46 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
name: Unit Tests
name: Testing Suite

on:
pull_request:
workflow_dispatch:

jobs:
tests:
name: "PHP: ${{ matrix.php }} (MU: ${{ matrix.multisite }})"
runs-on: ubuntu-latest
php-tests:
strategy:
fail-fast: true
matrix:
multisite: [0, 1]
php: ['8.0', '7.4', '7.3', '7.2', '7.1']
env:
WP_CORE_DIR: /tmp/wordpress/
WP_MULTISITE: ${{ matrix.multisite }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
all_but_latest: true
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
coverage: none
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Set up WordPress
run: |
bash <(curl -s "https://raw.githubusercontent.com/wp-cli/sample-plugin/master/bin/install-wp-tests.sh") wordpress_unit_tests root '' 127.0.0.1
rm -rf "${WP_CORE_DIR}wp-content/plugins"
mkdir -p "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news"
rsync -a --exclude=.git . "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news"
cd ${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news && composer install
- name: Run tests
shell: bash
run: |
cd ${WP_CORE_DIR}/wp-content/plugins/publish-to-apple-news
composer run phpunit
php: ['8.2', '8.1', '8.0', '7.4']
wordpress: ["latest"]
uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main
with:
command: "test"
php: ${{ matrix.php }}
wordpress: ${{ matrix.wordpress }}

0 comments on commit 8b86909

Please sign in to comment.