From 4c0adb9ee9ee6631b7cda6562d0e20b7daab8a9e Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Sun, 16 Apr 2017 02:33:01 +0100 Subject: Build failures summary page for pipelines --- app/assets/javascripts/dispatcher.js | 1 + app/assets/stylesheets/pages/pipelines.scss | 26 +++++++++++++++++++++++ app/controllers/projects/pipelines_controller.rb | 20 +++++++++++------ app/helpers/builds_helper.rb | 8 +++++++ app/views/projects/pipelines/_with_tabs.html.haml | 16 ++++++++++++-- 5 files changed, 63 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index f277e1dddc7..32cc6623c7e 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -232,6 +232,7 @@ const ShortcutsBlob = require('./shortcuts_blob'); } break; case 'projects:pipelines:builds': + case 'projects:pipelines:failures': case 'projects:pipelines:show': const { controllerAction } = document.querySelector('.js-pipeline-container').dataset; const pipelineStatusUrl = `${document.querySelector('.js-pipeline-tab-link a').getAttribute('href')}/status.json`; diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss index a4fe652b52f..22500698af3 100644 --- a/app/assets/stylesheets/pages/pipelines.scss +++ b/app/assets/stylesheets/pages/pipelines.scss @@ -316,6 +316,32 @@ } } +.build-failures { + .build-state { + padding: 20px 2px; + + .build-name { + float: right; + font-weight: 500; + } + + .ci-status-icon-failed svg { + vertical-align: middle; + } + + .stage { + color: $gl-text-color-secondary; + font-weight: 500; + vertical-align: middle; + } + } + + .build-log { + border: none; + line-height: initial; + } +} + // Pipeline graph .pipeline-graph { width: 100%; diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 1780cc0233c..915f0bc63f7 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -1,6 +1,6 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :pipeline, except: [:index, :new, :create, :charts] - before_action :commit, only: [:show, :builds] + before_action :commit, only: [:show, :builds, :failures] before_action :authorize_read_pipeline! before_action :authorize_create_pipeline!, only: [:new, :create] before_action :authorize_update_pipeline!, only: [:retry, :cancel] @@ -67,11 +67,11 @@ class Projects::PipelinesController < Projects::ApplicationController end def builds - respond_to do |format| - format.html do - render 'show' - end - end + render_show + end + + def failures + render_show end def status @@ -111,6 +111,14 @@ class Projects::PipelinesController < Projects::ApplicationController private + def render_show + respond_to do |format| + format.html do + render 'show' + end + end + end + def create_params params.require(:pipeline).permit(:ref) end diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index 2fcb7a59fc3..0145029fb60 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -1,4 +1,12 @@ module BuildsHelper + def build_summary(build) + if build.has_trace? + build.trace.html(last_lines: 10).html_safe + else + "No job trace" + end + end + def sidebar_build_class(build, current_build) build_class = '' build_class += ' active' if build.id === current_build.id diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml index d7cefb8613e..76eb8533cc3 100644 --- a/app/views/projects/pipelines/_with_tabs.html.haml +++ b/app/views/projects/pipelines/_with_tabs.html.haml @@ -7,8 +7,10 @@ = link_to builds_namespace_project_pipeline_path(@project.namespace, @project, @pipeline), data: {target: 'div#js-tab-builds', action: 'builds', toggle: 'tab' }, class: 'builds-tab' do Jobs %span.badge.js-builds-counter= pipeline.statuses.count - - + %li.js-failures-tab-link + = link_to failures_namespace_project_pipeline_path(@project.namespace, @project, @pipeline), data: {target: 'div#js-tab-failures', action: 'failures', toggle: 'tab' }, class: 'failures-tab' do + Failures + %span.badge.js-failures-counter= pipeline.statuses.latest.failed.count .tab-content #js-tab-pipeline.tab-pane @@ -39,3 +41,13 @@ %th Coverage %th = render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage + #js-tab-failures.build-failures.tab-pane + - failed = @pipeline.statuses.latest.failed + - failed.each do |build| + .build-state + %span.ci-status-icon-failed= custom_icon('icon_status_failed') + %span.stage + = build.stage.titleize + %span.build-name + = render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build + %pre.build-log= build_summary(build) -- cgit v1.2.3 From acd9cd0906046f3d11d95aa9dc9d1af0498ef2ef Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Thu, 4 May 2017 17:50:09 +0100 Subject: =?UTF-8?q?Hides=20pipeline=20=E2=80=98Failed=20Jobs=E2=80=99=20ta?= =?UTF-8?q?b=20when=20no=20jobs=20have=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects/pipelines_controller.rb | 6 ++++- app/views/projects/pipelines/_with_tabs.html.haml | 31 +++++++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'app') diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 915f0bc63f7..3a56be2735a 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -71,7 +71,11 @@ class Projects::PipelinesController < Projects::ApplicationController end def failures - render_show + if @pipeline.statuses.latest.failed.present? + render_show + else + redirect_to pipeline_path(@pipeline) + end end def status diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml index 76eb8533cc3..ba2c71cfd88 100644 --- a/app/views/projects/pipelines/_with_tabs.html.haml +++ b/app/views/projects/pipelines/_with_tabs.html.haml @@ -1,3 +1,5 @@ +- failed_builds = @pipeline.statuses.latest.failed + .tabs-holder %ul.pipelines-tabs.nav-links.no-top.no-bottom %li.js-pipeline-tab-link @@ -7,10 +9,11 @@ = link_to builds_namespace_project_pipeline_path(@project.namespace, @project, @pipeline), data: {target: 'div#js-tab-builds', action: 'builds', toggle: 'tab' }, class: 'builds-tab' do Jobs %span.badge.js-builds-counter= pipeline.statuses.count - %li.js-failures-tab-link - = link_to failures_namespace_project_pipeline_path(@project.namespace, @project, @pipeline), data: {target: 'div#js-tab-failures', action: 'failures', toggle: 'tab' }, class: 'failures-tab' do - Failures - %span.badge.js-failures-counter= pipeline.statuses.latest.failed.count + - if failed_builds.present? + %li.js-failures-tab-link + = link_to failures_namespace_project_pipeline_path(@project.namespace, @project, @pipeline), data: {target: 'div#js-tab-failures', action: 'failures', toggle: 'tab' }, class: 'failures-tab' do + Failed Jobs + %span.badge.js-failures-counter= failed_builds.count .tab-content #js-tab-pipeline.tab-pane @@ -41,13 +44,13 @@ %th Coverage %th = render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage - #js-tab-failures.build-failures.tab-pane - - failed = @pipeline.statuses.latest.failed - - failed.each do |build| - .build-state - %span.ci-status-icon-failed= custom_icon('icon_status_failed') - %span.stage - = build.stage.titleize - %span.build-name - = render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build - %pre.build-log= build_summary(build) + - if failed_builds.present? + #js-tab-failures.build-failures.tab-pane + - failed_builds.each do |build| + .build-state + %span.ci-status-icon-failed= custom_icon('icon_status_failed') + %span.stage + = build.stage.titleize + %span.build-name + = render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build + %pre.build-log= build_summary(build) -- cgit v1.2.3 From 9f3f22c8959b430811102fb790895e7edd61d3f9 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Thu, 4 May 2017 19:30:13 +0100 Subject: Failed Jobs tab only shows 10 job traces for performance --- app/helpers/builds_helper.rb | 8 ++++++-- app/views/projects/pipelines/_with_tabs.html.haml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index 0145029fb60..2eb2c6c7389 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -1,7 +1,11 @@ module BuildsHelper - def build_summary(build) + def build_summary(build, skip: false) if build.has_trace? - build.trace.html(last_lines: 10).html_safe + if skip + link_to "View job trace", pipeline_build_url(build.pipeline, build) + else + build.trace.html(last_lines: 10).html_safe + end else "No job trace" end diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml index ba2c71cfd88..1aa48bf9813 100644 --- a/app/views/projects/pipelines/_with_tabs.html.haml +++ b/app/views/projects/pipelines/_with_tabs.html.haml @@ -46,11 +46,11 @@ = render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage - if failed_builds.present? #js-tab-failures.build-failures.tab-pane - - failed_builds.each do |build| + - failed_builds.each_with_index do |build, index| .build-state %span.ci-status-icon-failed= custom_icon('icon_status_failed') %span.stage = build.stage.titleize %span.build-name - = render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build - %pre.build-log= build_summary(build) + = link_to build.name, pipeline_build_url(pipeline, build) + %pre.build-log= build_summary(build, skip: index >= 10) -- cgit v1.2.3