diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index a5fbcd0..ec85cf4 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -29,6 +29,17 @@ jobs: - name: Checkout uses: actions/checkout@v3 - uses: pantheon-systems/validate-readme-spacing@v1 + php8-compatibility: + name: PHP 8.x Compatibility + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: PHP Compatibility + uses: pantheon-systems/phpcompatibility-action@dev + with: + test-versions: 8.0- + paths: ${{ github.workspace }}/*.php ${{ github.workspace }}/inc/*.php test-phpunit-74: needs: lint runs-on: ubuntu-latest @@ -54,21 +65,23 @@ jobs: - name: Install Composer dependencies run: | composer update && composer install + - name: Run PHP linting + run: composer phplint - name: Run PHPUnit run: bash ./bin/phpunit-test.sh - test-phpunit-82: + test-phpunit-83: needs: lint runs-on: ubuntu-latest services: mariadb: image: mariadb:10.6 - name: PHP 8.2 Unit Tests + name: PHP 8.3 Unit Tests steps: - uses: actions/checkout@v3 - - name: Setup PHP 8.2 + - name: Setup PHP 8.3 uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 extensions: mysqli, zip, imagick - name: Start MySQL Service run: sudo systemctl start mysql @@ -80,5 +93,7 @@ jobs: restore-keys: test-phpunit-dependencies-${{ hashFiles('composer.json') }} - name: Install Composer dependencies run: composer install + - name: Run PHP linting + run: composer phplint - name: Run PHPUnit run: bash ./bin/phpunit-test.sh diff --git a/bin/install-local-tests.sh b/bin/install-local-tests.sh new file mode 100755 index 0000000..c1f8cc5 --- /dev/null +++ b/bin/install-local-tests.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -e + +# Initialize variables with default values +TMPDIR="/tmp" +DB_NAME="wordpress_test" +DB_USER="root" +DB_PASS="" +DB_HOST="127.0.0.1" +WP_VERSION="latest" +SKIP_DB="" + +# Display usage information +usage() { + echo "Usage:" + echo "./install-local-tests.sh [--dbname=wordpress_test] [--dbuser=root] [--dbpass=''] [--dbhost=127.0.0.1] [--wpversion=latest] [--no-db]" +} + +# Parse command-line arguments +for i in "$@" +do +case $i in + --dbname=*) + DB_NAME="${i#*=}" + shift + ;; + --dbuser=*) + DB_USER="${i#*=}" + shift + ;; + --dbpass=*) + DB_PASS="${i#*=}" + shift + ;; + --dbhost=*) + DB_HOST="${i#*=}" + shift + ;; + --wpversion=*) + WP_VERSION="${i#*=}" + shift + ;; + --no-db) + SKIP_DB="true" + shift + ;; + *) + # unknown option + usage + exit 1 + ;; +esac +done + +# Run install-wp-tests.sh +echo "Installing local tests into ${TMPDIR}" +bash "$(dirname "$0")/install-wp-tests.sh" "$DB_NAME" "$DB_USER" "$DB_PASS" "$DB_HOST" "$WP_VERSION" "$SKIP_DB" + +# Run PHPUnit +echo "Running PHPUnit" +composer phpunit diff --git a/composer.json b/composer.json index f87c9e1..26ce502 100644 --- a/composer.json +++ b/composer.json @@ -29,12 +29,16 @@ "prefer-stable": true, "scripts": { "lint": [ - "@phpcs" + "@phpcs", + "@phplint" ], "phpcs": "phpcs", "phpcbf": "phpcbf", - "phpunit": "phpunit", - "test": "@phpunit" + "phplint": "find . -type f -name '*.php' -not -path './vendor/*' -not -path './tests/*' -exec php -l {} \\;", + "phpunit": "phpunit --do-not-cache-result", + "test": "@phpunit", + "test:install": "bin/install-local-tests.sh --no-db", + "test:install:withdb": "bin/install-local-tests.sh" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index b74a1a7..f694243 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "762aedeb842219cbe0204d08822e130a", + "content-hash": "495907a95f131d852721af5a9bdc4055", "packages": [], "packages-dev": [ {