Skip to content
Open
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
69 changes: 53 additions & 16 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,45 @@ jobs:
if: success() || failure()
run: npm run lint:pkg-json

compute-previous-wordpress-version:
name: Compute previous WordPress version
runs-on: ubuntu-latest
permissions: {}
outputs:
previous-wordpress-version: ${{ steps.get-previous-wordpress-version.outputs.previous-wordpress-version }}

steps:
- name: Get previous WordPress version
id: get-previous-wordpress-version
run: |
curl \
-H "Accept: application/json" \
-o versions.json \
"http://api.wordpress.org/core/stable-check/1.0/"
LATEST_WP_VERSION="$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)"
# shellcheck disable=SC2034
IFS='.' read -r LATEST_WP_MAJOR LATEST_WP_MINOR LATEST_WP_PATCH <<< "${LATEST_WP_VERSION}"
if [[ "${LATEST_WP_MINOR}" == "0" ]]; then
PREVIOUS_WP_SERIES="$((LATEST_WP_MAJOR - 1)).9"
else
PREVIOUS_WP_SERIES="${LATEST_WP_MAJOR}.$((LATEST_WP_MINOR - 1))"
fi
PREVIOUS_WP_VERSION="$(jq --raw-output --arg series "${PREVIOUS_WP_SERIES}" 'with_entries(select(.key|startswith($series)))|keys[-1]' versions.json)"
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> "$GITHUB_OUTPUT"
rm versions.json

tests:
name: Test Suite
name: PHP ${{ matrix.php }}${{ matrix.wordpress != '' && format( ' (WP {0})', matrix.wordpress ) || '' }}
needs: [compute-previous-wordpress-version]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
wordpress: ['', 'previous major version']
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', needs.compute-previous-wordpress-version.outputs.previous-wordpress-version ) }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -66,23 +102,24 @@ jobs:
- name: Install Node Dependencies
run: npm i

- name: Compile JavaScript App
run: npm run build

- name: Setup MySQL
if: success() || failure()
uses: shogo82148/actions-setup-mysql@v1
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
mysql-version: '8.0'
php-version: '${{ matrix.php }}'
ini-file: development
coverage: none

- name: Docker debug information
run: docker -v

- name: Run JavaScript unit tests
run: npm run test:unit
- name: Start Docker environment
run: npm run wp-env start

- name: Install Subversion
run: sudo apt-get update -y && sudo apt-get install -y subversion
- name: Docker container debug information
run: npm run wp-env run tests-cli wp core version

- name: Log running Docker containers
run: docker ps -a

- name: Run PHP tests
run: |
mysql -uroot -h127.0.0.1 -e 'SELECT version()' \
&& ./bin/install-wp-tests.sh --wp-version=trunk --recreate-db wordpress_test root '' > /dev/null \
&& composer run-script test
run: npm run test:unit:php
221 changes: 0 additions & 221 deletions bin/install-wp-tests.sh

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"lint:php:fix": "composer run-script format",
"lint:md-docs": "wp-scripts lint-md-docs",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"test:php": "npm run test:php:setup && wp-env run tests-wordpress --env-cwd='wp-content/plugins/create-block-theme' composer run-script test",
"test:php:watch": "wp-env run cli --env-cwd='wp-content/plugins/create-block-theme' composer run-script test:watch",
"test:php:setup": "wp-env start",
"test:unit:php:setup": "wp-env start",
"test:unit:php:base": "wp-env run tests-wordpress --env-cwd='wp-content/plugins/create-block-theme' vendor/bin/phpunit -c phpunit.xml.dist --verbose",
"test:unit:php": "npm run test:unit:php:setup && npm run test:unit:php:base",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start src/admin-landing-page.js src/plugin-sidebar.js",
"composer": "wp-env run cli --env-cwd=wp-content/plugins/create-block-theme composer",
Expand Down
5 changes: 0 additions & 5 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path );
}

if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit( 1 );
}

// Give access to tests_add_filter() function.
require_once "{$_tests_dir}/includes/functions.php";

Expand Down