Merge pull request #721 from Automattic/fix/720-wordpress-test-wpcs-a… #815
This file contains hidden or 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: PHP Transformer | |
| on: | |
| pull_request: | |
| paths: | |
| - ".github/workflows/php-transformer.yml" | |
| - "php-transformer/**" | |
| - "scripts/production-acceptance-matrix.php" | |
| - "tests/contract/production-acceptance-matrix.php" | |
| push: | |
| branches: | |
| - trunk | |
| paths: | |
| - ".github/workflows/php-transformer.yml" | |
| - "php-transformer/**" | |
| - "scripts/production-acceptance-matrix.php" | |
| - "tests/contract/production-acceptance-matrix.php" | |
| jobs: | |
| validate: | |
| name: Composer validate and test | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: php-transformer | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 | |
| with: | |
| php-version: "8.1" | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Install dependencies | |
| run: composer install --no-interaction --prefer-dist --no-progress | |
| - name: Validate Composer package metadata | |
| run: composer validate --strict | |
| - name: Run package tests | |
| run: composer test | |
| - name: Run repository acceptance matrix contract | |
| working-directory: . | |
| run: php tests/contract/production-acceptance-matrix.php | |
| visual-parity: | |
| name: Generic visual parity tools | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: php-transformer/tools/visual-parity | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Chromium | |
| run: npx playwright install --with-deps chromium | |
| - name: Run visual parity tests | |
| run: npm test | |
| wordpress-site-plan: | |
| name: WordPress site plan integration | |
| runs-on: ubuntu-24.04 | |
| services: | |
| mysql: | |
| image: mysql:8.0.36 | |
| env: | |
| MYSQL_DATABASE: wordpress_test | |
| MYSQL_ALLOW_EMPTY_PASSWORD: "yes" | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping --silent" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 | |
| with: | |
| php-version: "8.1" | |
| extensions: mysqli | |
| tools: composer:v2 | |
| - name: Install package dependencies | |
| working-directory: php-transformer | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Provision pinned WordPress PHPUnit runtime | |
| env: | |
| WORDPRESS_DEVELOP_DIR: ${{ runner.temp }}/wordpress-develop | |
| WORDPRESS_TEST_DB: wordpress_site_plan_test | |
| run: | | |
| git clone --depth=1 --branch 6.7.4 https://github.com/WordPress/wordpress-develop.git "$WORDPRESS_DEVELOP_DIR" | |
| composer config --working-dir="$WORDPRESS_DEVELOP_DIR" --json policy.advisories.ignore-id '{"PKSA-mh9b-91zm-m1gy":{"on-audit":false,"reason":"Pinned WordPress 6.7.4 test runtime; WPCS is not loaded by the integration test."}}' | |
| composer install --working-dir="$WORDPRESS_DEVELOP_DIR" --no-interaction --prefer-dist --no-progress | |
| for attempt in $(seq 1 30); do | |
| if mysql --host=127.0.0.1 --port=3306 --user=root --execute='SELECT 1'; then break; fi | |
| if [ "$attempt" = 30 ]; then exit 1; fi | |
| sleep 2 | |
| done | |
| mysql --host=127.0.0.1 --port=3306 --user=root --execute="DROP DATABASE IF EXISTS $WORDPRESS_TEST_DB; CREATE DATABASE $WORDPRESS_TEST_DB;" | |
| cp "$WORDPRESS_DEVELOP_DIR/wp-tests-config-sample.php" "$WORDPRESS_DEVELOP_DIR/wp-tests-config.php" | |
| WORDPRESS_DEVELOP_DIR="$WORDPRESS_DEVELOP_DIR" WORDPRESS_TEST_DB="$WORDPRESS_TEST_DB" php -r '$config = file_get_contents(getenv("WORDPRESS_DEVELOP_DIR") . "/wp-tests-config.php"); $config = preg_replace("/define\(\s*\x27DB_NAME\x27\s*,\s*[^)]*\);/", "define( \x27DB_NAME\x27, \x27" . getenv("WORDPRESS_TEST_DB") . "\x27 );", $config); $config = preg_replace("/define\(\s*\x27DB_USER\x27\s*,\s*[^)]*\);/", "define( \x27DB_USER\x27, \x27root\x27 );", $config); $config = preg_replace("/define\(\s*\x27DB_PASSWORD\x27\s*,\s*[^)]*\);/", "define( \x27DB_PASSWORD\x27, \x27\x27 );", $config); $config = preg_replace("/define\(\s*\x27DB_HOST\x27\s*,\s*[^)]*\);/", "define( \x27DB_HOST\x27, \x27127.0.0.1:3306\x27 );", $config); file_put_contents(getenv("WORDPRESS_DEVELOP_DIR") . "/wp-tests-config.php", $config);' | |
| - name: Run required WordPress site plan integration | |
| working-directory: php-transformer | |
| env: | |
| REQUIRE_WP_TESTS: "1" | |
| WP_TESTS_DIR: ${{ runner.temp }}/wordpress-develop/tests/phpunit | |
| run: composer test:wordpress-integration |