Issue #3267721 by nod_, Wim Leers: Add DrupalCI step for ensuring that CKEditor 5 build files are build correctly

merge-requests/1974/head
Lauri Eskola 2022-03-15 20:15:22 +02:00
parent dcc51c80a2
commit da12af1477
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
3 changed files with 69 additions and 0 deletions

View File

@ -30,6 +30,7 @@
"vendor-update": "node ./scripts/js/vendor-update.js",
"watch:ckeditor5": "webpack --config ./modules/ckeditor5/webpack.config.js --watch",
"build:ckeditor5": "webpack --config ./modules/ckeditor5/webpack.config.js",
"check:ckeditor5": "node ./scripts/js/ckeditor5-check-plugins.js",
"build:ckeditor5-types": "node ./scripts/js/ckeditor5-types-documentation.js"
},
"devDependencies": {

View File

@ -128,6 +128,10 @@ ESLINT_CONFIG_PASSING_FILE_CHANGED=0
# - core/.stylelintrc.json
STYLELINT_CONFIG_FILE_CHANGED=0
# This variable will be set when a Drupal-specific CKEditor 5 plugin has changed
# it is used to make sure the compiled JS is valid.
CKEDITOR5_PLUGINS_CHANGED=0
# Build up a list of absolute file names.
ABS_FILES=
for FILE in $FILES; do
@ -156,6 +160,10 @@ for FILE in $FILES; do
ESLINT_CONFIG_PASSING_FILE_CHANGED=1;
STYLELINT_CONFIG_FILE_CHANGED=1;
fi;
if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.js$ ]] && [[ $FILE =~ ^core/modules/ckeditor5/js/build || $FILE =~ ^core/modules/ckeditor5/js/ckeditor5_plugins ]]; then
CKEDITOR5_PLUGINS_CHANGED=1;
fi;
done
# Exit early if there are no files.
@ -285,6 +293,27 @@ if [[ $STYLELINT_CONFIG_FILE_CHANGED == "1" ]]; then
printf "\n"
fi
# When a Drupal-specific CKEditor 5 plugin changed ensure that it is compiled
# properly. Only check on DrupalCI, since we're concerned about the build being
# run with the expected package versions and making sure the result of the build
# is in sync and conform to expectations.
if [[ "$DRUPALCI" == "1" ]] && [[ $CKEDITOR5_PLUGINS_CHANGED == "1" ]]; then
cd "$TOP_LEVEL/core"
yarn run -s check:ckeditor5
if [ "$?" -ne "0" ]; then
# If there are failures set the status to a number other than 0.
FINAL_STATUS=1
printf "\nDrupal-specific CKEditor 5 plugins: ${red}failed${reset}\n"
else
printf "\nDrupal-specific CKEditor 5 plugins: ${green}passed${reset}\n"
fi
cd $TOP_LEVEL
# Add a separator line to make the output easier to read.
printf "\n"
printf -- '-%.0s' {1..100}
printf "\n"
fi
for FILE in $FILES; do
STATUS=0;
# Print a line to separate spellcheck output from per file output.

View File

@ -0,0 +1,39 @@
/**
* @file
*
* Provides the `check:ckeditor5` command.
*
* Check that the plugins are built with the appropriate dependencies. This is
* only run on DrupalCI.
*
* @internal This file is part of the core JavaScript build process and is only
* meant to be used in that context.
*/
"use strict";
const glob = require("glob");
const log = require("./log");
const fs = require("fs").promises;
const child_process = require("child_process");
async function getContents(files) {
return Object.fromEntries(
await Promise.all(
files.map(async (file) => [file, (await fs.readFile(file)).toString()])
)
);
}
(async () => {
const files = glob.sync("./modules/ckeditor5/js/build/*.js");
const pluginsBefore = await getContents(files);
// Execute the plugin build script.
child_process.execSync("yarn run build:ckeditor5");
const pluginsAfter = await getContents(files);
if (JSON.stringify(pluginsBefore) !== JSON.stringify(pluginsAfter)) {
process.exitCode = 1;
}
})();