Page MenuHomePhabricator

Add npm test command to grrrit and have it to lint js/yaml files
Closed, ResolvedPublic

Description

The labs/tools/grrrit has three Jenkins jobs defined: jshint , jsonlint and yamllint. I would like to migrate to have jenkins simply run npm test to reduce the number of jobs we have to maintained and let the grrrit developers easily define tests they need.

Moreover, the yamllint job in Jenkins is using the python implementation whereas grrrit is using node.js.

Please see https://www.mediawiki.org/wiki/Continuous_integration/Entry_points#JavaScript for help defining the npm entry point. Once done, we can switch CI to use it instead of the custom jobs.

Event Timeline

hashar raised the priority of this task from to Needs Triage.
hashar updated the task description. (Show Details)
hashar added a project: grrrit-wm.
hashar added a subscriber: hashar.

grrrit folks any clue how to write a npm based test that lints the yaml files in Grrrit? I would like to phase out the python based Jenkins job 'yamllint'.

You're looking for some configuration of npm modules such that when you run npm test, the YAML files get linted?

If that's what you're looking for, js-yaml is a very easy-to-use node module. Running js-yaml file.yaml prints out the JSON for the YAML in the file and the return status code of js-yaml tells us whether there was an error or not. Errors get logged to console too, of course.

If we don't want to run the js-yaml module directly, we can use grunt-yamllint as a grunt task.

Change 241523 had a related patch set uploaded (by Polybuildr):
Use npm test to lint YAML

https://gerrit.wikimedia.org/r/241523

The project was already using js-yaml as a dependency, so I gave this a shot by putting in a js-yaml config.yaml as the npm test script.

Whatever works :-} Seems using the already provided js-yaml will do. Thank you!

Change 241615 had a related patch set uploaded (by Hashar):
[grrrit] Trigger npm for grrrit

https://gerrit.wikimedia.org/r/241615

Change 241615 merged by jenkins-bot:
[grrrit] Trigger npm for grrrit

https://gerrit.wikimedia.org/r/241615

Change 241523 merged by jenkins-bot:
Use npm test to lint YAML

https://gerrit.wikimedia.org/r/241523

hashar set Security to None.

yaml is done thanks. jsonlint/jshint should be done with Grunt probably.

Doing jsonlint using Grunt is a little weird, actually. The only JSON file that I can see in the repo is the package.json file. In order to use npm test, which will then get Grunt to lint the package.json file, the package.json file has to be valid in the first place. :P

I'll submit a patch soon that does the JSHinting using Grunt, but we probably need to rethink jsonlint.

Change 241754 had a related patch set uploaded (by Polybuildr):
Add Grunt to run JSHint

https://gerrit.wikimedia.org/r/241754

Indeed, no need to add jsonlint. I am happy to see you are working on adding jshint \O/

Change 241754 merged by jenkins-bot:
Add Grunt to run JSHint

https://gerrit.wikimedia.org/r/241754

Change 241757 had a related patch set uploaded (by Polybuildr):
Remove jshint and jsonlint jobs from labs/tools/grrrit

https://gerrit.wikimedia.org/r/241757

Change 241757 merged by jenkins-bot:
Remove jshint and jsonlint jobs from labs/tools/grrrit

https://gerrit.wikimedia.org/r/241757