This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
wp #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: wp | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
types: [opened, reopened, synchronize] | |
paths: | |
- "**.php" | |
- "composer.json" | |
- "phpcs.xml.dist" | |
- "phpstan.neon.dist" | |
- "phpunit.xml.dist" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
DB_NAME: wordpress_test | |
DB_PASS: wordpress_test | |
DB_ROOT_PASS: root | |
DB_USER: wordpress_test | |
PHP_EXTENSIONS: mysqli | |
strategy: | |
fail-fast: true | |
matrix: | |
php: ['7.4', '8.0', '8.1', '8.2', '8.3'] | |
wp: ['6.*', '5.*'] | |
services: | |
database: | |
image: 'mariadb:10.11.5' | |
env: | |
MYSQL_ROOT_PASSWORD: ${{ env.DB_ROOT_PASS }} | |
MYSQL_DATABASE: ${{ env.DB_NAME }} | |
MYSQL_USER: ${{ env.DB_USER }} | |
MYSQL_PASSWORD: ${{ env.DB_PASS }} | |
ports: | |
- 3306:3306 | |
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Get Composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Setup PHP extensions cache environment | |
id: php-ext-cache | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.PHP_EXTENSIONS }} | |
key: php-${{ matrix.php }}-ext | |
- name: Setup PHP extensions cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.php-ext-cache.outputs.dir }} | |
key: ${{ steps.php-ext-cache.outputs.key }} | |
restore-keys: ${{ steps.php-ext-cache.outputs.key }} | |
- name: Setup Composer cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: php-${{ matrix.php }}-composer- | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.PHP_EXTENSIONS }} | |
tools: composer:v2 | |
- name: Install dependencies | |
run: | | |
composer require "wp-phpunit/wp-phpunit:${{ matrix.wp }}" "roots/wordpress:${{ matrix.wp }}" --no-interaction --no-update --dev | |
composer install --prefer-dist | |
- name: Run test | |
run: | | |
composer phpcs | |
composer phpstan | |
vendor/bin/phpunit --coverage-clover coverage.xml | |
env: | |
WP_ENVIRONMENT_TYPE: development | |
DB_HOST: 127.0.0.1:${{ job.services.database.ports['3306'] }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |