Skip to content

Commit

Permalink
Merge branch 'trunk' into add/js-build-for-jetpack-wpcom-mu
Browse files Browse the repository at this point in the history
  • Loading branch information
okmttdhr committed Nov 24, 2023
2 parents 1696a90 + e9e7460 commit e77f92a
Show file tree
Hide file tree
Showing 931 changed files with 6,686 additions and 5,953 deletions.
1 change: 1 addition & 0 deletions .github/.phpcs.dir.phpcompatibility.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="Jetpack-Compat-NoWP" />
<rule ref="Jetpack-Compat-82" />
</ruleset>
1 change: 1 addition & 0 deletions .github/.phpcs.dir.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="Jetpack-NoWP" />
<rule ref="Jetpack-Compat-82" />
</ruleset>
2 changes: 1 addition & 1 deletion .github/actions/tool-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
# Read tool versions
. .github/versions.sh
if [[ "${INPUT_PHP:-$PHP_VERSION}" == 5.6 || "${INPUT_PHP:-$PHP_VERSION}" == 7.[01] ]]; then
if [[ "${INPUT_PHP:-$PHP_VERSION}" == 7.[01] ]]; then
printf "Downgrading composer for PHP %s\n\n" "${INPUT_PHP:-$PHP_VERSION}"
COMPOSER_VERSION=2.2.12
fi
Expand Down
13 changes: 10 additions & 3 deletions .github/files/lint-project-structure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cd $(dirname "${BASH_SOURCE[0]}")/../..
BASE=$PWD
. "$BASE/tools/includes/check-osx-bash-version.sh"
. "$BASE/tools/includes/chalk-lite.sh"
. "$BASE/.github/versions.sh"

