New plugin: gulp #563

Merged
merged 17 commits into from Jun 15, 2016

Conversation

Projects
None yet
4 participants
Collaborator

sergiusens commented Jun 10, 2016

LP: #1575880

Signed-off-by: Sergio Schvezov sergio.schvezov@ubuntu.com

snapcraft/plugins/gulp.py
+
+ - gulp-tasks:
+ (list)
+ A list of dependencies to fetch using npm.
@earnubs

earnubs Jun 10, 2016

Contributor

"A list of tasks to run" ?

@sergiusens

sergiusens Jun 10, 2016

Collaborator

Yup

+ },
+ 'default': [],
+ }
+ schema['properties']['node-engine'] = node_properties['node-engine']
@earnubs

earnubs Jun 10, 2016

Contributor

I wouldn't expect this to be here, I'd expect it only in the nodejs plugin where the deps are also loaded from package.json, no?

+ env['PATH'] = '{}:{}'.format(
+ os.path.join(self._npm_dir, 'bin'), env['PATH'])
+ self.run(['npm', 'install', '-g', 'gulp-cli'], env=env)
+ if os.path.exists(os.path.join(self.builddir, 'package.json')):
@earnubs

earnubs Jun 10, 2016

Contributor

Aaah, so this is entirely standalone, and there's no need for the nodejs plugin when you use this one. I thought this would be a super simple gulp only plugin (which admittedly is useless without the nodejs plugin).

Collaborator

sergiusens commented Jun 10, 2016

@earnubs thanks for the review

snapcraft/plugins/gulp.py
@@ -0,0 +1,106 @@
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
+#
+# Copyright (C) 2015 Canonical Ltd
snapcraft/plugins/gulp.py
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""The gulp plugin is useful for parts that use gulp tasks.
@elopio

elopio Jun 10, 2016

Member

I had no idea what was gulp a week ago. Is there room here for a short short summary, like:

gulp, the build system that uses node.js streams

snapcraft/tests/test_plugin_gulp.py
@@ -0,0 +1,147 @@
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
+#
+# Copyright (C) 2015 Canonical Ltd
Member

elopio commented Jun 10, 2016

This is missing one integration test with a gulp simple project.

+
+ patcher = mock.patch('snapcraft.sources.Tar')
+ self.tar_mock = patcher.start()
+ self.addCleanup(patcher.stop)
@elopio

elopio Jun 10, 2016

Member

I'm not sure what tar has to do with this. That means that either it's unnecessary, or missing a comment.

@kyrofa

kyrofa Jun 14, 2016

Member

It's used to pull down npm.

+ plugin.pull()
+
+ self.assertFalse(self.run_mock.called, 'run() was called')
+ self.tar_mock.assert_has_calls([
@elopio

elopio Jun 10, 2016

Member

I see it now.

snapcraft/tests/test_plugin_gulp.py
+ os.makedirs(plugin.sourcedir)
+ open(os.path.join(plugin.sourcedir, 'package.json'), 'w').close()
+
+ with mock.patch.dict(os.environ, {'PATH': 'bin'}):
@elopio

elopio Jun 10, 2016

Member

what if you use the env var fixture, to set PATH for the duration of the test?

snapcraft/tests/test_plugin_gulp.py
+ 'source-tag', 'source-subdir', 'node-engine'],
+ 'build-properties': ['gulp-tasks'],
+ 'required': ['gulp-tasks'],
+ 'type': 'object'}
@elopio

elopio Jun 10, 2016

Member

@kyrofa tests this with tons of assertions. I have no preference, but I would like the code to be consistent.

@kyrofa

kyrofa Jun 14, 2016

Member

A dump like this makes the tests easier to write, but harder to figure out when the test fails, so I tend to like helpful assertions.

@mariogrip mariogrip referenced this pull request Jun 10, 2016

Closed

New plugin: grunt #568

Member

elopio commented Jun 13, 2016

FAIL: test_main (test_main.MainTestCase)

test_main.MainTestCase.test_main

testtools.testresult.real._StringException: Traceback (most recent call last):
File "/tmp/adt-run.7oL9G5/build.Wh6/real-tree/integration_tests/test_main.py", line 30, in test_main
self.assertEqual(expected, output)
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 350, in assertEqual
self.assertThat(observed, matcher, message)
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 435, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = '''
ant catkin copy jdk kernel maven nodejs python3 tar-content
autotools cmake go kbuild make nil python2 scons
'''
actual = '''
ant catkin copy gulp kbuild make nil python2 scons
autotools cmake go jdk kernel maven nodejs python3 tar-content
'''

integration_tests/test_gulp_plugin.py
- self.assertEqual(expected, output)
+ binary_output = self.get_output_ignoring_non_zero_exit(
@elopio

elopio Jun 14, 2016

Member

why does it exit with non-zero?

@sergiusens

sergiusens Jun 14, 2016

Collaborator

I just copied this from another test, the Make one...

Member

elopio commented Jun 14, 2016

lgtm. I has a missing copyright year update. And there's the nit that 2015-2016 is not valid. It should be 2015, 2016.

snapcraft/plugins/gulp.py
+
+"""The gulp plugin drives gulp.js, the streaming build system.
+
+The plugin uses gulp to drive the build. It requires a gulpfile.js in
@kyrofa

kyrofa Jun 14, 2016

Member

"The gulp plugin drives gulp[...]" and "The plugin uses gulp to drive[...]" seem contradictory.

snapcraft/plugins/gulp.py
+ A list of gulp tasks to run.
+ - node-engine:
+ (string)
+ The version of nodejs you want the snap to run on.
@kyrofa

kyrofa Jun 14, 2016

Member

Does "The version of nodejs to be used by the snap" read a little better?

snapcraft/plugins/gulp.py
+ 'default': [],
+ }
+ schema['properties']['node-engine'] = node_properties['node-engine']
+ schema['required'] = ['gulp-tasks']
@kyrofa

kyrofa Jun 14, 2016

Member

This removes source from the requirements. Should you append instead, or is that what you intended?

snapcraft/plugins/gulp.py
+
+ # Inform Snapcraft of the properties associated with building. If these
+ # change in the YAML Snapcraft will consider the build step dirty.
+ schema['build-properties'] = ['gulp-tasks']
@kyrofa

kyrofa Jun 14, 2016

Member

Why not just append here?

@sergiusens

sergiusens Jun 14, 2016

Collaborator

thanks this is leftover from when I tried to inherit from the nodejs plugin

sergiusens added some commits Jun 14, 2016

Member

elopio commented Jun 14, 2016

The autopkgtests failed cleaning the test bed at the end, but all the tests passed. So this is good to go, except that it needs to be merged with master.

Member

elopio commented Jun 15, 2016

The autopkgtest failed with "Cannot connect to proxy." in one example test. Not related to this change, so I repeat, good to go. I'm not sure if Kyle has given the other +1, so I'll leave this to Sergio.

@sergiusens sergiusens merged commit 00079ee into snapcore:master Jun 15, 2016

3 of 4 checks passed

autopkgtest
Details
Examples tests Success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.05%) to 95.867%
Details

@sergiusens sergiusens deleted the sergiusens:bugfix/1575880/gulp-went-the branch Jun 15, 2016

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

New plugin: gulp (#563)
LP: #1575880

Signed-off-by: Sergio Schvezov <sergio.schvezov@ubuntu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment