Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into feature/welcome-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsreberski committed Jul 25, 2024
2 parents e9cc408 + b8ae589 commit c4cb36a
Show file tree
Hide file tree
Showing 1,362 changed files with 86,589 additions and 49,140 deletions.
2 changes: 1 addition & 1 deletion .github/files/check-lock-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for FILE in $(git -c core.quotepath=off ls-files 'pnpm-lock.yaml' '**/pnpm-lock.
echo "::endgroup::"
if ! git diff --exit-code pnpm-lock.yaml; then
echo "---" # Bracket message containing newlines for better visibility in GH's logs.
echo "::error file=$FILE::$FILE is not up to date!%0AYou can probably fix this by running \`pnpm install\` in the appropriate directory."
echo "::error file=$FILE::$FILE is not up to date!%0AYou can probably fix this by running \`pnpm install\`.%0AIf that doesn't do it, try \`pnpm install --resolution-only\`."
echo "---"
EXIT=1
fi
Expand Down
12 changes: 11 additions & 1 deletion .github/files/generate-ci-matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$matrix = array();

// Add PHP tests.
foreach ( array( '7.0', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ) as $php ) {
foreach ( array( '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ) as $php ) {
$matrix[] = array(
'name' => "PHP tests: PHP $php WP latest",
'script' => 'test-php',
Expand All @@ -68,6 +68,16 @@
);
}

// TODO: When WordPress 6.5 is no longer supported, this can be removed.
$matrix[] = array(
'name' => 'PHP tests: PHP 7.0 WP previous',
'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(
Expand Down
8 changes: 4 additions & 4 deletions .github/files/jetpack-staging-sites/k6-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export const sites = [
blog_id: '215379549',
},
{
url: 'https://jetpackedgephp74.wpcomstaging.com',
note: 'php 7.4',
url: 'https://jetpackedgephpold.wpcomstaging.com',
note: 'php old',
blog_id: '215379848',
},
{
url: 'https://jetpackedgephp82.wpcomstaging.com',
note: 'php 8.2',
url: 'https://jetpackedgephpnew.wpcomstaging.com',
note: 'php new',
blog_id: '215380000',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

TMP_DIR=$(mktemp -d) # Temp dir where the plugin .zip files are downloaded and unpacked.
REMOTE_DIR='/srv/htdocs/jetpack-staging' # Remote dir where the unpacked plugin files are synced to.
PLUGINS=( "jetpack" "jetpack-mu-wpcom-plugin" "wpcomsh" ); # Plugins to update.
PLUGINS=( "jetpack" "wpcomsh" ); # Plugins to update.
declare -A PLUGIN_DOWNLOAD_URLS # Array used to hold fetched plugin download URLs.

SITES='{
Expand All @@ -18,16 +18,16 @@ SITES='{
"ssh_string": "[email protected]",
"blog_id": "215379549"
},
"jetpackedgephp74.wpcomstaging.com": {
"url": "https://jetpackedgephp74.wpcomstaging.com/",
"note": "php 7.4",
"ssh_string": "jetpackedgephp74[email protected]",
"jetpackedgephpold.wpcomstaging.com": {
"url": "https://jetpackedgephpold.wpcomstaging.com/",
"note": "php old",
"ssh_string": "jetpackedgephpold[email protected]",
"blog_id": "215379848"
},
"jetpackedgephp82.wpcomstaging.com": {
"url": "https://jetpackedgephp82.wpcomstaging.com/",
"note": "php 8.2",
"ssh_string": "jetpackedgephp82[email protected]",
"jetpackedgephpnew.wpcomstaging.com": {
"url": "https://jetpackedgephpnew.wpcomstaging.com/",
"note": "php new",
"ssh_string": "jetpackedgephpnew[email protected]",
"blog_id": "215380000"
},
"jetpackedgeecomm.wpcomstaging.com": {
Expand Down
32 changes: 32 additions & 0 deletions .github/files/lint-project-structure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ declare -A PROJECT_PREFIXES=(
['js-packages']='JS Package'
)

declare -A PKG_VENDOR_DIR_CACHE=()
while IFS=$'\t' read -r PKG VENDOR; do
PKG_VENDOR_DIR_CACHE["$PKG=dev-trunk"]="$VENDOR"
done < <( jq -r '[ .name, if .type == "jetpack-library" then "jetpack_vendor" else "vendor" end ] | @tsv' "$BASE"/projects/packages/*/composer.json )

PACKAGES=$(jq -nc 'reduce inputs as $in ({}; .[ $in.name ] |= ( $in.extra["mirror-repo"] | type == "string" ) )' "$BASE"/projects/packages/*/composer.json)
JSPACKAGES='{}'
for PROJECT in "$BASE"/projects/js-packages/*/.; do
Expand Down Expand Up @@ -401,6 +406,33 @@ for PROJECT in projects/*/*; do
fi
fi

# - Plugin non-dev composer dependencies need to be production-included.
if [[ "$TYPE" == "plugins" && -e "$PROJECT/composer.lock" ]]; then
HAS_COMPOSER_PLUGIN=false
if composer -d "$PROJECT" info --locked automattic/jetpack-composer-plugin &>/dev/null; then
HAS_COMPOSER_PLUGIN=true
fi
while IFS=$'\t' read -r PKG VER; do
VENDOR=vendor
if $HAS_COMPOSER_PLUGIN; then
if [[ -z "${PKG_VENDOR_DIR_CACHE["$PKG=$VER"]}" ]]; then
if composer -d "$PROJECT" info --locked --format=json "$PKG" | jq -e '.type == "jetpack-library"' &>/dev/null; then
PKG_VENDOR_DIR_CACHE["$PKG=$VER"]=jetpack_vendor
else
PKG_VENDOR_DIR_CACHE["$PKG=$VER"]=vendor
fi
fi
VENDOR=${PKG_VENDOR_DIR_CACHE["$PKG=$VER"]}
fi
if [[ "$(git check-attr production-include -- "$PROJECT/$VENDOR/$PKG/file")" != *": production-include: set" ]]; then
EXIT=1
echo "---"
echo "::error file=$PROJECT/.gitattributes::Non-dev composer dependency $PKG is not being production-included. Either make it a dev dependency, or add a line like%0A/$VENDOR/$PKG/** production-include%0Ain \`.gitattributes\`."
echo "---"
fi
done < <( composer -d "$PROJECT" info --locked --no-dev --format=json | jq -r 'if type == "object" then .locked[] | [ .name, .version ] | @tsv else empty end' )
fi

# - `.extra.dependencies.test-only` must refer to dev dependencies.
if jq -e '.extra.dependencies["test-only"] // empty' "$PROJECT/composer.json" >/dev/null; then
while IFS=$'\t' read -r LINE DEP; do
Expand Down
33 changes: 33 additions & 0 deletions .github/files/select-wordpress-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

## Environment used by this script:
#
# Required:
# - WP_BRANCH: Version of WordPress to check out.
#
# Other:
# - GITHUB_ENV: File written to to set environment variables for later steps.

set -eo pipefail

case "$WP_BRANCH" in
trunk)
WORDPRESS_TAG=trunk
;;
latest)
WORDPRESS_TAG=$(php ./tools/get-wp-version.php)
;;
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
;;
*)
echo "Unrecognized value for WP_BRANCH: $WP_BRANCH" >&2
exit 1
;;
esac

if [[ -n "$GITHUB_ENV" ]]; then
echo "WORDPRESS_TAG=$WORDPRESS_TAG" >> "$GITHUB_ENV"
fi
35 changes: 16 additions & 19 deletions .github/files/setup-wordpress-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,11 @@ mysql -e "CREATE DATABASE wordpress_tests;"
echo "::endgroup::"

echo "::group::Preparing WordPress from \"$WP_BRANCH\" branch";
case "$WP_BRANCH" in
trunk)
TAG=trunk
;;
latest)
TAG=$(php ./tools/get-wp-version.php)
;;
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'
TAG=6.4
;;
*)
echo "Unrecognized value for WP_BRANCH: $WP_BRANCH" >&2
exit 1
;;
esac
git clone --depth=1 --branch "$TAG" git://develop.git.wordpress.org/ "/tmp/wordpress-$WP_BRANCH"
source .github/files/select-wordpress-tag.sh
git clone --depth=1 --branch "$WORDPRESS_TAG" git://develop.git.wordpress.org/ "/tmp/wordpress-$WP_BRANCH"
# We need a built version of WordPress to test against, so download that into the src directory instead of what's in wordpress-develop.
rm -rf "/tmp/wordpress-$WP_BRANCH/src"
git clone --depth=1 --branch "$TAG" git://core.git.wordpress.org/ "/tmp/wordpress-$WP_BRANCH/src"
git clone --depth=1 --branch "$WORDPRESS_TAG" git://core.git.wordpress.org/ "/tmp/wordpress-$WP_BRANCH/src"
echo "::endgroup::"

if [[ -n "$GITHUB_ENV" ]]; then
Expand Down Expand Up @@ -123,6 +107,19 @@ for PLUGIN in projects/plugins/*/composer.json; do
fi
cd "$BASE"

# Upgrade/downgrade WorDBless if necessary.
if [[ ( "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ) && "$TEST_SCRIPT" == "test-php" ]]; then
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
if [[ -n "$VER" ]]; then
INSVER=$WORDPRESS_TAG
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
rm -rf "$DIR/wordpress"
composer --working-dir="$DIR" require --dev roots/wordpress="$INSVER" roots/wordpress-no-content="$INSVER"
fi
fi

cp -r "$DIR" "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/$NAME"
# Plugin dir for tests in WP >= 5.6-beta1
ln -s "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/$NAME" "/tmp/wordpress-$WP_BRANCH/tests/phpunit/data/plugins/$NAME"
Expand Down
11 changes: 2 additions & 9 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
rangeStrategy: 'widen',
},

// Forbid `@wordpress/dependency-extraction-webpack-plugin` v6 until WP 6.5 support is dropped.
// https://github.com/WordPress/gutenberg/issues/62202
{
matchPackageNames: [ '@wordpress/dependency-extraction-webpack-plugin' ],
allowedVersions: '<6.0.0',
},

// Various other monorepos and package groupings.
{
extends: [ 'monorepo:wordpress' ],
Expand Down Expand Up @@ -104,8 +97,8 @@
'uuid',
'@testing-library/preact',
],
reviewers: [ 'team:jetpack-search' ],
addLabels: [ 'Search', 'Instant Search' ],
reviewers: [ 'team:red' ],
addLabels: [ '[Feature] Search', 'Instant Search' ],
},
],

Expand Down
36 changes: 22 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ jobs:
pnpm install
echo "::endgroup::"
# If we're going to be making WorDBless use WP "nightlies", remove the relevant package from Composer's cache to get the latest version.
if [[ "$WP_BRANCH" == 'trunk' && "$TEST_SCRIPT" == "test-php" ]]; then
echo "::group::Clear composer cache for roots/wordpress"
DIR=$(composer config cache-files-dir)
rm -rf "$DIR/roots/wordpress" "$DIR/roots/wordpress-no-content"
echo "::endgroup::"
fi
- name: Detect changed projects
id: changed
run: |
Expand All @@ -93,6 +101,10 @@ jobs:
echo "projects=${CHANGED}" >> "$GITHUB_OUTPUT"
echo "any-plugins=${ANY_PLUGINS}" >> "$GITHUB_OUTPUT"
- name: Select WordPress version
if: steps.changed.outputs.any-plugins != 'true' && matrix.wp != 'none'
run: .github/files/select-wordpress-tag.sh

- name: Setup WordPress environment for plugin tests
env:
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -105,12 +117,6 @@ jobs:
FORCE_PACKAGE_TESTS: ${{ matrix.force-package-tests && 'true' || 'false' }}
CHANGED: ${{ steps.changed.outputs.projects }}
run: |
# If we're going to be making WorDBless use WP "nightlies", remove the relevant package from Composer's cache to get the latest version.
if [[ "$WP_BRANCH" == 'trunk' && ( "$TEST_SCRIPT" == "test-php" ) ]]; then
DIR=$(composer config cache-files-dir)
rm -rf "$DIR/roots/wordpress"
fi
EXIT=0
mkdir artifacts
for P in composer.json projects/*/*/composer.json; do
Expand Down Expand Up @@ -165,15 +171,17 @@ jobs:
echo 'Platform reqs failed, running `composer update`'
composer --working-dir="$DIR" update
fi
fi
if [[ "$WP_BRANCH" == 'trunk' && "$TEST_SCRIPT" == "test-php" ]]; then
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
if [[ -n "$VER" ]]; then
echo 'Supposed to run tests against WordPress trunk, so upgrading roots/wordpress and roots/wordpress-no-content to dev-main'
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
rm -rf "$DIR/wordpress"
composer --working-dir="$DIR" require --dev roots/wordpress="dev-main as $VER" roots/wordpress-no-content="dev-main as $VER"
if [[ "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ]]; then
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
if [[ -n "$VER" ]]; then
INSVER=$WORDPRESS_TAG
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
rm -rf "$DIR/wordpress"
composer --working-dir="$DIR" require --dev roots/wordpress="$INSVER" roots/wordpress-no-content="$INSVER"
fi
fi
fi
Expand Down
2 changes: 2 additions & 0 deletions .phan/config.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function make_phan_config( $dir, $options = array() ) {
$extra_stubs = array();
$global_stubs = array();
$internal_stubs = array();

foreach ( array_merge( $options['stubs'], $options['+stubs'] ) as $stub ) {
switch ( $stub ) {
case 'akismet':
Expand Down Expand Up @@ -104,6 +105,7 @@ function make_phan_config( $dir, $options = array() ) {
$stubs[] = "$root/.phan/stubs/wpcom-stubs.php";
if ( $dir !== "$root/projects/plugins/wpcomsh" ) {
$extra_stubs[] = "$root/projects/plugins/wpcomsh/feature-plugins/nav-redesign.php";
$extra_stubs[] = "$root/projects/plugins/wpcomsh/feature-plugins/masterbar.php";
$extra_stubs[] = "$root/projects/plugins/wpcomsh/footer-credit/footer-credit/customizer.php";
$extra_stubs[] = "$root/projects/plugins/wpcomsh/footer-credit/theme-optimizations.php";
$extra_stubs[] = "$root/projects/plugins/wpcomsh/lib/require-lib.php";
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/akismet-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from Akismet 5.3.2
* Stubs automatically generated from Akismet 5.3.3
* using the definition file `tools/stubs/akismet-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/amp-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from AMP 2.5.3 and AMP for WP 1.0.95
* Stubs automatically generated from AMP 2.5.4 and AMP for WP 1.0.96.1
* using the definition file `tools/stubs/amp-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
Loading

0 comments on commit c4cb36a

Please sign in to comment.