Skip to content

Run PHPUnit on issue/18-19 #47

Run PHPUnit on issue/18-19

Run PHPUnit on issue/18-19 #47

Workflow file for this run

name: PHPUnit
run-name: Run PHPUnit on `${{ github.head_ref }}`
on:
push:
branches:
- master
paths:
- Plugin.php
- includes/**
- tests/**
- .github/workflows/phpunit.yml
pull_request:
paths:
- Plugin.php
- includes/**
- tests/**
- .github/workflows/phpunit.yml
workflow_dispatch:
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: wordpress
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
WP_VERSION: latest
WP_MULTISITE: '0'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: post_max_size=256M
coverage: xdebug #optional, setup coverage driver
extensions: mysqli, mbstring, intl
- name: Check PHP Version
run: php -v
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Set up Composer caching
uses: actions/cache@v3.2.4
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer install
run: composer install --optimize-autoloader --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
- name: Install WP Tests
run: ./bin/install-wp-tests.sh ${MYSQL_DATABASE} ${MYSQL_USER} ${MYSQL_PASSWORD} ${DB_HOST}:${DB_PORT} ${WP_VERSION}
- name: phpunit tests
run: ./vendor/bin/phpunit --coverage-text