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