From 16dd013172f4ee3dcc250eee5bed4d81d22483c8 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:39:44 +0530 Subject: [PATCH 01/12] Update plugins.json --- plugins.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins.json b/plugins.json index ab4f2323c2..b171fa5cda 100644 --- a/plugins.json +++ b/plugins.json @@ -1,10 +1,13 @@ { - "images/dominant-color-images": { - "slug": "dominant-color-images", - "version": "1.0.1" + "modules": { + "images/dominant-color-images": { + "slug": "dominant-color-images", + "version": "1.0.1" + }, + "images/webp-uploads": { + "slug": "webp-uploads", + "version": "1.0.5" + } }, - "images/webp-uploads": { - "slug": "webp-uploads", - "version": "1.0.5" - } + "plugins": ["dominant-color-images", "webp-uploads"] } From 147b4b8aab8354945ec5b28e7d04e98c53f53a3d Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:41:48 +0530 Subject: [PATCH 02/12] Update build-plugins.js --- bin/plugin/commands/build-plugins.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/plugin/commands/build-plugins.js b/bin/plugin/commands/build-plugins.js index 0564547c6d..3faaad7ce8 100644 --- a/bin/plugin/commands/build-plugins.js +++ b/bin/plugin/commands/build-plugins.js @@ -24,7 +24,16 @@ exports.handler = async () => { } try { - const plugins = JSON.parse( jsonString ); + const pluginsConfig = JSON.parse( jsonString ); + const plugins = pluginsConfig.modules; + if ( ! plugins ) { + log( + formats.error( + 'The given module configuration is invalid, the modules is missing, or they are misspelled.' + ) + ); + return; + } for ( const moduleDir in plugins ) { const pluginVersion = plugins[ moduleDir ]?.version; const pluginSlug = plugins[ moduleDir ]?.slug; From 7dfcd91ab52aea364b240db66fa74e6643647469 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:43:08 +0530 Subject: [PATCH 03/12] Update build-plugins.js --- bin/plugin/commands/build-plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/plugin/commands/build-plugins.js b/bin/plugin/commands/build-plugins.js index 3faaad7ce8..7ad689c409 100644 --- a/bin/plugin/commands/build-plugins.js +++ b/bin/plugin/commands/build-plugins.js @@ -25,7 +25,7 @@ exports.handler = async () => { try { const pluginsConfig = JSON.parse( jsonString ); - const plugins = pluginsConfig.modules; + const plugins = pluginsConfig.modules; if ( ! plugins ) { log( formats.error( From 5f4ac69fe8d8f6461b78f761e324829f2ac80ca6 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:44:25 +0530 Subject: [PATCH 04/12] Update test-plugins.js --- bin/plugin/commands/test-plugins.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 08a7b85a6b..8cc9e3318a 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -413,12 +413,14 @@ function doRunStandalonePluginTests( settings ) { ); } - const pluginsJsonFileContentAsJson = JSON.parse( pluginsJsonFileContent ); + const pluginsJsonFileContentAsEntireJsonData = JSON.parse( + pluginsJsonFileContent + ); // Check for valid and not empty object resulting from plugins JSON file parse. if ( - 'object' !== typeof pluginsJsonFileContentAsJson || - 0 === Object.keys( pluginsJsonFileContentAsJson ).length + 'object' !== typeof pluginsJsonFileContentAsEntireJsonData || + 0 === Object.keys( pluginsJsonFileContentAsEntireJsonData ).length ) { log( formats.error( @@ -430,6 +432,19 @@ function doRunStandalonePluginTests( settings ) { process.exit( 1 ); } + const pluginsJsonFileContentAsJson = + pluginsJsonFileContentAsEntireJsonData.modules; + if ( ! pluginsJsonFileContentAsJson ) { + log( + formats.error( + 'The given module configuration is invalid, the modules is missing, or they are misspelled.' + ) + ); + + // Return with exit code 1 to trigger a failure in the test pipeline. + process.exit( 1 ); + } + // Create an array of plugins from entries in plugins JSON file. builtPlugins = Object.keys( pluginsJsonFileContentAsJson ) .filter( ( item ) => { From a201a4c9734d8f0646e584df33f1ccef883cedd0 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:46:40 +0530 Subject: [PATCH 05/12] Update get-plugin-version.js --- bin/plugin/commands/get-plugin-version.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/plugin/commands/get-plugin-version.js b/bin/plugin/commands/get-plugin-version.js index ad04defe48..f898dd0adc 100644 --- a/bin/plugin/commands/get-plugin-version.js +++ b/bin/plugin/commands/get-plugin-version.js @@ -56,15 +56,25 @@ function doRunGetPluginVersion( settings ) { ); } - const plugins = JSON.parse( pluginsFileContent ); + const pluginsConfig = JSON.parse( pluginsFileContent ); // Check for valid and not empty object resulting from plugins JSON file parse. - if ( 'object' !== typeof plugins || 0 === Object.keys( plugins ).length ) { + if ( + 'object' !== typeof pluginsConfig || + 0 === Object.keys( pluginsConfig ).length + ) { throw Error( `File at "${ pluginsFile }" parsed, but detected empty/non valid JSON object.` ); } + const plugins = pluginsConfig.modules; + if ( ! plugins ) { + throw Error( + `File at "${ pluginsFile }" parsed, but the modules is missing, or they are misspelled.` + ); + } + for ( const moduleDir in plugins ) { const pluginVersion = plugins[ moduleDir ]?.version; const pluginSlug = plugins[ moduleDir ]?.slug; From d2c6088fcf0112bb40d83ce7ffbb68a8e23d2275 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:48:42 +0530 Subject: [PATCH 06/12] Update load.php --- load.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/load.php b/load.php index 5d1d9970d9..19afebabdb 100644 --- a/load.php +++ b/load.php @@ -426,7 +426,7 @@ function perflab_maybe_remove_object_cache_dropin() { $dropin_path = WP_CONTENT_DIR . '/object-cache.php'; $dropin_backup_path = WP_CONTENT_DIR . '/object-cache-plst-orig.php'; - /** + /* * If there is an object-cache-plst-orig.php file, restore it and * override the Performance Lab file. This is only relevant for * backward-compatibility with previous Performance Lab versions From 7d16b4909e7d345a354427427238ee0cf0d9ec00 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 10:57:38 +0530 Subject: [PATCH 07/12] Update deploy-standalone-plugins.yml --- .github/workflows/deploy-standalone-plugins.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index 0515b03bef..baac01c7d1 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -1,6 +1,18 @@ name: Deploy standalone plugins to WordPress.org on: + # TODO The pull_request will be removed once the workflow is tested. + pull_request: + branches: + - trunk + - 'release/**' + - 'feature/**' + paths: + - '.github/workflows/deploy-standalone-plugins.yml' + types: + - opened + - reopened + - synchronize release: types: [published] workflow_dispatch: From bbbdb5777b2265f5e024c3c15eeb620a62739252 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 11:46:30 +0530 Subject: [PATCH 08/12] Update deploy-standalone-plugins.yml --- .github/workflows/deploy-standalone-plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index baac01c7d1..9aae7235e4 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -62,7 +62,7 @@ jobs: # for use in the matrix. # The "dry-run" parameter is included here to set the deployment mode. # When running the manual (workflow_dispatch) workflow, this value will be set from manual input type. - echo "matrix="$(jq -c '{include:[keys[] as $k | {name:$k,slug:.[$k].slug,version:.[$k].version,"dry-run":false }]}' plugins.json) >> $GITHUB_OUTPUT + echo 'matrix={"include":'$(jq -c '[.modules | to_entries[] | {name: .key, slug: .value.slug, version: .value.version, "dry-run": false }]' plugins.json)'}' >> $GITHUB_OUTPUT fi deploy: name: Deploy Plugin From 9986e9f5bb594a766270c7e3d909b795e56db4a9 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 11:56:59 +0530 Subject: [PATCH 09/12] Update deploy-standalone-plugins.yml --- .github/workflows/deploy-standalone-plugins.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index 9aae7235e4..821b8c3a95 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -87,8 +87,12 @@ jobs: with: dry-run: ${{ matrix.dry-run }} env: - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + # TODO Once the workflow is tested, we will remove the comment and use the secret SVN access. + #SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + #SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + # TODO Once the workflow is tested, we will remove this test credential. + SVN_PASSWORD: SVN_PASSWORD + SVN_USERNAME: SVN_USERNAME SLUG: ${{ matrix.slug }} VERSION: ${{ matrix.version }} BUILD_DIR: ./build/${{ matrix.slug }} From df2a4dd4329384ee7832c3e5a95ded2e3d738105 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 12:06:29 +0530 Subject: [PATCH 10/12] Update deploy-standalone-plugins.yml --- .github/workflows/deploy-standalone-plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index 821b8c3a95..508bcab7c8 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -62,7 +62,7 @@ jobs: # for use in the matrix. # The "dry-run" parameter is included here to set the deployment mode. # When running the manual (workflow_dispatch) workflow, this value will be set from manual input type. - echo 'matrix={"include":'$(jq -c '[.modules | to_entries[] | {name: .key, slug: .value.slug, version: .value.version, "dry-run": false }]' plugins.json)'}' >> $GITHUB_OUTPUT + echo "matrix="$(jq -c '{include:[.modules | to_entries[] | {name:.key,slug:.value.slug,version:.value.version,"dry-run":false }]}' plugins.json) >> $GITHUB_OUTPUT fi deploy: name: Deploy Plugin From 259d7cdd5226bc6edd41f1fb2c0b6a0900f2b371 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 18 Jan 2024 12:11:55 +0530 Subject: [PATCH 11/12] Update deploy-standalone-plugins.yml --- .github/workflows/deploy-standalone-plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index 508bcab7c8..e9fb36e098 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -62,7 +62,7 @@ jobs: # for use in the matrix. # The "dry-run" parameter is included here to set the deployment mode. # When running the manual (workflow_dispatch) workflow, this value will be set from manual input type. - echo "matrix="$(jq -c '{include:[.modules | to_entries[] | {name:.key,slug:.value.slug,version:.value.version,"dry-run":false }]}' plugins.json) >> $GITHUB_OUTPUT + echo "matrix="$(jq -c '{include:[.modules | to_entries[] | {name:.key,slug:.value.slug,version:.value.version,"dry-run":true }]}' plugins.json) >> $GITHUB_OUTPUT fi deploy: name: Deploy Plugin From 2b15729d5d03ddebd4c1383bd4f27fa0e15508e4 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 19 Jan 2024 08:50:55 +0530 Subject: [PATCH 12/12] Update test-plugins.js --- bin/plugin/commands/test-plugins.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 8cc9e3318a..9cf4578070 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -413,14 +413,12 @@ function doRunStandalonePluginTests( settings ) { ); } - const pluginsJsonFileContentAsEntireJsonData = JSON.parse( - pluginsJsonFileContent - ); + const pluginsConfig = JSON.parse( pluginsJsonFileContent ); // Check for valid and not empty object resulting from plugins JSON file parse. if ( - 'object' !== typeof pluginsJsonFileContentAsEntireJsonData || - 0 === Object.keys( pluginsJsonFileContentAsEntireJsonData ).length + 'object' !== typeof pluginsConfig || + 0 === Object.keys( pluginsConfig ).length ) { log( formats.error( @@ -432,12 +430,11 @@ function doRunStandalonePluginTests( settings ) { process.exit( 1 ); } - const pluginsJsonFileContentAsJson = - pluginsJsonFileContentAsEntireJsonData.modules; - if ( ! pluginsJsonFileContentAsJson ) { + const plugins = pluginsConfig.modules; + if ( ! plugins ) { log( formats.error( - 'The given module configuration is invalid, the modules is missing, or they are misspelled.' + 'The given module configuration is invalid, the modules are missing, or they are misspelled.' ) ); @@ -446,23 +443,23 @@ function doRunStandalonePluginTests( settings ) { } // Create an array of plugins from entries in plugins JSON file. - builtPlugins = Object.keys( pluginsJsonFileContentAsJson ) + builtPlugins = Object.keys( plugins ) .filter( ( item ) => { if ( ! fs.pathExistsSync( - `${ settings.builtPluginsDir }${ pluginsJsonFileContentAsJson[ item ].slug }` + `${ settings.builtPluginsDir }${ plugins[ item ].slug }` ) ) { log( formats.error( - `Built plugin path "${ settings.builtPluginsDir }${ pluginsJsonFileContentAsJson[ item ].slug }" not found, skipping and removing from plugin list` + `Built plugin path "${ settings.builtPluginsDir }${ plugins[ item ].slug }" not found, skipping and removing from plugin list` ) ); return false; } return true; } ) - .map( ( item ) => pluginsJsonFileContentAsJson[ item ].slug ); + .map( ( item ) => plugins[ item ].slug ); // For each built plugin, copy the test assets. builtPlugins.forEach( ( plugin ) => {