Skip to content

Commit

Permalink
fix(build): Skip npm prepare when running in CI (google#6244)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cpcallen authored and BeksOmega committed Aug 2, 2022
1 parent 2af7ae0 commit 14a20b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 22 additions & 0 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,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
Expand Down Expand Up @@ -728,7 +748,9 @@ function format() {
}

module.exports = {
prepare: prepare,
build: build,
javaScriptAndDeps: buildJavaScriptAndDeps,
javaScript: buildJavaScript,
deps: buildDeps,
generateLangfiles: generateLangfiles,
Expand Down

0 comments on commit 14a20b7

Please sign in to comment.