diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-05-12 16:48:42 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-05-12 16:48:42 +0000 |
commit | f2303f9df061d6ff85d0ff0fee9e3aa54df97ea7 (patch) | |
tree | 72383406de96e7c4ae10994d556a8cdb90f7592a /app | |
parent | 95163307ae0c363d309b02c624c40b1ad9a03f06 (diff) | |
parent | 5bd356eb31fb4684199f6f681f4901ebe025ed92 (diff) | |
download | gitlab-ce-f2303f9df061d6ff85d0ff0fee9e3aa54df97ea7.tar.gz |
Merge branch 'send-incremental-build-log' into 'master'
Update build log incrementally
Proof of concept implementation of incremental sending of build log to browser.
cc @jschatz1 @vsizov @grzesiek @tmaczukin
See merge request !3737
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/ci/build.coffee | 21 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 8 | ||||
-rw-r--r-- | app/models/ci/build.rb | 8 | ||||
-rw-r--r-- | app/views/projects/builds/show.html.haml | 7 |
4 files changed, 33 insertions, 11 deletions
diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee index 7afe8bf79e2..fca0c3bae5c 100644 --- a/app/assets/javascripts/ci/build.coffee +++ b/app/assets/javascripts/ci/build.coffee @@ -1,9 +1,12 @@ class CiBuild @interval: null + @state: null - constructor: (build_url, build_status) -> + constructor: (build_url, build_status, build_state) -> clearInterval(CiBuild.interval) + @state = build_state + @initScrollButtonAffix() if build_status == "running" || build_status == "pending" @@ -26,14 +29,18 @@ class CiBuild CiBuild.interval = setInterval => if window.location.href.split("#").first() is build_url $.ajax - url: build_url + url: build_url + "/trace.json?state=" + encodeURIComponent(@state) dataType: "json" - success: (build) => - if build.status == "running" - $('#build-trace code').html build.trace_html - $('#build-trace code').append '<i class="fa fa-refresh fa-spin"/>' + success: (log) => + @state = log.state + if log.status is "running" + if log.append + $('.fa-refresh').before log.html + else + $('#build-trace code').html log.html + $('#build-trace code').append '<i class="fa fa-refresh fa-spin"/>' @checkAutoscroll() - else if build.status != build_status + else if log.status isnt build_status Turbolinks.visit build_url , 4000 diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index b8b9e78427d..bb1f6c5e980 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -38,6 +38,14 @@ class Projects::BuildsController < Projects::ApplicationController end end + def trace + respond_to do |format| + format.json do + render json: @build.trace_with_state(params[:state]).merge!(id: @build.id, status: @build.status) + end + end + end + def retry unless @build.retryable? return render_404 diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index c9506dd3057..4a3f92ad34a 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -95,8 +95,12 @@ module Ci end def trace_html - html = Ci::Ansi2html::convert(trace) if trace.present? - html || '' + trace_with_state[:html] || '' + end + + def trace_with_state(state = nil) + trace_with_state = Ci::Ansi2html::convert(trace, state) if trace.present? + trace_with_state || {} end def timeout diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml index c0f7a7686f0..c7b9c36a3ab 100644 --- a/app/views/projects/builds/show.html.haml +++ b/app/views/projects/builds/show.html.haml @@ -1,5 +1,6 @@ - page_title "#{@build.name} (##{@build.id})", "Builds" = render "header_title" +- trace_with_state = @build.trace_with_state .build-page .row-content-block.top-block @@ -85,7 +86,9 @@ %pre.trace#build-trace %code.bash = preserve do - = raw @build.trace_html + = raw trace_with_state[:html] + - if @build.active? + %i{:class => "fa fa-refresh fa-spin"} %div#down-build-trace @@ -216,4 +219,4 @@ :javascript - new CiBuild("#{namespace_project_build_url(@project.namespace, @project, @build)}", "#{@build.status}") + new CiBuild("#{namespace_project_build_url(@project.namespace, @project, @build)}", "#{@build.status}", "#{trace_with_state[:state]}") |