Skip to content

Commit

Permalink
Parallelize Grunt build using grunt-parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Nov 4, 2023
1 parent 91d66be commit 1c407e0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 16 deletions.
65 changes: 49 additions & 16 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,47 @@ module.exports = function (grunt) {
},
},
},

parallel: {
'write-out-wpt-cts-html-all': {
options: { grunt: true },
tasks: [
'run:write-out-wpt-cts-html',
'run:write-out-wpt-cts-html-chunked2sec',
],
},
'all-builds': {
options: { grunt: true },
tasks: [
'build-standalone',
'build-wpt',
'run:build-out-node',
],
},
'all-checks': {
options: { grunt: true },
tasks: [
'ts:check',
'run:validate',
'run:validate-cache',
'run:unittest',
'run:lint',
'run:tsdoc-treatWarningsAsErrors',
],
},
'all-builds-and-checks': {
options: { grunt: true },
tasks: [
'build-all', // Internally parallel
'parallel:all-checks',
],
},
},
});

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-ts');

Expand All @@ -202,27 +239,28 @@ module.exports = function (grunt) {
grunt.registerTask('build-wpt', 'Build out-wpt/ (no checks; run after generate-common)', [
'run:build-out-wpt',
'run:copy-assets-wpt',
'run:autoformat-out-wpt',
'copy:gen-to-out-wpt',
'copy:htmlfiles-to-out-wpt',
'run:write-out-wpt-cts-html',
'run:write-out-wpt-cts-html-chunked2sec',
'parallel:write-out-wpt-cts-html-all',
'run:autoformat-out-wpt',
]);
grunt.registerTask('build-all', 'Build out*/ (no checks; run after generate-common)', [
'parallel:all-builds',
'build-done-message',
]);
grunt.registerTask('build-done-message', () => {
process.stderr.write('\nBuild completed! Running checks/tests');
grunt.log.writeln(`\
=====================================================
==== Build completed! Continuing checks/tests... ====
=====================================================`);
});

grunt.registerTask('pre', ['all']);

registerTaskAndAddToHelp('all', 'Run all builds and checks', [
'clean',
'generate-common',
// None of the steps below have interdependencies.
'build-standalone',
'build-wpt',
'run:build-out-node',
'build-done-message',
'checks',
'parallel:all-builds-and-checks',
]);
registerTaskAndAddToHelp('standalone', 'Build standalone (out/) (no checks)', [
'generate-common',
Expand All @@ -235,12 +273,7 @@ module.exports = function (grunt) {
'build-done-message',
]);
registerTaskAndAddToHelp('checks', 'Run all checks (and build tsdoc)', [
'ts:check',
'run:validate',
'run:validate-cache',
'run:unittest',
'run:lint',
'run:tsdoc-treatWarningsAsErrors',
'parallel:all-checks',
]);
registerTaskAndAddToHelp('unittest', 'Just run unittests', [
'run:unittest',
Expand Down
58 changes: 58 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-parallel": "^0.5.1",
"grunt-run": "^0.8.1",
"grunt-timer": "^0.6.0",
"grunt-ts": "^6.0.0-beta.22",
Expand Down

0 comments on commit 1c407e0

Please sign in to comment.