Monorepo: disable autoloading optimization by default (take 2) (#48980)

This PR is the second attempt to speed up monorepo installation by removing autoloading optimization setting from the configuration and performing the optimization where it is appropriate (composer post-install hooks and when building releases).

In the installation context, the composer post-install hook will execute a background task to dump the optimized autoloading, while the installation process completes other tasks.
This commit is contained in:
Vladimir Reznichenko 2024-07-04 10:12:52 +02:00 committed by GitHub
parent ab646ace8e
commit 7959060850
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 7 deletions

View File

@ -56,12 +56,12 @@ jobs:
bash bin/build-zip.sh bash bin/build-zip.sh
mkdir "$GITHUB_WORKSPACE/zips" mkdir "$GITHUB_WORKSPACE/zips"
cp "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip"
cd "$GITHUB_WORKSPACE/zips" cd "$GITHUB_WORKSPACE/zips"
unzip -qq woocommerce.zip unzip -qq woocommerce.zip
rm woocommerce.zip rm woocommerce.zip
mv woocommerce woocommerce-dev mv woocommerce woocommerce-dev
zip -q -r "woocommerce-dev.zip" "woocommerce-dev/" zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/"
rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev" rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev"
# Plugin data is passed as a JSON object. # Plugin data is passed as a JSON object.

View File

@ -66,13 +66,13 @@ jobs:
mkdir "$GITHUB_WORKSPACE/zips" mkdir "$GITHUB_WORKSPACE/zips"
mkdir -p "$GITHUB_WORKSPACE/unzips/woocommerce" mkdir -p "$GITHUB_WORKSPACE/unzips/woocommerce"
cp "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip"
cd "$GITHUB_WORKSPACE/zips" cd "$GITHUB_WORKSPACE/zips"
unzip -qq woocommerce.zip unzip -qq woocommerce.zip
cp -r woocommerce "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce" cp -r woocommerce "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce"
rm woocommerce.zip rm woocommerce.zip
mv woocommerce woocommerce-dev mv woocommerce woocommerce-dev
zip -q -r "woocommerce-dev.zip" "woocommerce-dev/" zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/"
rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev" rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev"
# Plugin data is passed as a JSON object. # Plugin data is passed as a JSON object.
PLUGIN_DATA="{}" PLUGIN_DATA="{}"

View File

@ -20,9 +20,11 @@ if [ ! -d "packages/" ]; then
output 1 "run \"composer install\" before proceed." output 1 "run \"composer install\" before proceed."
fi fi
# Autoloader # Autoloader optimization is forced to prevent OOM fatal errors in JetPack Autoloader.
# We running the optimization in background to speedup build process, with dev-environments in mind.
# Building zips enforcing the optimization during the install process, so we are good around building releases as well.
output 3 "Updating autoloader classmaps..." output 3 "Updating autoloader classmaps..."
composer dump-autoload composer dump-autoload --optimize --quiet &
output 2 "Done" output 2 "Done"
if [ -z "$SKIP_UPDATE_TEXTDOMAINS" ]; then if [ -z "$SKIP_UPDATE_TEXTDOMAINS" ]; then

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Build: speedup dependencies installation by disabling composer optimize autoloading by default.

View File

@ -40,7 +40,6 @@
"yoast/phpunit-polyfills": "^2.0" "yoast/phpunit-polyfills": "^2.0"
}, },
"config": { "config": {
"optimize-autoloader": true,
"preferred-install": { "preferred-install": {
"woocommerce/action-scheduler": "dist" "woocommerce/action-scheduler": "dist"
}, },

View File

@ -107,6 +107,7 @@
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -129,6 +130,7 @@
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -154,6 +156,7 @@
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -179,6 +182,7 @@
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -205,6 +209,7 @@
"optional": true, "optional": true,
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -238,6 +243,7 @@
], ],
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -384,6 +390,7 @@
], ],
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -466,6 +473,7 @@
"optional": false, "optional": false,
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -494,6 +502,7 @@
"optional": false, "optional": false,
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -524,6 +533,7 @@
"optional": true, "optional": true,
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",
@ -545,6 +555,7 @@
"optional": true, "optional": true,
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
"composer.json",
"composer.lock", "composer.lock",
"includes/**/*.php", "includes/**/*.php",
"patterns/**/*.php", "patterns/**/*.php",