Add updated GHA testing workflow

This commit is contained in:
Alain Schlesser 2021-03-03 16:25:18 +00:00
parent 841f1a4fec
commit fc8b342910
3 changed files with 2782 additions and 2892 deletions

View file

@ -1,11 +1,6 @@
name: Testing

on:
push:
branches:
- main
- releases-**
pull_request:
on: pull_request

jobs:

@ -15,7 +10,7 @@ jobs:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: Check out source code
@ -35,7 +30,7 @@ jobs:
coverage: none
tools: composer,cs2pr

- name: Get Composer cache directory
- name: Get Composer cache Directory
if: steps.check_files.outputs.files_exists == 'true'
id: composer-cache
run: |
@ -63,35 +58,55 @@ jobs:
run: composer phpunit

functional: #----------------------------------------------------------------------
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }}
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
wp: ['latest']
mysql: ['8.0']
test: ["composer behat || composer behat-rerun"]
include:
- php: '5.6'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: 'trunk'
mysql: '5.7'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: 'trunk'
mysql: '5.6'
test: "composer behat || composer behat-rerun"
- php: '7.4'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '5.7'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '5.6'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: '3.7'
test: "composer behat || composer behat-rerun || true"
runs-on: ubuntu-latest
mysql: '5.6'
test: "composer behat || composer behat-rerun"
runs-on: ubuntu-20.04

services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: wp_cli_test
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: root
image: mysql:${{ matrix.mysql }}
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"

steps:
- name: Check out source code
@ -103,16 +118,16 @@ jobs:
with:
files: "composer.json, behat.yml"

- name: Set up PHP environment
- name: Set up PHP envirnoment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: mysql, zip, imagick
extensions: mysql, zip
coverage: none
tools: composer

- name: Get Composer cache directory
- name: Get Composer cache Directory
if: steps.check_files.outputs.files_exists == 'true'
id: composer-cache
run: |
@ -127,27 +142,28 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-

- name: Change ImageMagick policy to allow pdf->png conversion.
if: steps.check_files.outputs.files_exists == 'true'
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml

- name: Install dependencies
if: steps.check_files.outputs.files_exists == 'true'
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest

- name: Start MySQL server
if: steps.check_files.outputs.files_exists == 'true'
run: sudo service mysql start
run: sudo systemctl start mysql

- name: Configure DB environment
if: steps.check_files.outputs.files_exists == 'true'
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV

- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true'
run: |
export MYQSL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
mysql -e 'CREATE DATABASE IF NOT EXISTS wp_cli_test;' -uroot -proot
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test_scaffold.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
run: composer prepare-tests

- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'

View file

@ -35,11 +35,11 @@
"wp-cli/shell-command": "^2",
"wp-cli/super-admin-command": "^2",
"wp-cli/widget-command": "^2",
"wp-cli/wp-cli": "dev-master"
"wp-cli/wp-cli": "dev-master",
"wp-cli/wp-cli-tests": "^3.0.1"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"wp-cli/wp-cli-tests": "^2.1"
"roave/security-advisories": "dev-master"
},
"suggest": {
"psy/psysh": "Enhanced `wp shell` functionality"

5586
composer.lock generated

File diff suppressed because it is too large Load diff