asjon/scripts/drone.coffee

38 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2015-04-28 17:50:59 +02:00
# Description:
# integrazione con drone.io e funzioni annesse
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot (mostrami la) copertura (dei test)
#
# Author:
# Enrico Fasoli (fazo96)
moment = require 'moment'
module.exports = (robot) ->
robot.respond /(?:mostrami la )?(?:copertura|coverage)(?: dei test)?/i, (res) ->
url = 'https://drone.io/github.com/fazo96/asjon/files/coverage/coverage.'
robot.http(url+'json')
.get() (err, resp, body) ->
try
report = JSON.parse body
catch e
if /^404/g.test body
return res.send 'Coverage report non disponibile (404) forse \
non รจ ancora stato generato?'
return res.send 'Errore: '+e+'\n\nRisposta del server: '+body
2015-04-28 17:50:59 +02:00
unless report?.files?.push? and report?.coverage?.toFixed?
return res.send 'Errore: informazioni insufficienti'
2015-04-28 17:50:59 +02:00
t = '=== Coverage: ' + report.coverage.toFixed(0) + '%'
t += report.files.map (f) ->
'\n - ' + f.filename + ' is covered at ' + f.coverage.toFixed(0) + '%'
t += '\nHTML report: '+url+'html'
t += '\nJSON report: '+url+'json'
res.send t