gruntjs / grunt

Grunt: The JavaScript Task Runner
http://gruntjs.com/
Other
12.27k stars 1.5k forks source link

TeamCity-digestible reporting from lint and qunit tasks #147

Closed ArturDorochowicz closed 12 years ago

ArturDorochowicz commented 12 years ago

This is a feature request.

I currently use grunt qunit task as part of a build that runs on TeamCity (a continuous integration server). For linting I use a separate jshint installation with JSLint XML reporting redirected to a file. This file is later imported into TeamCity which can process it and present the code inspection results in the web ui. I would like to move linting to grunt as well. The problem for me is that grunt lint and qunit tasks do not generate output that can be consumed by TeamCity.

TeamCity can accept two types of input: a file or specially formatted messages in stdout. I would love to see a kind of a pluggable system of reporting in lint and qunit tasks so that if someone wants to, they can attach a file reporter or a special console reporter, or maybe both of them at the same time.

For tests TeamCity accepts files in JUnit, NUnit, Google Test and some other formats (http://confluence.jetbrains.net/display/TW/XML+Test+Reporting). For lint, it works with JSLint XML format.

The other way are so called service messages, specially formatted messages in stdout that TeamCity recognizes and interprets. A small benefit over files is that they are processed as they appear in the output - it may allow for a faster feedback to the user observing the build. More information here: http://confluence.jetbrains.net/display/TCD7/Build+Script+Interaction+with+TeamCity. For example, mocha has a reporter that uses this TeamCity capability: https://github.com/visionmedia/mocha/blob/master/lib/reporters/teamcity.js

There is no support for code inspection reporting (which lint is) through service messages in TeamCity now.

It would be best to be able to enable both: a file reporter - so that it can produce a build artifact that can be inspected later, and a stdout TeamCity-compatible reporter so that TeamCity can pick up things as they are printed out.

dcherman commented 12 years ago

+1. I'm wondering if something along the lines of https://github.com/cowboy/grunt/pull/199 could potentially be used for this.

If logging was changed so that it was event based or a callback list ( and more information was passed to it - message, module, filename ), you'd be able to write plugins to output info to support any kind of CI server that you wanted to without having to modify existing tasks.

You could also support having the standard grunt output or suppressing/replacing it entirely as part of your build config by simply unbinding or replacing the standard handlers.

JasonLunn commented 12 years ago

+1

zwigby commented 12 years ago

+10

ArturDorochowicz commented 12 years ago

I started working on xml report file for qunit task in my fork here: https://github.com/ArturDorochowicz/grunt/commit/06a2eb5f702669e3e390fca35d47f9c8f5f69dfb Seems to work ok in TeamCity.

cowboy commented 12 years ago

Once qunit task events have been added per #328, you'll be able to implement this entirely on your end using events... so feel free to participate in that discussion!

ArturDorochowicz commented 12 years ago

@cowboy Ok, I guess I'll have to give it a try with events later. What about lint task? Do you plan to introduce events there as well? Events are planned for 0.4, right?

ArturDorochowicz commented 12 years ago

For qunit I now have an Ant JUnit compatible XML reporter implemented based on the new grunt 0.4 qunit events. Repository is at https://github.com/ArturDorochowicz/grunt-qunit-ant-junit-reporter This should be considered work in progress, especially since grunt 0.4 is not finished yet.