Commit 7c0d0039 authored by Fatih Acet's avatar Fatih Acet Committed by Rémy Coutable

Merge branch 'cs-warn-on-failure' into 'master'

Warn on failure

## What does this MR do?

Adds styling and HTML for a `success_with_warnings` status in the MR widget. Unfinished as it needs some plumbing in the relevant CI controllers and models.

## Are there points in the code the reviewer needs to double check?

Not at the moment, though I think I'll probably need help getting this to work in the backend.

## What are the relevant issue numbers?

#17669 

## Screenshots (if relevant)

![Screen_Shot_2016-06-29_at_12.02.49_PM](/uploads/af4a915689633fe028f44bb34ae7a5b1/Screen_Shot_2016-06-29_at_12.02.49_PM.png)

## Does this MR meet the acceptance criteria?

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

cc: @ayufan 

See merge request !5004
parent e31bf436
...@@ -25,6 +25,7 @@ v 8.10.0 (unreleased) ...@@ -25,6 +25,7 @@ v 8.10.0 (unreleased)
- Store when and yaml variables in builds table - Store when and yaml variables in builds table
- Display last commit of deleted branch in push events !4699 (winniehell) - Display last commit of deleted branch in push events !4699 (winniehell)
- Escape file extension when parsing search results !5141 (winniehell) - Escape file extension when parsing search results !5141 (winniehell)
- Add "passing with warnings" to the merge request pipeline possible statuses, this happens when builds that allow failures have failed. !5004
- Apply the trusted_proxies config to the rack request object for use with rack_attack - Apply the trusted_proxies config to the rack request object for use with rack_attack
- Added the ability to block sign ups using a domain blacklist !5259 - Added the ability to block sign ups using a domain blacklist !5259
- Upgrade to Rails 4.2.7. !5236 - Upgrade to Rails 4.2.7. !5236
......
...@@ -55,10 +55,13 @@ class @MergeRequestWidget ...@@ -55,10 +55,13 @@ class @MergeRequestWidget
$('.mr-state-widget').replaceWith(data) $('.mr-state-widget').replaceWith(data)
ciLabelForStatus: (status) -> ciLabelForStatus: (status) ->
if status is 'success' switch status
'passed' when 'success'
else 'passed'
status when 'success_with_warnings'
'passed with warnings'
else
status
pollCIStatus: -> pollCIStatus: ->
@fetchBuildStatusInterval = setInterval ( => @fetchBuildStatusInterval = setInterval ( =>
...@@ -116,7 +119,7 @@ class @MergeRequestWidget ...@@ -116,7 +119,7 @@ class @MergeRequestWidget
showCIStatus: (state) -> showCIStatus: (state) ->
return if not state? return if not state?
$('.ci_widget').hide() $('.ci_widget').hide()
allowed_states = ["failed", "canceled", "running", "pending", "success", "skipped", "not_found"] allowed_states = ["failed", "canceled", "running", "pending", "success", "success_with_warnings", "skipped", "not_found"]
if state in allowed_states if state in allowed_states
$('.ci_widget.ci-' + state).show() $('.ci_widget.ci-' + state).show()
switch state switch state
...@@ -124,7 +127,7 @@ class @MergeRequestWidget ...@@ -124,7 +127,7 @@ class @MergeRequestWidget
@setMergeButtonClass('btn-danger') @setMergeButtonClass('btn-danger')
when "running" when "running"
@setMergeButtonClass('btn-warning') @setMergeButtonClass('btn-warning')
when "success" when "success", "success_with_warnings"
@setMergeButtonClass('btn-create') @setMergeButtonClass('btn-create')
else else
$('.ci_widget.ci-error').show() $('.ci_widget.ci-error').show()
......
...@@ -70,6 +70,14 @@ ...@@ -70,6 +70,14 @@
color: $gl-success; color: $gl-success;
} }
&.ci-success_with_warnings {
color: $gl-success;
i {
color: $gl-warning;
}
}
&.ci-skipped { &.ci-skipped {
background-color: #eee; background-color: #eee;
color: #888; color: #888;
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
border-color: $gl-danger; border-color: $gl-danger;
} }
&.ci-success { &.ci-success,
&.ci-success_with_warnings {
color: $gl-success; color: $gl-success;
border-color: $gl-success; border-color: $gl-success;
} }
...@@ -57,9 +58,12 @@ ...@@ -57,9 +58,12 @@
.ci-status-icon-failed { .ci-status-icon-failed {
color: $gl-danger; color: $gl-danger;
} }
.ci-status-icon-pending {
.ci-status-icon-pending,
.ci-status-icon-success_with_warning {
color: $gl-warning; color: $gl-warning;
} }
.ci-status-icon-running { .ci-status-icon-running {
color: $blue-normal; color: $blue-normal;
} }
......
...@@ -286,6 +286,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -286,6 +286,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
status = pipeline.status status = pipeline.status
coverage = pipeline.try(:coverage) coverage = pipeline.try(:coverage)
status = "success_with_warnings" if pipeline.success? && pipeline.has_warnings?
status ||= "preparing" status ||= "preparing"
else else
ci_service = @merge_request.source_project.ci_service ci_service = @merge_request.source_project.ci_service
......
...@@ -15,8 +15,11 @@ module CiStatusHelper ...@@ -15,8 +15,11 @@ module CiStatusHelper
end end
def ci_label_for_status(status) def ci_label_for_status(status)
if status == 'success' case status
when 'success'
'passed' 'passed'
when 'success_with_warnings'
'passed with warnings'
else else
status status
end end
......
...@@ -151,6 +151,10 @@ module Ci ...@@ -151,6 +151,10 @@ module Ci
end end
end end
def has_warnings?
builds.latest.ignored.any?
end
def config_processor def config_processor
return nil unless ci_yaml_file return nil unless ci_yaml_file
return @config_processor if defined?(@config_processor) return @config_processor if defined?(@config_processor)
......
- if @pipeline - if @pipeline
.mr-widget-heading .mr-widget-heading
- %w[success skipped canceled failed running pending].each do |status| - %w[success success_with_warnings skipped canceled failed running pending].each do |status|
.ci_widget{ class: "ci-#{status}", style: ("display:none" unless @pipeline.status == status) } .ci_widget{ class: "ci-#{status}", style: ("display:none" unless @pipeline.status == status) }
= ci_icon_for_status(status) = ci_icon_for_status(status)
%span %span
......
...@@ -504,4 +504,42 @@ describe Ci::Pipeline, models: true do ...@@ -504,4 +504,42 @@ describe Ci::Pipeline, models: true do
end end
end end
end end
describe '#has_warnings?' do
subject { pipeline.has_warnings? }
context 'build which is allowed to fail fails' do
before do
create :ci_build, :success, pipeline: pipeline, name: 'rspec'
create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop'
end
it 'returns true' do
is_expected.to be_truthy
end
end
context 'build which is allowed to fail succeeds' do
before do
create :ci_build, :success, pipeline: pipeline, name: 'rspec'
create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: 'rubocop'
end
it 'returns false' do
is_expected.to be_falsey
end
end
context 'build is retried and succeeds' do
before do
create :ci_build, :success, pipeline: pipeline, name: 'rubocop'
create :ci_build, :failed, pipeline: pipeline, name: 'rspec'
create :ci_build, :success, pipeline: pipeline, name: 'rspec'
end
it 'returns false' do
is_expected.to be_falsey
end
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment