Skip to content

Unit Tests

Unit Tests #379

Workflow file for this run

name: Unit Tests
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }} - (MU: ${{ matrix.multisite }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false # do not fail fast, let all the failing tests fail.
matrix:
php: [8.0, 8.1]
multisite: [0, 1]
wp_version: ["latest"]
env:
WP_CORE_DIR: /tmp/wordpress/
WP_TESTS_DIR: /tmp/wordpress-tests-lib
WP_VERSION: ${{ matrix.wp_version }}
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 of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ github.token }}
- name: Check out code
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
- name: Set up WordPress and Plugin
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 ${{ matrix.wp_version }}
rm -rf "${WP_CORE_DIR}wp-content/plugins"
mkdir -p "${WP_CORE_DIR}wp-content/plugins/wp-graphql-buddypress"
rsync -a --exclude=.git . "${WP_CORE_DIR}wp-content/plugins/wp-graphql-buddypress"
cd ${WP_CORE_DIR}wp-content/plugins/wp-graphql-buddypress && composer install
- name: Run all tests
run: |
cd ${WP_CORE_DIR}wp-content/plugins/wp-graphql-buddypress
composer phpunit