if [[ -n "$CI" ]]; then
function debug {
Expand Down Expand Up @@ -139,11 +140,11 @@ for PROJECT in projects/*/*; do
LINE=$(jq --stream -r 'if length == 1 then .[0][:-1] else .[0] end | if . == ["bugs","url"] then ",line=\( input_line_number )" else empty end' "$PROJECT/package.json")
echo "::error file=$PROJECT/package.json$LINE::Setting the project's bug URL to the raw issues list makes no sense. Target the project's label instead, i.e. \"$URL2\"."
fi
if [[ "$URL" == "https://github.com/Automattic/jetpack/labels/"* && "$URL" != "$URL2" ]]; then
if [[ "$URL" == "https://github.com/Automattic/jetpack/labels/"* && "${URL,,}" != "${URL2,,}" ]]; then
EXIT=1
LINE=$(jq --stream -r 'if length == 1 then .[0][:-1] else .[0] end | if . == ["bugs","url"] then ",line=\( input_line_number )" else empty end' "$PROJECT/package.json")
printf -v URL3 "%b" "$(sed -E 's/\\/\\\\/g;s/%([0-9a-fA-F]{2})/\\x\1/g' <<<"$URL")"
if [[ "$URL3" == "$URL2" ]]; then
if [[ "${URL3,,}" == "${URL2,,}" ]]; then
echo "::error file=$PROJECT/package.json$LINE::The \`.bugs.url\` gets (brokenly) passed through \`encodeURI\` by \`npm bugs\`, so it should not be encoded in package.json. Sigh. Try \"$URL2\" instead."
else
echo "::error file=$PROJECT/package.json$LINE::The \`.bugs.url\` appears to be pointing to the wrong label. Try \"$URL2\" instead."
Expand Down Expand Up @@ -226,6 +227,13 @@ for PROJECT in projects/*/*; do
echo "::error file=$PROJECT/composer.json::Package $SLUG should set \`.extra.branch-alias.dev-trunk\` in composer.json."
fi

# - Packages must set `.require.php`.
if [[ "$TYPE" == "packages" ]] && ! jq -e '.require.php // null' "$PROJECT/composer.json" >/dev/null; then
EXIT=1
LINE=$(jq --stream -r 'if length == 1 then .[0][:-1] else .[0] end | if . == ["require"] then ",line=\( input_line_number )" else empty end' "$PROJECT/composer.json")
echo "::error file=$PROJECT/composer.json$LINE::Package $SLUG should set \`.require.php\` in composer.json (probably to \">=$MIN_PHP_VERSION\")."
fi

SUGGESTION="You might add this with \`composer config autoloader-suffix '$(printf "%s" "$SLUG" | md5sum | sed -e 's/[[:space:]]*-$//')_$(sed -e 's/[^0-9a-zA-Z]/_/g' <<<"${SLUG##*/}")ⓥversion'\` in the appropriate directory."

# - If vendor/autoload.php or vendor/autoload_packages.php is production-included, composer.json must set .config.autoloader-suffix.
Expand Down Expand Up @@ -453,7 +461,6 @@ for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/.eslintrc
done

# - .nvmrc should match .github/versions.sh.
. .github/versions.sh
debug "Checking .nvmrc vs versions.sh"
if [[ "$(<.nvmrc)" != "$NODE_VERSION" ]]; then
EXIT=1
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Monorepo packages are excluded in renovate-config.js, where we can read
// the list of them in code.

// We need to keep a wide version range to support PHP 5.6.
// We need to keep a wide version range to support PHP 7.0.
// Note for libraries used in plugins this will only work right for require-dev deps, not require.
{
matchPackageNames: [
Expand Down
2 changes: 1 addition & 1 deletion .github/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ NODE_VERSION=20.8.1
PNPM_VERSION=8.6.8

# Other useful version numbers.
MIN_PHP_VERSION=5.6
MIN_PHP_VERSION=7.0
MAX_PHP_VERSION=8.2
13 changes: 9 additions & 4 deletions .github/workflows/block-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- uses: actions/checkout@v3
with:
Expand All @@ -29,7 +29,8 @@ jobs:
working-directory: gutenberg
run: |
npm ci
npm run build
npx playwright install chromium --with-deps
npm run build:packages
- uses: actions/cache@v3
with:
Expand All @@ -51,8 +52,9 @@ jobs:
env:
CONFIG_KEY: ${{ secrets.E2E_CONFIG_KEY }}
run: |
# Gutenberg Performance tests require disable-animations.php test plugin to be available on a site. Below we inject the mapping for that plugin into a Docker config file
# Gutenberg Performance tests require disable-animations.php test
# plugin to be available on a site. Below we inject the mapping for
# that plugin into a Docker config file.
echo "e2e:" >> ../docker/jetpack-docker-config.yml
echo " volumeMappings:" >> ../docker/jetpack-docker-config.yml
echo " gutenberg/packages/e2e-tests/plugins/disable-animations.php: /var/www/html/wp-content/plugins/disable-animations.php" >> ../docker/jetpack-docker-config.yml
Expand All @@ -61,6 +63,9 @@ jobs:
pnpm config:decrypt
pnpm env:start
# The twentytwentyone theme is required for the post-editor test suite.
pnpm jetpack docker --type e2e --name t1 wp theme install twentytwentyone
- name: Run performance tests
working-directory: tools/e2e-commons
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: [ '5.6', '7.0', '7.2', '7.4', '8.0', '8.1', '8.2' ]
php-versions: [ '7.0', '7.2', '7.4', '8.0', '8.1', '8.2' ]
experimental: [ false ]

steps:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ jobs:
echo "Skipping $SLUG, no changes in it or its dependencies"
elif ! jq --arg script "$TEST_SCRIPT" -e '.scripts[$script] // false' "$P" > /dev/null; then
echo "Skipping $SLUG, no test script is defined in composer.json"
elif php -r 'exit( preg_match( "/^>=\\s*(\\d+\\.\\d+)$/", $argv[1], $m ) && version_compare( PHP_VERSION, $m[1], "<" ) ? 0 : 1 );' "$( jq -r '.require.php // ""' "$P" )"; then
echo "Skipping $SLUG, requires PHP $( jq -r '.require.php // ""' "$P" ) but PHP version is $( php -r 'echo PHP_VERSION;' )"
else
if jq --arg script "skip-$TEST_SCRIPT" -e '.scripts[$script] // false' "$P" > /dev/null; then
{ composer --working-dir="$DIR" run "skip-$TEST_SCRIPT"; CODE=$?; } || true
Expand Down
6 changes: 6 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ function fixDeps( pkg ) {
}
}

// Update localtunnel axios dep to avoid CVE
// https://github.com/localtunnel/localtunnel/issues/632
if ( pkg.name === 'localtunnel' && pkg.dependencies.axios === '0.21.4' ) {
pkg.dependencies.axios = '^1.6.0';
}

// Avoid annoying flip-flopping of sub-dep peer deps.
// https://github.com/localtunnel/localtunnel/issues/481
if ( pkg.name === 'localtunnel' ) {
Expand Down
44 changes: 24 additions & 20 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{
{
"files.exclude": {
"**/.cache/**": true,
"**/.DS_Store/**": true,
"**/.git/**": true,
"**/.hg/**": true,
"**/.svn/**": true,
"**/bower_components/**": true,
"**/CVS/**": true,
"**/jetpack_vendor/**": true,
"**/node_modules/**": true,
"**/vendor/**": true,
},
"intelephense.files.exclude": [
"**/.git/**",
"**/.svn/**",
"**/.hg/**",
"**/CVS/**",
"**/.DS_Store/**",
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**/{Tests,tests}/**",
"**/.history/**",
"**/vendor/**/vendor/**",
"**/packages/**/vendor/**",
"**/projects/**/vendor/**",
"**/plugins/**/vendor/**",
"**/packages/**/wordpress/**",
"**/projects/**/wordpress/**",
"**/plugins/**/wordpress/**",
"**/.cache/**",
"**/jetpack_vendor/**/jetpack_vendor/**",
"**/jetpack_vendor/**"
"**/.cache/**",
"**/.git/**",
"**/.svn/**",
"**/.hg/**",
"**/.history/**",
"**/bower_components/**",
"**/jetpack_vendor/**",
"**/packages/**/wordpress/**",
"**/projects/**/wordpress/**",
"**/plugins/**/wordpress/**",
"**/vendor/**",
],
"phpCodeSniffer.autoExecutable": true,
"phpCodeSniffer.standard": "Automatic",
Expand Down
19 changes: 10 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ These are some things to keep in mind when writing code for Jetpack plugin. Plea

## Versions supported

- Jetpack supports PHP 5.6, as per WordPress' own requirements. Keep that in mind when developing for Jetpack.
- Jetpack supports PHP 7.0, as per WordPress' own requirements. Keep that in mind when developing for Jetpack.
- Jetpack follows [WordPress Core's standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/), with a few additions. The best way to ensure that you adhere to those standards is to set up your IDE [as per the recommendations here](./development-environment.md#use-php-codesniffer-and-eslint-to-make-sure-your-code-respects-coding-standards).
- Jetpack supports the WP current version and the immediate previous version. So if WP version is 4.6, Jetpack will support it, as well as 4.5. It's desirable that when Jetpack is installed in older versions, it doesn't fail in a severe way.
- We support the latest two versions of all major browsers, except IE, where we currently only support 11 and Edge. (see [Browse Happy](http://browsehappy.com) for current latest versions).
Expand Down
4 changes: 2 additions & 2 deletions docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ We strongly recommend that you install tools to review your code in your IDE. It
composer phpcs:lint
```

* ### Checking Jetpack's PHP for compatibility with different versions of PHP since 5.6
* ### Checking Jetpack's PHP for compatibility with different versions of PHP since 7.0

We have a handy `composer` script that will just run the PHP CodeSniffer `PHPCompatibilityWP` ruleset checking for code not compatible with PHP 5.6
We have a handy `composer` script that will just run the PHP CodeSniffer `PHPCompatibilityWP` ruleset checking for code not compatible with PHP 7.0

```sh
composer phpcs:compatibility
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Assume we're in tests/php/bootstrap.php.
$_plugin_root = dirname( dirname( __DIR__ ) );
$_plugin_root = dirname( __DIR__, 2 );

// Locate WordPress or wordpress-develop. We look in several places.
if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
Expand All @@ -18,9 +18,9 @@
} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
// WordPress core environment variable.
$_tests_dir = getenv( 'WP_TESTS_DIR' );
} elseif ( file_exists( dirname( dirname( $_plugin_root ) ) . '/tests/phpunit/includes/bootstrap.php' ) ) {
} elseif ( file_exists( dirname( $_plugin_root, 2 ) . '/tests/phpunit/includes/bootstrap.php' ) ) {
// Installed inside wordpress-develop.
$_tests_dir = dirname( dirname( $_plugin_root ) ) . '/tests/phpunit/includes/bootstrap.php';
$_tests_dir = dirname( $_plugin_root, 2 ) . '/tests/phpunit/includes/bootstrap.php';
} elseif ( file_exists( '/vagrant/www/wordpress-develop/public_html/tests/phpunit/includes/bootstrap.php' ) ) {
// VVV.
$_tests_dir = '/vagrant/www/wordpress-develop/public_html/tests/phpunit';
Expand Down
6 changes: 3 additions & 3 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ All GitHub Actions configuration for the monorepo, including CI, lives in `.gith

## Compatibility

All projects should be compatible with PHP versions WordPress supports. That's currently PHP 5.6 to 8.0.
All projects should be compatible with PHP versions WordPress supports. That's currently PHP 7.0 to 8.2.

## First Time

Expand Down Expand Up @@ -210,15 +210,15 @@ If a project contains PHP tests (typically PHPUnit), it must define `.scripts.te

A MySQL database is available if needed; credentials may be found in `~/.my.cnf`. Note that the host must be specified as `127.0.0.1`, as when passed `localhost` PHP will try to connect via a Unix domain socket which is not available in the Actions environment.

Tests are run with a variety of supported PHP versions from 5.6 to 8.0. If you have tests that only need to be run once, run them when `PHP_VERSION` matches that in `.github/versions.sh`.
Tests are run with a variety of supported PHP versions from 7.0 to 8.2. If you have tests that only need to be run once, run them when `PHP_VERSION` matches that in `.github/versions.sh`.

#### PHP tests for non-plugins

For all project types other than WordPress plugins, the necessary version of PHPUnit and/or any other tools should be pulled in via Composer.

We currently make use of the following packages in testing; it's encouraged to use these rather than introducing other tools that serve the same purpose.

* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 5.7 to 9.0, to support PHP 5.6 to 8.0.
* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 6.5 to 9.0, to support PHP 7.0 to 8.2.
* Do not use `Yoast\PHPUnitPolyfills\TestCases\TestCase` or `Yoast\PHPUnitPolyfills\TestCases\XTestCase`. Just use the `@before`, `@after`, `@beforeClass`, and `@afterClass` annotations directly.
* PHPUnit's built-in mocking is used for class mocks.
* [brain/monkey](https://packagist.org/packages/brain/monkey) is used for mocking functions, and can also provide some functions for minimal WordPress compatibility.
Expand Down
2 changes: 1 addition & 1 deletion docs/testing/regression-checklist/regression-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NOTE: it might become outdated, so it could be a good idea to generate this file

### PHP versions(Low)

- 5.6 - current
- 7.0 - current

### Hosting providers(High)

Expand Down
Loading

0 comments on commit e77f92a

Please sign in to comment.