diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-15 15:30:58 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-15 15:30:58 +0200 |
commit | 2b3dc7bfbc3dc9c94a7597e227da8001af995492 (patch) | |
tree | 76db153573ffbe7ee8c03f8ee4164aa545f800c3 | |
parent | 06a5402bd1a9f556d94eafc2a93ab7cd63306e73 (diff) | |
download | gitlab-ci-2b3dc7bfbc3dc9c94a7597e227da8001af995492.tar.gz |
Real time output
-rw-r--r-- | app/assets/javascripts/application.js | 2 | ||||
-rw-r--r-- | app/models/build.rb | 18 | ||||
-rw-r--r-- | db/migrate/20121115132252_add_tmp_file_to_build.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rw-r--r-- | lib/runner.rb | 2 |
5 files changed, 27 insertions, 3 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f68a4ce..d010afc 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,6 +18,6 @@ function getBuild(buildPath, buildId) { console.log('run'); setTimeout(function() { $.get(buildPath + ".js?bid=" + buildId); - }, 1500); + }, 3000); } diff --git a/app/models/build.rb b/app/models/build.rb index ccf7fc8..5252dcf 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -59,12 +59,23 @@ class Build < ActiveRecord::Base def trace_html if trace.present? - Ansi2html::convert(trace) + Ansi2html::convert(compose_output) else '' end end + + def compose_output + output = trace + + if running? && tmp_file + output << File.read(tmp_file) + end + + output + end + def to_param sha end @@ -72,6 +83,11 @@ class Build < ActiveRecord::Base def active? running? || pending? end + + def set_file path + self.tmp_file = path + self.save + end end diff --git a/db/migrate/20121115132252_add_tmp_file_to_build.rb b/db/migrate/20121115132252_add_tmp_file_to_build.rb new file mode 100644 index 0000000..a9a4e36 --- /dev/null +++ b/db/migrate/20121115132252_add_tmp_file_to_build.rb @@ -0,0 +1,5 @@ +class AddTmpFileToBuild < ActiveRecord::Migration + def change + add_column :builds, :tmp_file, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 5dfdc73..8234cbd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121115094430) do +ActiveRecord::Schema.define(:version => 20121115132252) do create_table "builds", :force => true do |t| t.integer "project_id" @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version => 20121115094430) do t.datetime "updated_at", :null => false t.string "sha" t.datetime "started_at" + t.string "tmp_file" end create_table "projects", :force => true do |t| diff --git a/lib/runner.rb b/lib/runner.rb index 924a1c7..50bbe76 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -73,6 +73,8 @@ class Runner @process.environment['BUNDLE_GEMFILE'] = '' @process.start + build.set_file @tmp_file.path + begin @process.poll_for_exit(project.timeout) rescue ChildProcess::TimeoutError |