Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Renovate[bot]: Update actions/checkout digest to 8ade135 #572

Renovate[bot]: Update actions/checkout digest to 8ade135

Renovate[bot]: Update actions/checkout digest to 8ade135 #572

Workflow file for this run

name: PHPUnit Tests
on:
push:
branches:
- develop
workflow_dispatch:
pull_request:
# Once weekly On Sundays at 00:00 UTC.
schedule:
- cron: '0 0 * * 0'
jobs:
# Runs the PHPUnit tests for ClassicPress.
#
# Performs the following steps:
# - Cancel workflow if PR updated.
# - Checkout ClassicPress.
# - Set environment variables.
# - Read .nvmrc.
# - Installs NodeJS.
# - Sets up caching for NPM.
# - Setup, wait for and initialise MySQL.
# - Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Configure PHP.
# - Set up locale.
# - Install PHPUnit and Composer dependencies.
# - Make Composer packages available globally.
# - Log debug information.
# - Create config file.
# - Set up object cache if needed for memcached tests.
# - Set up a Memcached server if needed.
# - Clone PHP.net if needed for unit tests.
# - Run PHPUnit Tests.
test-php:
name: "PHP ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }}${{ matrix.experimental && ' - Experimental' || '' }}"
runs-on: ubuntu-latest
if: ${{ github.repository == 'ClassicPress/ClassicPress-v2' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.0', '7.4' ]
mysql: [ '5.7' ]
memcached: [ false ]
experimental: [ false ]
include:
- php: '7.4'
mysql: '5.7'
memcached: true
experimental: false
- php: '8.2'
mysql: '5.7'
memcached: false
experimental: true
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: Read .nvmrc
run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvmrc
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: '${{ steps.nvmrc.outputs.NVMRC }}'
- name: Use cached Node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql root password: "password"
mysql version: "${{ matrix.mysql }}"
- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --port 3306 -u root -ppassword --silent; do
sleep 1
done
- name: Initialise MySQL
run: |
mysql --host 127.0.0.1 --port 3306 -u root -ppassword -e "SELECT @@VERSION"
mysql --host 127.0.0.1 --port 3306 -u root -ppassword < tools/local-env/mysql-init.sql
mysql --host 127.0.0.1 --port 3306 -u root -ppassword -e "SHOW DATABASES"
- name: Install dependencies
run: npx install-changed --install-command="npm ci"
- name: Set up PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php }}"
ini-values: >-
mysql.default_host=127.0.0.1,
mysql.default_port=3306,
mysql.default_socket=/var/run/mysqld/mysqld.sock
extensions: >-
bcmath,
curl,
dom,
exif,
gd,
iconv,
imagick,
intl,
libxml,
mbstring,
memcached,
mysql,
mysqli,
pcntl,
pdo,
pdo_mysql,
pdo_sqlite,
soap,
sqlite,
zip
coverage: none
- name: Set up locale
run: |
sudo locale-gen es_ES.UTF-8 fr_FR.UTF-8 ru_RU.UTF-8
sudo update-locale LC_ALL="es_ES.UTF-8 fr_FR.UTF-8 ru_RU.UTF-8"
- name: Install PHPUnit and Composer dependencies
run: |
composer require phpunit/phpunit "9.*" -W --no-progress --no-ansi --no-interaction
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Show debug information
run: |
set +e
set -x
npm --version
node --version
curl --version
git --version
svn --version
php --version
phpunit --version
composer --version
grunt --version
lsb_release -a
localectl list-locales
- name: Create ClassicPress config file for tests
run: |
cp wp-tests-config-sample.php wp-tests-config.php
sed -i 's/youremptytestdbnamehere/classicpress_develop_tests/g' wp-tests-config.php
sed -i 's/yourusernamehere/root/g' wp-tests-config.php
sed -i 's/yourpasswordhere/password/g' wp-tests-config.php
sed -i 's/localhost/127.0.0.1/g' wp-tests-config.php
- name: Set up object cache
if: ${{ matrix.memcached }}
run: |
cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
- name: Set up a Memcached server
if: ${{ matrix.memcached }}
uses: niden/actions-memcached@v7
- name: Clone PHP.net and create local supported versions for PHPUnit tests
if: ${{ matrix.memcached }}
run: |
mkdir php.net
git clone https://github.com/php/web-php php.net
php -d error_reporting=E_ERROR -f php.net/supported-versions.php > supported-versions.html
- name: Run PHPUnit default
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:default
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit ajax
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:ajax
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit multisite
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:multisite
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit ms-files
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:ms-files
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit external-http
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:external-http
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit restapi-jsclient
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:restapi-jsclient
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit wp-api-client-fixtures
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:wp-api-client-fixtures
continue-on-error: ${{ matrix.experimental }}