diff --git a/gulpfile.js b/gulpfile.js index a51ccd33c..026d0dc1d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,6 +20,22 @@ const tasks = { await utils.execCommandVerbose('git', ['push']); }, }, + build: { + fn: async () => { + // Building everything in parallel seems to be unreliable on CI as + // certain scripts randomly fail with missing files or folder, or + // cannot delete certain directories (eg. copyPluginAssets or + // copyApplicationAssets). Because of this, on CI, we run the build + // sequencially. Locally we run it in parallel, which is much + // faster, especially when having to rebuild after adding a + // dependency. + if (process.env.IS_CONTINUOUS_INTEGRATION === '1') { + await utils.execCommandVerbose('yarn', ['run', 'buildSequential']); + } else { + await utils.execCommandVerbose('yarn', ['run', 'buildParallel']); + } + }, + }, }; utils.registerGulpTasks(gulp, tasks); diff --git a/package.json b/package.json index 9bb0b9d8a..c7da4cca2 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "node": ">=16" }, "scripts": { - "build": "yarn workspaces foreach --verbose --interlaced --parallel run build && yarn run tsc", + "buildParallel": "yarn workspaces foreach --verbose --interlaced --parallel --jobs 2 run build && yarn run tsc", + "buildSequential": "yarn workspaces foreach --verbose --interlaced run build && yarn run tsc", "buildApiDoc": "yarn workspace joplin start apidoc ../../readme/api/references/rest_api.md", "buildCommandIndex": "gulp buildCommandIndex", "buildPluginDoc": "typedoc --name 'Joplin Plugin API Documentation' --mode file -theme './Assets/PluginDocTheme/' --readme './Assets/PluginDocTheme/index.md' --excludeNotExported --excludeExternals --excludePrivate --excludeProtected --out ../joplin-website/docs/api/references/plugin_api packages/lib/services/plugins/api/", @@ -28,9 +29,9 @@ "linter-ci": "eslint --resolve-plugins-relative-to . --quiet --ext .js --ext .jsx --ext .ts --ext .tsx", "linter-precommit": "eslint --resolve-plugins-relative-to . --fix --ext .js --ext .jsx --ext .ts --ext .tsx", "linter": "eslint --resolve-plugins-relative-to . --fix --quiet --ext .js --ext .jsx --ext .ts --ext .tsx", - "postinstall": "yarn run build", - "publishAll": "git pull && yarn run build && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll", - "releaseAndroid": "yarn run build && export PATH=\"/usr/local/opt/openjdk@11/bin:$PATH\" && node packages/tools/release-android.js", + "postinstall": "gulp build", + "publishAll": "git pull && yarn run buildParallel && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll", + "releaseAndroid": "yarn run buildParallel && export PATH=\"/usr/local/opt/openjdk@11/bin:$PATH\" && node packages/tools/release-android.js", "releaseAndroidClean": "node packages/tools/release-android.js", "releaseCli": "node packages/tools/release-cli.js", "releaseClipper": "node packages/tools/release-clipper.js", diff --git a/packages/tools/gulp/utils.js b/packages/tools/gulp/utils.js index a394d324b..d8beeced1 100644 --- a/packages/tools/gulp/utils.js +++ b/packages/tools/gulp/utils.js @@ -19,6 +19,7 @@ utils.execCommandVerbose = function(commandName, args = []) { console.info(`> ${commandName}`, args && args.length ? args : ''); const promise = execa(commandName, args); promise.stdout.pipe(process.stdout); + promise.stderr.pipe(process.stderr); return promise; };