palantir / gradle-bowerdeps-plugin

A Gradle plugin for controlling build order with bower.json files.
Apache License 2.0
3 stars 4 forks source link

Use globally installed node for integration tests #2

Open nmalaguti opened 9 years ago

nmalaguti commented 9 years ago

This should resolve #1.

Integration tests should use the globally installed version of node since the node plugin doesn't support installing correctly on all platforms.

Travis CI will use whatever version of nodejs is on the build nodes.

Review on Reviewable

saper commented 9 years ago

This pushed my one step further: now the exception says I need to gradle installGrunt. No way to add that as dependency of the integration test?

nmalaguti commented 9 years ago

Hmm, the integration tests should automatically run installGrunt as part of their run and create node_modules folders in each of the test projects.

def result = runTasksSuccessfully('installGrunt', 'installGulp', ':example-app:build')

Can you look at build/test/com.palantir.bowerdeps.BowerDepsPluginIntegSpec/grunt-dependencies-added/ and let me know if there is a node_modules folder with grunt and grunt-cli installed?

saper commented 9 years ago

installGrunt does not appear on the list of the valid top-level tasks.

Here's what I have in grunt-dependencies-added after running gradle clean and then gradle integrationTest:

https://gist.github.com/f977c3e1a6465d1ec677

nmalaguti commented 9 years ago

That's very odd. Are the gradle-node-plugin and gradle-grunt-plugin on the classpath in build/test/com.palantir.bowerdeps.BowerDepsPluginIntegSpec/grunt-dependencies-added/.gradle-test-kit/init.gradle?

This is currently working on Travis CI and locally for me. I'll look into setting up FreeBSD to repro this.

saper commented 9 years ago

Yes, both are there on the classpath. Somehow I feel it is not a FreeBSD-specific issue, it's more like a "polluted environment" issue.

Few observations:

I have re-installed gulp in that node_modules directory and it ended up fine.

Here's the integTest-results/TEST-com.palantir.bowerdeps.BowerDepsPluginMultiProjectIntegSpec.xml:

https://gist.github.com/7906a853a8f30f2b9230

So it seems to be there is some problem with locating correct node_modules (similar to https://github.com/srs/gradle-node-plugin/issues/53) and others.

saper commented 9 years ago

Well - that was it - installing in some directory which has no node_modules below and with no grunt or gulp on the node global path (npm install -g) the test finally worked!

nmalaguti commented 9 years ago

So this PR worked for you? If so, I'll merge it in and update the README so developers know they need to have node installed locally in order to run the tests.

saper commented 9 years ago

Well. not quite. To make it work I had to nuke all node_modules directories on the filesystem up to the plugin path, because then npm install it there and the gradle-node plugin system tears apart.

I think it shouldn't work this way... Maybe just some path to check after the install is hardcoded?

nmalaguti commented 9 years ago

I think that's an issue with the node/grunt/gulp plugins. I can look into having them search the parent directory tree for a node_modules folder, but I wouldn't want to handle that case in this plugin.

saper commented 9 years ago

I think those plugins are not mature yet; I also do not need those (or even yours:) plugins, so I'd rather drop here at the moment. This patch is a great improvement; I think the upstream plugins should actually do the same. Somehow this "download binary/install/execute immediately" philosophy (a.k.a curl ... | sudo bash - is going to backfire someday due to security.

Thanks for your involvement, at least I could refer to the problem on the gradle forum.