Wordpress 6 5 #90
Workflow file for this run
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: Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
e2e: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
wordpress-image-tag: ["latest", "4.3-apache"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: ${{ github.workspace }}/plugins/staticpress2019 | |
- id: set_branch_name | |
run: | | |
if [ "${IS_PULL_REQUEST}" = true ] | |
then | |
echo "::set-output name=branch_name::$(echo ${GITHUB_HEAD_REF#refs/heads/} | sed 's/\//_/g')" | |
else | |
echo "::set-output name=branch_name::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" | |
fi | |
env: | |
IS_PULL_REQUEST: ${{ startsWith( github.ref, 'refs/pull/' ) }} | |
- uses: actions/checkout@v4 | |
with: | |
repository: yukihiko-shinoda/docker-compose-jest-puppeteer-staticpress2019 | |
ref: ${{ steps.set_branch_name.outputs.branch_name }} | |
path: ${{ github.workspace }}/docker-compose-jest-puppeteer-staticpress2019 | |
- run: docker-compose -f docker-compose.test.yml run --rm puppeteer | |
working-directory: ${{ github.workspace }}/docker-compose-jest-puppeteer-staticpress2019 | |
env: | |
PATH_TO_PLUGIN_DIRECTORY: ${{ github.workspace }}/plugins | |
WORDPRESS_IMAGE_TAG: ${{ matrix.wordpress-image-tag }} | |
unit: | |
strategy: | |
fail-fast: false | |
matrix: | |
software-versions: | |
# Because current PHP recommended version is 7.4+. | |
# @see https://wordpress.org/support/article/requirements/ | |
# PHP 7.4 is already end of life. | |
# @see https://www.php.net/supported-versions.php | |
- ["8.3", "latest", "<10.0.0", "*", "8.0"] | |
# Because now PHP 8.0 is in the Active Support period and should be focused in development. | |
# @see https://www.php.net/supported-versions.php | |
# According to commit message of this definition, | |
# the trunk version seems to should be tested by current major support PHP version. | |
# @see: | |
# - Rebuild `.travis.yml` file · wp-cli/scaffold-command@fe11bcc | |
# https://github.com/wp-cli/scaffold-command/commit/fe11bcc02a2ee164c987e2cb14fcb08dfe73663b | |
- ["8.3", "trunk", "<10.0.0", "*", "8.0"] | |
# Because 3.7 is the version which start support for auto background update. However, test can't work. | |
# 3.7 - 3.8: When init database before running PHPUnit, wp-includes/wp-db.php db_connect() calls mysql_connect(). | |
# 3.9 - 4.2: wp-includes/class-phpass.php PasswordHash has a deprecated constructor. | |
# @see https://make.wordpress.org/core/handbook/about/release-cycle/releasing-minor-versions/#security | |
# Because WordPress 4.3 doesn't support PHP 7.2. | |
# When call activate_plugin(), | |
# count(): Parameter must be an array or an object that implements Countable | |
# /wp-includes/kses.php:900 | |
- ["7.1", "4.3", "4.8.*|5.7.*", "", "5.7"] | |
- ["8.2", "latest", "<10.0.0", "*", "8.0"] | |
- ["8.1", "latest", "<10.0.0", "*", "8.0"] | |
- ["8.0", "latest", "<10.0.0", "*", "8.0"] | |
- ["7.4", "latest", "", "", "8.0"] | |
- ["7.3", "latest", "", "", "8.0"] | |
- ["7.2", "latest", "", "", "8.0"] | |
- ["7.1", "latest", "", "", "8.0"] | |
- ["7.0", "latest", "", "", "8.0"] | |
# Because of minimum support version. | |
# @see https://wordpress.org/news/2019/04/minimum-php-version-update/ | |
# @see https://ubuntu.com/about/release-cycle | |
- ["5.6", "6.2.5", "", "", "8.0"] | |
env: | |
PHP_VERSION: ${{ matrix.software-versions[0] }} | |
WORDPRESS_VERSION: ${{ matrix.software-versions[1] }} | |
PHPUNIT_REQUIRE: ${{ matrix.software-versions[2] || '4.8.*|5.7.*|<8.0.0' }} | |
MOCKERY_REQUIRE: ${{ matrix.software-versions[3] || '1.3.*' }} | |
MYSQL_VERSION: ${{ matrix.software-versions[4] }} | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:${{ matrix.software-versions[4] }} | |
env: | |
# The MySQL docker container requires these environment variables to be set | |
# so we can create and migrate the test database. | |
# See: https://hub.docker.com/_/mysql | |
MYSQL_ROOT_PASSWORD: examplepass | |
ports: | |
# Opens port 3306 on service container and host | |
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers | |
- 3306:3306 | |
# Before continuing, verify the mysql container is reachable from the ubuntu host | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Shutdown Ubuntu MySQL (SUDO) | |
run: sudo service mysql stop | |
- uses: actions/checkout@v4 | |
# To change `default_authentication_plugin` in MySQL: | |
# - Change options that can only be specified at startup with mysqld in services of GitHub Actions - @znz blog | |
# https://blog.n-z.jp/blog/2021-02-20-github-actions-services-mysqld-option.html | |
- name: Add conf | |
run: | | |
set -eux | |
chmod 644 ${{ github.workspace }}/mysql/conf.d/${{ (env.PHP_VERSION <= '7.3' && 'nativepassword') || 'empty' }}.cnf | |
docker cp ${{ github.workspace }}/mysql/conf.d/${{ (env.PHP_VERSION <= '7.3' && 'nativepassword') || 'empty' }}.cnf ${{ job.services.mysql.id }}:/etc/mysql/conf.d/custom.cnf | |
- name: Restart mysql | |
run: | | |
set -eux | |
docker restart ${{ job.services.mysql.id }} | |
for sleep in 0 ${WAITS:- 1 2 4 8 15 25 100}; do | |
sleep "$sleep" | |
health_status=`docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" ${{ job.services.mysql.id }}` | |
if [ 'starting' != "$health_status" ]; then | |
exit 0 | |
fi | |
done | |
exit 1 | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION }} | |
# It seems to have to be not localhost but 127.0.0.1 on Ubuntu 18.04 . | |
# @see https://stackoverflow.com/a/41997588 | |
- run: bash bin/install-wp-tests.sh wordpress_test root examplepass 127.0.0.1 $WORDPRESS_VERSION | |
# Suppress below error: | |
# Error: dealerdirect/phpcodesniffer-composer-installer (installed globally) contains a Composer plugin which is blocked by your allow-plugins config. | |
# You may add it to the list if you consider it safe. | |
- run: composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true | |
- run: composer global require "phpunit/phpunit:${{ env.PHPUNIT_REQUIRE }}" yoast/phpunit-polyfills "mockery/mockery:${{ env.MOCKERY_REQUIRE }}" | |
- name: Prevent to access real example.org | |
run: sudo echo "127.0.0.1 example.org" | sudo tee -a /etc/hosts | |
- run: phpunit | |
- run: WP_MULTISITE=1 phpunit | |
phpcs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.3 | |
# Suppress below error: | |
# Error: dealerdirect/phpcodesniffer-composer-installer (installed globally) contains a Composer plugin which is blocked by your allow-plugins config. | |
# You may add it to the list if you consider it safe. | |
- run: composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true | |
- run: composer global require wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer phpcompatibility/phpcompatibility-wp automattic/vipwpcs | |
- run: phpcs | |
continue-on-error: true |