Skip to content

PHPUnit 環境の修正 #66

PHPUnit 環境の修正

PHPUnit 環境の修正 #66

Workflow file for this run

name: PHP Unit Test
on:
pull_request:
branches:
- master
- develop
- ^feature/.+
jobs:
php_unit:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
wp-versions: ['6.5', '6.4', '6.3']
name: PHP Unit test ${{ matrix.php-versions }} / WP ${{ matrix.wp-versions }} Test
services:
mysql:
image: mysql:5.7
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
steps:
- uses: actions/checkout@v3
# setup node based on the version from the .node-version file, fetched in the previous step
- name: Setup Node.js (.node-version)
uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache multiple paths
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: install npm scripts
run: npm install
- name: Install Composer Packages
run: composer install
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
- name: Install several WordPress version by wp-env.override.json
run: WP_ENV_PHP_VERSION=${{ matrix.php-versions }} WP_ENV_CORE=WordPress/WordPress#${{ matrix.wp-versions }} npm run wp-env start --update
- name: Check WordPress Version
run: npm run wp-env run cli wp core version
- name: Build
run: npm run build
- name: Start Environment
run: npx wp-env start
- name: Run PHP Unit Test
run: npm run phpunit