Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions .github/workflows/reusable-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ on:
use-phar:
type: boolean
required: true
os:
type: string
required: false
default: 'ubuntu-22.04'
mysql:
type: string
required: false
default: ''

jobs:
run-test:
name: WP ${{ inputs.wp }} | PHP ${{ inputs.php }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mysql' && 'MySQL' || 'MariaDB' }}${{ inputs.use-phar && ' (Phar)' || '' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}
runs-on: ubuntu-22.04
name: WP ${{ inputs.wp }} | PHP ${{ inputs.php }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mysql' && 'MySQL' || 'MariaDB' }}${{ inputs.use-phar && ' (Phar)' || '' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
runs-on: ${{ inputs.os || 'ubuntu-22.04' }}
continue-on-error: ${{ inputs.dbtype == 'sqlite' || inputs.object_cache == 'sqlite' }}

env:
Expand All @@ -45,20 +53,29 @@ jobs:

- name: Check existence of composer.json & behat.yml files
id: check_files
shell: bash
run: echo "files_exists=$([ -f composer.json ] && [ -f behat.yml ] && echo true || echo false)" >> "$GITHUB_OUTPUT"

- name: Install Ghostscript
if: steps.check_files.outputs.files_exists == 'true'
if: steps.check_files.outputs.files_exists == 'true' && (inputs.os == 'ubuntu-22.04' || inputs.os == '')
run: |
sudo apt-get update
sudo apt-get install ghostscript -y

- name: Install dependencies (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
run: choco install sqlite ghostscript --yes

- name: Install dependencies (macOS)
if: ${{ startsWith(inputs.os, 'macos') }}
run: brew install ghostscript

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

Expand All @@ -69,7 +86,7 @@ jobs:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}

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

Expand All @@ -78,20 +95,27 @@ jobs:
if: ${{ inputs.dbtype != 'sqlite' }}
uses: shogo82148/actions-setup-mysql@9c42ca180d5f1dd4dceb54c23c5eda0384f4d265 # v1
with:
mysql-version: '8.0' # Standard MySQL version for these tests
mysql-version: ${{ inputs.mysql || '8.0' }}
auto-start: true
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
user: ${{ env.WP_CLI_TEST_DBUSER}}
password: ${{ env.WP_CLI_TEST_DBPASS}}
my-cnf: |
default_authentication_plugin=mysql_native_password
${{ inputs.dbtype == 'mariadb' && '[client]' || '' }}
${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}

- name: Remove system MySQL binary
if: steps.check_files.outputs.files_exists == 'true' && inputs.dbtype != 'sqlite'
run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump

- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true' && inputs.dbtype != 'sqlite'
run: composer prepare-tests

- name: Conditionally use Phar instead of source
if: steps.check_files.outputs.files_exists == 'true' && inputs.use-phar == true
shell: bash
run: echo "TEST_PHAR=nightly" >> $GITHUB_ENV

- name: Check Behat environment
Expand All @@ -100,7 +124,10 @@ jobs:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
WP_CLI_TEST_DEBUG_BEHAT_ENV: 1
SSL_CERT_FILE: '${{ steps.setup-mysql.outputs.base-dir }}/var/ca.pem'
CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
run: composer behat

- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'
Expand All @@ -109,4 +136,6 @@ jobs:
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype }}
TEST_PACKAGE: 'wp-cli/${{ inputs.test-package }}'
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
SSL_CERT_FILE: '${{ steps.setup-mysql.outputs.base-dir }}/var/ca.pem'
CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
run: composer test
50 changes: 46 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
matrix:
php: ['7.2', '8.5']
wp: ['latest', 'trunk']
dbtype: ['mysql', 'sqlite']
dbtype: ['mysql', 'sqlite', 'mariadb']
object_cache: ['none', 'sqlite']
use-phar: [false, true]
os: ['ubuntu-22.04', 'macos-latest', 'windows-latest']
test-package:
- wp-cli-bundle
- wp-cli
Expand Down Expand Up @@ -59,9 +60,6 @@ jobs:
- dbtype: mysql
object_cache: sqlite

# SQLite runs only on WP latest and PHP 8.5
- dbtype: sqlite
wp: trunk
- dbtype: sqlite
php: '7.2'

Expand All @@ -78,11 +76,53 @@ jobs:
wp: trunk
- use-phar: false
wp: latest
- use-phar: true
php: '7.2'

# Limit ancient php on trunk
- php: '7.2'
wp: trunk

# Only run one macos combination: php: 8.5, wp: trunk, dbtype: sqlite, object_cache: none, use-phar: false
- os: macos-latest
php: '7.2'
- os: macos-latest
wp: latest
- os: macos-latest
dbtype: mysql
- os: macos-latest
object_cache: sqlite

# Only run one windows combination: php: 8.5, wp: trunk, dbtype: sqlite, object_cache: none, use-phar: false
- os: windows-latest
php: '7.2'
- os: windows-latest
wp: latest
- os: windows-latest
dbtype: mysql
- os: windows-latest
object_cache: sqlite

# Skip Windows tests for db-command to to environment configuration issues with SQLite.
- os: windows-latest
test-package: db-command

# Limit MariaDB runs to php: 8.5, wp: trunk, os: ubuntu-22.04, object_cache: none, use-phar: false
- dbtype: mariadb
php: '7.2'
- dbtype: mariadb
wp: latest
- dbtype: mariadb
os: macos-latest
- dbtype: mariadb
os: windows-latest
- dbtype: mariadb
object_cache: sqlite
- dbtype: mariadb
use-phar: true



uses: ./.github/workflows/reusable-testing.yml
with:
test-package: ${{ matrix.test-package }}
Expand All @@ -91,4 +131,6 @@ jobs:
dbtype: ${{ matrix.dbtype }}
object_cache: ${{ matrix.object_cache }}
use-phar: ${{ matrix.use-phar }}
os: ${{ matrix.os }}
mysql: ${{ matrix.dbtype == 'mariadb' && 'mariadb-10.11' || 'mysql-8.0' }}

4 changes: 2 additions & 2 deletions bin/test-phar
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ for RELEASE in $RELEASES; do

# Download binary and verify MD5 checksum.
BIN_FOLDER="$(mktemp -d)"
wget -O "${BIN_FOLDER}/wp-cli.phar.md5" "$MD5_URL"
curl -sLo "${BIN_FOLDER}/wp-cli.phar.md5" "$MD5_URL"
TARGET_MD5=$(cat "${BIN_FOLDER}/wp-cli.phar.md5")
wget -O "${BIN_FOLDER}/wp-cli.phar" "$PHAR_URL"
curl -sLo "${BIN_FOLDER}/wp-cli.phar" "$PHAR_URL"
if hash md5sum 2>/dev/null; then
DOWNLOAD_MD5=$(md5sum "${BIN_FOLDER}/wp-cli.phar" | cut -d ' ' -f 1)
else
Expand Down
8 changes: 5 additions & 3 deletions bin/test-source
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ for REPO in $REPOS; do

echo "Testing package $REPO..."

BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=${BUILD_DIR}/vendor/${REPO}/features php ${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php)
FEATURES_FOLDER="${BUILD_DIR}/vendor/${REPO}/features"

BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER="$FEATURES_FOLDER" php "${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php")
echo "Behat Tags: $BEHAT_TAGS"

set +e
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO
if [ $? -ne 0 ]; then
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO --rerun
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO --rerun
if [ $? -ne 0 ]; then
FAILED_PACKAGES="$FAILED_PACKAGES ${RELEASE}:${REPO}"
fi
Expand Down
Loading