From 0bd62b835cc95b8d0fcfa0fcb2fe6b3aa874fc3c Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Fri, 24 Jun 2022 20:38:00 +0100 Subject: [PATCH] fix(build): Skip npm prepare when running in CI Have npm prepare do nothing when running in CI. We don't need to do any building, because npm test will build everything needed in the workflows in which it is run, and we don't want to build anything in other workflows because a tsc error would prevent those workflows from completing. --- gulpfile.js | 3 ++- package.json | 2 +- scripts/gulpfiles/build_tasks.js | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b31d12c4d81..1b6f0126962 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,7 +31,7 @@ module.exports = { buildCompiled: buildTasks.compiled, buildAdvancedCompilationTest: buildTasks.advancedCompilationTest, buildJavaScript: buildTasks.javaScript, - buildJavaScriptAndDeps: gulp.series(buildTasks.javaScript, buildTasks.deps), + buildJavaScriptAndDeps: buildTasks.javaScriptAndDeps, // TODO(5621): Re-enable once typings generation is fixed. // checkin: gulp.parallel(buildTasks.checkinBuilt, typings.checkinTypings), checkin: gulp.parallel(buildTasks.checkinBuilt), @@ -48,6 +48,7 @@ module.exports = { // typings: gulp.series(typings.typings, typings.msgTypings), // checkinTypings: typings.checkinTypings, package: packageTasks.package, + prepare: buildTasks.prepare, checkLicenses: licenseTasks.checkLicenses, recompile: releaseTasks.recompile, prepareDemos: appengineTasks.prepareDemos, diff --git a/package.json b/package.json index 0f5a26e262f..8c214b0297b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "license": "gulp checkLicenses", "lint": "eslint .", "package": "gulp package", - "prepare": "gulp buildJavaScriptAndDeps", + "prepare": "gulp prepare", "prepareDemos": "gulp prepareDemos", "publish": "gulp publish", "publish:beta": "gulp publishBeta", diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 3e709f940cf..f394a121c9e 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -272,6 +272,26 @@ var JSCOMP_OFF = [ 'visibility', ]; +/** + * The npm prepare script, run by npm install after installing modules + * and as part of the packaging process. + * + * This does just enough of the build that npm start should work. + * + * Exception: when running in the CI environment, we don't build + * anything. We don't need to, because npm test will build everything + * needed, and we don't want to, because a tsc error would prevent + * other workflows (like lint and format) from completing. + */ +function prepare() { + if (process.env.CI) { + return gulp.src('.'); // Do nothing. + } + return buildJavaScriptAndDeps(); +} + +const buildJavaScriptAndDeps = gulp.series(buildJavaScript, buildDeps); + /** * Builds Blockly as a JS program, by running tsc on all the files in * the core directory. This must be run before buildDeps or @@ -697,7 +717,9 @@ function format() { }; module.exports = { + prepare: prepare, build: build, + javaScriptAndDeps: buildJavaScriptAndDeps, javaScript: buildJavaScript, deps: buildDeps, generateLangfiles: generateLangfiles,