mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-14 00:59:15 +00:00
move avg build calculation from lib distributor - fix tests
This commit is contained in:
parent
0df4b2771f
commit
2f0c87ceac
@ -3,6 +3,9 @@
|
||||
var Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
Distributor = require('./lib/distributor').Distributor,
|
||||
getAvgProjectBuildDuration = (
|
||||
require('./lib/project').getAvgProjectBuildDuration
|
||||
),
|
||||
db = require('./db'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
@ -16,6 +19,15 @@ exports.init = function(app, callback) {
|
||||
saveBuild: function(build, callback) {
|
||||
Steppy(
|
||||
function() {
|
||||
if (!_(build.project).has('avgBuildDuration')) {
|
||||
getAvgProjectBuildDuration(build.project.name, this.slot());
|
||||
} else {
|
||||
this.pass(build.project.avgBuildDuration);
|
||||
}
|
||||
},
|
||||
function(err, avgBuildDuration) {
|
||||
build.project.avgBuildDuration = avgBuildDuration;
|
||||
|
||||
db.builds.put(build, this.slot());
|
||||
},
|
||||
function() {
|
||||
|
@ -3,7 +3,6 @@
|
||||
var Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
Node = require('./node').Node,
|
||||
getAvgProjectBuildDuration = require('./project').getAvgProjectBuildDuration,
|
||||
EventEmitter = require('events').EventEmitter,
|
||||
inherits = require('util').inherits,
|
||||
notifier = require('./notifier'),
|
||||
@ -220,17 +219,18 @@ Distributor.prototype.run = function(params, callback) {
|
||||
};
|
||||
Steppy(
|
||||
function() {
|
||||
project = _(self.projects).findWhere({name: params.projectName});
|
||||
project = _(self.projects).chain()
|
||||
.findWhere({name: params.projectName})
|
||||
.clone()
|
||||
.value();
|
||||
|
||||
if (params.withScmChangesOnly) {
|
||||
self.nodes[0].hasScmChanges(project, this.slot());
|
||||
} else {
|
||||
this.pass(null);
|
||||
}
|
||||
|
||||
getAvgProjectBuildDuration(params.projectName, this.slot());
|
||||
},
|
||||
function(err, hasScmChanges, avgProjectBuildDuration) {
|
||||
function(err, hasScmChanges) {
|
||||
if (params.withScmChangesOnly && !hasScmChanges) {
|
||||
logger.log(
|
||||
'Building of "%s" skipped coz no scm changes',
|
||||
@ -239,8 +239,6 @@ Distributor.prototype.run = function(params, callback) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
project.avgBuildDuration = avgProjectBuildDuration;
|
||||
|
||||
self._updateBuild({}, {
|
||||
project: project,
|
||||
initiator: params.initiator,
|
||||
|
Loading…
Reference in New Issue
Block a user