Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new external media endpoint #40145

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bd5e753
Add Google Photos Picker new WPCOM endpoints
zaerl Nov 12, 2024
c9b92d7
changelog
zaerl Nov 12, 2024
a512d13
Backup: Add next daily backup schedule time (#39914)
Initsogar Nov 12, 2024
f05867c
Repo Gardening: allow escalating issues to multiple groups (#39973)
jeherve Nov 12, 2024
b42824f
General: Bump minimum WordPress version to 6.6 (#40146)
tbradsha Nov 12, 2024
04af86b
Coming Soon: Change the color on the coming soon banner to new WordPr…
katinthehatsite Nov 12, 2024
c663031
Jetpack AI: Adding "transform list into table" functionality back to …
mwatson Nov 12, 2024
6baa6d5
Repo Gardening: update conditions when AI Labelling is triggered (#40…
jeherve Nov 13, 2024
0b45b96
Boost: Fix broken Beta tag for "Auto-Resize Lazy Images" (#40143)
dilirity Nov 13, 2024
bfe4286
Additional CSS: Update the upgrade nudge with the correct plan (#40107)
BogdanUngureanu Nov 13, 2024
9cd7a8f
Add missing endpoint
zaerl Nov 13, 2024
cd25cb0
Fix phan errors
zaerl Nov 13, 2024
ebef826
Jetpack AI: add featured image styles support (#40113)
CGastrell Nov 13, 2024
d7d7102
Repo Gardening: cover more use-cases of changelog files (#40160)
jeherve Nov 13, 2024
3669f38
ci: Fix coverage munger with no coverage (#40150)
anomiex Nov 13, 2024
bbe16de
Jetpack Sync: Add 'od_url_metrics' in blacklisted post types (#40158)
fgiannar Nov 13, 2024
410917f
Boost: Cornerstone Pages list UI tweaks (#40163)
dilirity Nov 13, 2024
e2ab2c1
General: Bump minimum PHP version to 7.2 (#40147)
tbradsha Nov 13, 2024
e1fd272
Repo Gardening: update Type column in project board based off label (…
jeherve Nov 13, 2024
88d9ec8
Protect: Add Scan tab threat count (#40056)
dkmyta Nov 13, 2024
494d36b
ThreatFixerButton: Add tooltips alt (#40111)
dkmyta Nov 13, 2024
a24a5f6
Protect Status: Add a threats list property to the status, and deprec…
nateweller Nov 13, 2024
3eeff5b
Backup: fix backup pricing placeholder (#40157)
Initsogar Nov 13, 2024
53cd95d
Remove json_decode
zaerl Nov 14, 2024
612faa7
Add HTTP header injection
zaerl Nov 14, 2024
486a04b
SupportInteractions: Pass params on get (#40185)
heavyweight Nov 14, 2024
d8d592d
Fix: return type
zaerl Nov 14, 2024
7b6f3e3
Social: Add utm toggle sync (#40144)
gmjuhasz Nov 14, 2024
e0cdabc
Add direct output of binary
zaerl Nov 14, 2024
f7a2f86
Add checks for output error
zaerl Nov 14, 2024
47bfdb5
Jetpack AI: Make sure we validate that the new option exists (#40186)
mwatson Nov 14, 2024
b5dede3
Update/wpcomsh package to sync growth constant features (#40187)
CodeyGuyDylan Nov 14, 2024
fcf3010
Add/jetpack growth to constants (#40176)
CodeyGuyDylan Nov 14, 2024
bbb0564
coverage: Always process coverage, even if tests fail (#40167)
anomiex Nov 14, 2024
1f68cdf
Jetpack: show connection cards with disabled promotions (#40179)
sergeymitr Nov 14, 2024
fa3e13d
Migrate to WordPress.com: remove the plugin (#40166)
jeherve Nov 14, 2024
8ee1c37
Codesniffer: remove PHP 7.0 and 7.1 support (#40174)
tbradsha Nov 14, 2024
a4ea55a
tools: Run `jetpack install --root` when releasing plugins (#40193)
anomiex Nov 14, 2024
13cb3bc
Backport backup 3.0 Changes (#40194)
Initsogar Nov 14, 2024
b8f11c6
cli: Rewrite test command (#40175)
anomiex Nov 14, 2024
33c1e82
jetpack: Limit test-coverage concurrency (#40195)
anomiex Nov 14, 2024
af007b7
Jetpack AI: bug hotfix - general image disabled input (#40198)
CGastrell Nov 14, 2024
41823b2
Add Google Photos Picker new WPCOM endpoints
zaerl Nov 12, 2024
50465ce
changelog
zaerl Nov 12, 2024
ef0e45e
Add missing endpoint
zaerl Nov 13, 2024
cd92207
Fix phan errors
zaerl Nov 13, 2024
7418144
Remove json_decode
zaerl Nov 14, 2024
facde9f
Add HTTP header injection
zaerl Nov 14, 2024
86b1108
Fix: return type
zaerl Nov 14, 2024
a3d5798
Add direct output of binary
zaerl Nov 14, 2024
5020c8a
Add checks for output error
zaerl Nov 14, 2024
3230657
Merge branch 'add/new-external-media-endpoint' of github.com:Automatt…
zaerl Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
52 changes: 32 additions & 20 deletions .github/files/coverage-munger/process-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,39 @@ echo '::endgroup::'
TMP_DIR=$( mktemp -d )
trap 'rm -rf "$TMP_DIR"' exit

echo "::group::Combining PHP coverage"
composer --working-dir="$BASE" update
"$BASE"/vendor/bin/phpcov merge --php artifacts/php-combined.cov coverage
perl -i -pwe 'BEGIN { $prefix = shift; $prefix=~s!/*$!/!; $re = qr/\Q$prefix\E/; $l = length( $prefix ); } s!s:(\d+):"$re! sprintf( qq(s:%d:"), $1 - $l ) !ge' "$GITHUB_WORKSPACE" artifacts/php-combined.cov
echo '::endgroup::'

echo "::group::Combining JS coverage"
pnpm --filter=jetpack-gh-config-munger exec istanbul-merge --out "$PWD"/artifacts/js-combined.json $( find "$PWD/coverage" -name '*.json' )
perl -i -pwe 'BEGIN { $prefix = shift; $prefix=~s!/*$!/!; $re = qr/\Q$prefix\E/; } s!"$re!"!g' "$GITHUB_WORKSPACE" artifacts/js-combined.json
echo '::endgroup::'

echo "::group::Creating PHP coverage summary"
"$BASE"/extract-php-summary-data.php artifacts/php-combined.cov > "$TMP_DIR/php-summary.tsv"
echo '::endgroup::'
TMP=$( find "$PWD/coverage" -name '*.cov' )
if [[ -n "$TMP" ]]; then
echo "::group::Combining PHP coverage"
composer --working-dir="$BASE" update
"$BASE"/vendor/bin/phpcov merge --php artifacts/php-combined.cov coverage
perl -i -pwe 'BEGIN { $prefix = shift; $prefix=~s!/*$!/!; $re = qr/\Q$prefix\E/; $l = length( $prefix ); } s!s:(\d+):"$re! sprintf( qq(s:%d:"), $1 - $l ) !ge' "$GITHUB_WORKSPACE" artifacts/php-combined.cov
echo '::endgroup::'

echo "::group::Creating PHP coverage summary"
"$BASE"/extract-php-summary-data.php artifacts/php-combined.cov > "$TMP_DIR/php-summary.tsv"
echo '::endgroup::'
else
echo "No PHP coverage files found!"
touch "$TMP_DIR/php-summary.tsv"
fi

echo "::group::Creating JS coverage summary"
mkdir "$TMP_DIR/js"
cp artifacts/js-combined.json "$TMP_DIR/js"
pnpm --filter=jetpack-gh-config-munger exec nyc report --no-exclude-after-remap --report-dir="$TMP_DIR" --temp-dir="$TMP_DIR/js" --reporter=json-summary
jq -r 'to_entries[] | select( .key != "total" ) | [ .key, .value.lines.total, .value.lines.covered ] | @tsv' "$TMP_DIR/coverage-summary.json" > "$TMP_DIR/js-summary.tsv"
echo '::endgroup::'
TMP=$( find "$PWD/coverage" -name '*.json' )
if [[ -n "$TMP" ]]; then
echo "::group::Combining JS coverage"
pnpm --filter=jetpack-gh-config-munger exec istanbul-merge --out "$PWD"/artifacts/js-combined.json $TMP
perl -i -pwe 'BEGIN { $prefix = shift; $prefix=~s!/*$!/!; $re = qr/\Q$prefix\E/; } s!"$re!"!g' "$GITHUB_WORKSPACE" artifacts/js-combined.json
echo '::endgroup::'

echo "::group::Creating JS coverage summary"
mkdir "$TMP_DIR/js"
cp artifacts/js-combined.json "$TMP_DIR/js"
pnpm --filter=jetpack-gh-config-munger exec nyc report --no-exclude-after-remap --report-dir="$TMP_DIR" --temp-dir="$TMP_DIR/js" --reporter=json-summary
jq -r 'to_entries[] | select( .key != "total" ) | [ .key, .value.lines.total, .value.lines.covered ] | @tsv' "$TMP_DIR/coverage-summary.json" > "$TMP_DIR/js-summary.tsv"
echo '::endgroup::'
else
echo "No JS coverage files found!"
touch "$TMP_DIR/js-summary.tsv"
fi

echo "::group::Combining coverage summaries"
sort "$TMP_DIR/php-summary.tsv" "$TMP_DIR/js-summary.tsv" > artifacts/summary.tsv
Expand Down
19 changes: 4 additions & 15 deletions .github/files/generate-ci-matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,18 @@
'script' => 'test-php',
'php' => $php,
'wp' => 'latest',
'timeout' => 20, // 2023-08-17: Successful runs seem to take up to ~12 minutes.
'timeout' => 20, // 2024-11-12: Successful runs seem to take up to ~7 minutes.
);
}

// TODO: When WordPress 6.5 is no longer supported, this can be removed. Runs too slow on ubuntu-24.04 (ubuntu-latest).
$matrix[] = array(
'name' => 'PHP tests: PHP 7.0 WP previous',
'runner' => 'ubuntu-22.04',
'script' => 'test-php',
'php' => '7.0',
'wp' => 'previous',
'timeout' => 20, // 2023-08-17: Successful runs seem to take up to ~12 minutes.
'force-package-tests' => true,
);

foreach ( array( 'previous', 'trunk' ) as $wp ) {
$phpver = $versions['PHP_VERSION'];
$matrix[] = array(
'name' => "PHP tests: PHP {$phpver} WP $wp",
'script' => 'test-php',
'php' => $phpver,
'wp' => $wp,
'timeout' => 15, // 2021-01-18: Successful runs seem to take ~8 minutes for the 7.4 trunk run, ~5.5-6 for 7.x and 8.0.
'timeout' => 15, // 2024-11-12: Successful runs seem to take ~7 minutes with PHP 8.2.
);
}

Expand Down Expand Up @@ -115,15 +104,15 @@
$matrix[] = array(
'name' => 'JS tests',
'script' => 'test-js',
'timeout' => 15, // 2021-01-18: Successful runs seem to take ~5 minutes.
'timeout' => 15, // 2024-11-12: Successful runs seem to take ~5 minutes.
);

// Add Coverage tests.
$matrix[] = array(
'name' => 'Code coverage',
'script' => 'test-coverage',
'wp' => 'latest',
'timeout' => 40, // 2024-10-30: Successful runs seem to take ~30 minutes. We'll need to improve that.
'timeout' => 40, // 2024-11-12: Successful runs seem to take ~14 minutes.
);

// END matrix definitions.
Expand Down
3 changes: 0 additions & 3 deletions .github/files/phpcompatibility-dev-phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
<rule ref="PHPCompatibilityWP">
<!-- Doesn't hurt anything, earlier versions ignore attributes. -->
<exclude name="PHPCompatibility.Attributes.NewAttributes.Found" />

<!-- We're not ready for 8.4 yet. Hopefully https://core.trac.wordpress.org/ticket/58719 will happen before we are. -->
<exclude name="PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam.Deprecated" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion .github/files/select-wordpress-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ case "$WP_BRANCH" in
previous)
# We hard-code the version here because there's a time near WP releases where
# we've dropped the old 'previous' but WP hasn't actually released the new 'latest'
WORDPRESS_TAG=6.5
WORDPRESS_TAG=6.6
;;
*)
echo "Unrecognized value for WP_BRANCH: $WP_BRANCH" >&2
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=22.9.0
PNPM_VERSION=9.3.0

# Other useful version numbers.
MIN_PHP_VERSION=7.0
MIN_PHP_VERSION=7.2
MAX_PHP_VERSION=8.3
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: [ '7.0', '7.2', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php-versions: [ '7.2', '7.4', '8.0', '8.1', '8.2', '8.3' ]
experimental: [ false ]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
- name: Process coverage results
env:
CHANGED: ${{ steps.changed.outputs.projects }}
if: matrix.script == 'test-coverage'
if: matrix.script == 'test-coverage' && always()
run: .github/files/coverage-munger/process-coverage.sh

- name: Check for artifacts
Expand Down
6 changes: 0 additions & 6 deletions .phan/config.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,5 @@ function make_phan_config( $dir, $options = array() ) {
$config['minimum_target_php_version'] = $m[1];
}

// Disable PhanDeprecatedImplicitNullableParam if still supporting PHP 7.0
// @todo Remove this once we drop PHP 7.0 support everywhere.
if ( isset( $config['minimum_target_php_version'] ) && version_compare( $config['minimum_target_php_version'], '7.1.0', '<' ) ) {
$config['suppress_issue_types'][] = 'PhanDeprecatedImplicitNullableParam';
}

return $config;
}
4 changes: 2 additions & 2 deletions .phpcs.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!-- This file configures everything except the list of rules. -->
<!-- The separation is so .github/files/phpcompatibility-dev-phpcs.xml can use the same config with a different rule set. -->
<ruleset>
<config name="minimum_supported_wp_version" value="6.5" />
<config name="testVersion" value="7.0-"/>
<config name="minimum_supported_wp_version" value="6.6" />
<config name="testVersion" value="7.2-"/>

<!-- Use our custom filter for `.phpcsignore` and `.phpcs.dir.xml` support. -->
<arg name="filter" value="vendor/automattic/jetpack-phpcs-filter/src/PhpcsFilter.php" />
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"phan/phan": "^5.4",
"php-parallel-lint/php-parallel-lint": "^1.4.0",
"php-stubs/woocommerce-stubs": ">=8.7",
"php-stubs/wordpress-stubs": ">=6.5",
"php-stubs/wordpress-tests-stubs": ">=6.5",
"php-stubs/wordpress-stubs": ">=6.6",
"php-stubs/wordpress-tests-stubs": ">=6.6",
"php-stubs/wp-cli-stubs": "^2.10",
"sirbrillig/phpcs-changed": "^2.11.5",
"squizlabs/php_codesniffer": "^3.6.2"
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

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

4 changes: 2 additions & 2 deletions docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,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 7.0
* ### Checking Jetpack's PHP for compatibility with different versions of PHP

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

```sh
composer phpcs:compatibility
Expand Down
53 changes: 50 additions & 3 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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 7.0 to 8.3.
All projects should be compatible with PHP versions WordPress supports. That's currently PHP 7.2 to 8.3.

## First Time

Expand Down Expand Up @@ -266,15 +266,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 7.0 to 8.3. 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.2 to 8.3. 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 6.5 to 9.0, to support PHP 7.0 to 8.3.
* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 8.5 to 9.6, to support PHP 7.2 to 8.3.
* 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 Expand Up @@ -315,6 +315,53 @@ For JS tests, you'll probably have a `test` script in package.json that runs `je

There's no need to be concerned about collisions with other projects' coverage files, a separate directory is used per project. The coverage files are also automatically copied to `ARTIFACTS_DIR`.

If you want to generate coverage locally, e.g. with `jetpack test coverage`, note that generating PHP coverage requires the [pcov](https://pecl.php.net/package/pcov) or [xdebug](https://pecl.php.net/package/xdebug) extensions. We use `pcov` for the CI runs; results from `xdebug` may be slightly different.

<details><summary>Installing the PHP pcov extension on Linux</summary>

On most Linux distributions, you can install the PHP pcov extension using your package manager:

- For Ubuntu/Debian-based systems:
```
sudo apt-get install php8.2-pcov
```
- For Arch Linux:
Install the AUR package "php-pcov" from https://aur.archlinux.org/packages/php-pcov

For other Linux distributions, consult your package manager's documentation or consider compiling from source.

</details>

Mac users have reported having trouble installing the PHP pcov extension. See the dropdown below for Mac-specific instructions.

<details><summary>Installing the PHP pcov extension on Mac</summary>

This assumes you have PHP installed via Homebrew, e.g. you've done `brew install [email protected]`.

1. First, check whether pcov is already installed by running `php --ri pcov`. If it prints something like this, you should already be good:
```
pcov

PCOV support => Enabled
PCOV version => 1.0.11
pcov.directory => /some/path/
pcov.exclude => none
pcov.initial.memory => 65336 bytes
pcov.initial.files => 64
```
2. You may need to `brew install pkg-config zlib` to install some necessary dependencies.
3. Update the list of available extensions: `pecl channel-update pecl.php.net`
4. Build the extension: `pecl install pcov`
- If the build process fails due to mkdir errors with the pecl directory, you might try `mkdir -p /opt/homebrew/lib/php/pecl` and running the install again.
5. You may also need to tell PHP where to find the newly-installed extension.
1. Run `pecl config-get ext_dir` to find where pecl installs extensions.
2. Run `php -r 'echo ini_get( "extension_dir" ) . "\n";'` to find where PHP currently expects extensions to live.
3. If those are the same, great! If not, you have two options:
* If PHP's current directory is empty, you could find your `php.ini` file (`php --ini`) and change `extension_dir` to pecl's location.
* Or else, pecl probably added `extension=pcov.so` to an ini file somewhere. You could change the `pcov.so` value to be the full path inside pecl's directory.

</details>

## Mirror repositories

Most projects in the monorepo should have a mirror repository holding a built version of the project, ready for deployment. Follow these steps to create the mirror repo and configure the monorepo tooling to push to it.
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)

- 7.0 - current
- 7.2 - current

### Hosting providers(High)

Expand Down
Loading
Loading