add step timings to the build

This commit is contained in:
oleg 2015-07-12 00:27:02 +03:00
parent 46bfedc506
commit b41b76884b
2 changed files with 26 additions and 3 deletions

View File

@ -92,6 +92,10 @@ Distributor.prototype._runNext = function(callback) {
self._updateBuild(build, {currentStep: stepName});
});
executor.on('stepTimingsChange', function(stepTimings) {
self._updateBuild(build, {stepTimings: stepTimings});
});
executor.on('data', function(data) {
self.emit('buildData', build, data);
});

View File

@ -33,20 +33,39 @@ Executor.prototype.hasScmChanges = function(callback) {
Executor.prototype.run = function(params, callback) {
var self = this,
project = _({}).extend(self.project, params);
project = _({}).extend(self.project, params),
getSourcesTiming = {name: 'get sources'},
stepTimings = [],
getSourcesStart = Date.now();
Steppy(
function() {
self.throttledEmit('currentStep', 'get sources');
self.throttledEmit('currentStep', getSourcesTiming.name);
self._getSources(project.scm, this.slot());
},
function(err, scmData) {
getSourcesTiming.duration = Date.now() - getSourcesStart;
stepTimings.push(getSourcesTiming);
self.emit('scmData', scmData);
var funcs = project.steps.map(function(step, index) {
return function() {
var start = Date.now(),
stepCallback = this.slot();
self.throttledEmit('currentStep', step.name);
self._runStep(step, this.slot());
var timing = {name: step.name};
self._runStep(step, function(err) {
timing.duration = Date.now() - start;
stepTimings.push(timing);
self.emit('stepTimingsChange', stepTimings);
stepCallback(err);
});
};
});
funcs.push(this.slot());
Steppy.apply(this, funcs);
},