Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBDS-3849 use promises to fetch requirements #158

Closed

Conversation

nickboldt
Copy link
Contributor

@nickboldt nickboldt commented Apr 25, 2016

JBDS-3849 use promise to fetch requirements into cache folder and copy from cache to dist

}
}
promise.all(promises);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nick it should be something like this snipped below and coounter would not be neded anymore

promise.all(promises).then((result)=> {
  cb();
}).catch((error)=>{
  cb(error);
});

@nickboldt nickboldt force-pushed the JBDS-3849_2 branch 2 times, most recently from 37d0e38 to 6663d27 Compare April 25, 2016 23:13
@nickboldt nickboldt changed the title JBDS-3849 use promise to fetch requirements... JBDS-3849 use promises to fetch requirements Apr 25, 2016
@nickboldt
Copy link
Contributor Author

SHA fix for requirements moved to #159 at Denis' request.

@nickboldt
Copy link
Contributor Author

nickboldt commented Apr 26, 2016

So, this PR works if you run gulp prefetch && gulp dist

But if you start from a clean checkout (no prefetch folder) or do gulp clean-all && gulp dist the sequence looks like this:

http://pastebin.com/7jg3merG

So... the promises are not blocking. :(

gulp.task('prefetch', function(cb) {
let counter=0;
let promises = [];
if (!fs.existsSync(prefetchFolder)) { mkdirp(prefetchFolder, cb); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason why, you call back here and the in promise.all().then().catch();

@nickboldt
Copy link
Contributor Author

nickboldt commented Apr 26, 2016

With this last suggestion, build works.

Here's a console log (expires in 1 week):

http://pastebin.com/WpAjCp2U

HOWEVER the generated .exe is missing the JBDS jar (because the 7zip archive embeds a 0-length file)... details here:

https://issues.jboss.org/browse/JBDS-3849?focusedCommentId=13196798&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13196798

@dgolovin
Copy link
Contributor

Fix changes a lot and not easy to follow, instead is should be simple promise wrap around download we already have. Here is an example https://github.com/redhat-developer-tooling/developer-platform-install/compare/master...dgolovin:JBDS-3849?expand=1.
I didn't test it really and it could look much better after refactoring, but I think that is Pavol's idea in rough implementation. It just get rid of ugly counter and introduce Promise.all() call.

@@ -17,6 +17,7 @@ var gulp = require('gulp'),
minimatch = require('minimatch'),
copy = require('gulp-copy'),
concat = require('gulp-concat'),
promise = require('promise'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promises are natively supported by Node.js 4 and 5 so you don't need this dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. I get "ReferenceError: promise is not defined" if I don't declare it in gulpfile.js.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to use Promise (with upper-case "P")

@ppitonak
Copy link
Member

ppitonak commented Apr 26, 2016

I added comments directly to Nick's code. I still need to test it

  • npm prune && rm -rf dist && rm -rf prefetch-dependencies && npm install
  • npm start
  • npm test
  • npm run ui-test FAILED
  • npm run package-simple
  • (( $(stat -c %s dist/win/*installer.exe) > 36000000 )) || echo 'file too small'
  • (( $(stat -c %s dist/win/*installer.exe) < 40000000 )) || echo 'file too big'
  • npm run package-bundle FAILED
  • (( $(stat -c %s dist/win/*installer.exe) > 1500000000 )) || echo 'file too small'
  • (( $(stat -c %s dist/win/*installer.exe) < 1600000000 )) || echo 'file too big'
  • echo "aaa" > prefetch-dependencies/cdk.zip && npm run package-bundle
  • echo "aaa" > prefetch-dependencies/cdk.zip && npm run dist
  • npm run package-simple


// Create bundled installer
gulp.task('package-bundle', function(cb) {
runSequence(['check-requirements', 'clean'], 'create-dist-win-dir', ['generate',
runSequence(['check-requirements', 'clean'], 'create-dist-win-dir', ['generate',
'prepare-tools'], 'prefetch', 'package', 'cleanup', cb);
Copy link
Member

@ppitonak ppitonak Apr 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to run prefetch in parallel with generate and prepare-tools, it will speed up the build a little bit but only if we split downloading and copying deps into separate tasks, i.e. downloading can run in parallel with generate and prepare-tools, copying has to run after generate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is doable and should work good, because download is going to be done often for jbds bits only, probably

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it as is for now and improve performance in another PR

@nickboldt nickboldt force-pushed the JBDS-3849_2 branch 3 times, most recently from e4beb04 to 24a98e5 Compare April 26, 2016 20:10
…y from cache to dist

simpler approach from Denis; use requirements folder instead of prefetch-dependencies; also re-enable creation of sha256 file in requirements folder as we'll need it later

add requirements/ folder to gitignore

better but now prefetch task ENDS THE PROCESS instead of returning and running the package task
Promise.all(promises).then((result) => {
installerExe = resolveInstallerExePath('-bundle');
cb();
}).catch((error)=>{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be just

}).catch(cb);

@dgolovin
Copy link
Contributor

#161 reworked version of this PR

@dgolovin
Copy link
Contributor

See #161 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants