From 94629bd27e7403a38d72822704c01e21190c4dc8 Mon Sep 17 00:00:00 2001 From: oleg Date: Wed, 6 May 2015 02:11:28 +0300 Subject: [PATCH] show current build step --- lib/distributor.js | 6 ++++++ lib/executor/base.js | 4 +++- projects/project1/config.json | 2 +- static/js/dataio.js | 2 +- views/index.jade | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/distributor.js b/lib/distributor.js index 97deca1..33068bc 100644 --- a/lib/distributor.js +++ b/lib/distributor.js @@ -67,6 +67,11 @@ Distributor.prototype._runNext = function(callback) { }); }); + executor.on('currentStep', function(stepName) { + build.currentStep = stepName; + self._updateBuild(build); + }); + executor.on('data', function(data) { self.onBuildData(build, data); }); @@ -76,6 +81,7 @@ Distributor.prototype._runNext = function(callback) { }; Distributor.prototype._updateBuild = function(build, callback) { + callback = callback || _.noop; this.onBuildUpdate(build, callback); }; diff --git a/lib/executor/base.js b/lib/executor/base.js index 51aa340..1dc0092 100644 --- a/lib/executor/base.js +++ b/lib/executor/base.js @@ -27,11 +27,13 @@ Executor.prototype.run = function(params, callback) { project = _({}).extend(self.project, params); Steppy( function() { + self.emit('currentStep', 'get sources'); self._getSources(project.scm, this.slot()); }, function() { - var funcs = project.steps.map(function(step) { + var funcs = project.steps.map(function(step, index) { return function() { + self.emit('currentStep', step.name || ('step ' + index)); self._runStep(step, this.slot()); }; }); diff --git a/projects/project1/config.json b/projects/project1/config.json index 20749f9..1db82d5 100644 --- a/projects/project1/config.json +++ b/projects/project1/config.json @@ -7,7 +7,7 @@ }, "steps": [ {"type": "shell", "cmd": "echo \"hello, cur dir is `pwd`\""}, - {"type": "shell", "cmd": "sleep 4"}, + {"type": "shell", "name": "sleep", "cmd": "sleep 4"}, {"type": "shell", "cmd": "echo 1 > 1.txt"}, {"type": "shell", "cmd": "sleep 4"}, {"type": "shell", "cmd": "echo 2 > 2.txt"}, diff --git a/static/js/dataio.js b/static/js/dataio.js index 9a5556a..4a774dd 100644 --- a/static/js/dataio.js +++ b/static/js/dataio.js @@ -5,7 +5,7 @@ define(['_dataio'], function(dataio) { var connect = dataio(socket); /* - * Extend resource + * Extend Resource */ var resource = connect.resource('__someResource__'), resourcePrototype = Object.getPrototypeOf(resource); diff --git a/views/index.jade b/views/index.jade index 98451a3..b7e0664 100644 --- a/views/index.jade +++ b/views/index.jade @@ -30,6 +30,7 @@ html | #<%= build.id %> | <%= build.project.name %> | <%= build.status %> + | <%= build.currentStep && build.status === 'in-progress' ? '(' + build.currentStep + ')' : '' %> | | | <% }); %>