diff --git a/CHANGELOG b/CHANGELOG index 25a13d558ca2d6572999ce635efacbeee686a4fc..d5e66840f233f5e3794975dbda7c2c5f9b51b64a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ v 8.10.0 (unreleased) - Store when and yaml variables in builds table - Display last commit of deleted branch in push events !4699 (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 - Upgrade to Rails 4.2.7. !5236 - Extend exposed environment variables for CI builds diff --git a/app/assets/javascripts/merge_request_widget.js.coffee b/app/assets/javascripts/merge_request_widget.js.coffee index 779f536d9f07455c104212b1eafa0bd8e44aedd0..963a0550c35bde422d6980d66aec6410d991817c 100644 --- a/app/assets/javascripts/merge_request_widget.js.coffee +++ b/app/assets/javascripts/merge_request_widget.js.coffee @@ -55,10 +55,13 @@ class @MergeRequestWidget $('.mr-state-widget').replaceWith(data) ciLabelForStatus: (status) -> - if status is 'success' - 'passed' - else - status + switch status + when 'success' + 'passed' + when 'success_with_warnings' + 'passed with warnings' + else + status pollCIStatus: -> @fetchBuildStatusInterval = setInterval ( => @@ -116,7 +119,7 @@ class @MergeRequestWidget showCIStatus: (state) -> return if not state? $('.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 $('.ci_widget.ci-' + state).show() switch state @@ -124,7 +127,7 @@ class @MergeRequestWidget @setMergeButtonClass('btn-danger') when "running" @setMergeButtonClass('btn-warning') - when "success" + when "success", "success_with_warnings" @setMergeButtonClass('btn-create') else $('.ci_widget.ci-error').show() diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index 5254faf723db65efbbdaf28711eb79fba5153d24..4e806e60e7e91ca10b3c0150c78d20fe047308e4 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -70,6 +70,14 @@ color: $gl-success; } + &.ci-success_with_warnings { + color: $gl-success; + + i { + color: $gl-warning; + } + } + &.ci-skipped { background-color: #eee; color: #888; diff --git a/app/assets/stylesheets/pages/status.scss b/app/assets/stylesheets/pages/status.scss index a22d4b6f6be66b02eaa675a32e9eb62926b5bb79..99f64b5e4cc2c26fc475208ae7539a4adc6a2881 100644 --- a/app/assets/stylesheets/pages/status.scss +++ b/app/assets/stylesheets/pages/status.scss @@ -15,7 +15,8 @@ border-color: $gl-danger; } - &.ci-success { + &.ci-success, + &.ci-success_with_warnings { color: $gl-success; border-color: $gl-success; } @@ -57,9 +58,12 @@ .ci-status-icon-failed { color: $gl-danger; } - .ci-status-icon-pending { + + .ci-status-icon-pending, + .ci-status-icon-success_with_warning { color: $gl-warning; } + .ci-status-icon-running { color: $blue-normal; } diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index df659bb8c3bbfa3cbd1d4e58a8e91b9dd411c9dd..7beeb7d97d01d81f9e18afe5ed05567f9046fb79 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -286,6 +286,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController status = pipeline.status coverage = pipeline.try(:coverage) + status = "success_with_warnings" if pipeline.success? && pipeline.has_warnings? + status ||= "preparing" else ci_service = @merge_request.source_project.ci_service diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 59a8365d60b403cfe02fe9ab20335562ee9d029e..ffac28f78a0e21542955a4cfe2f9c41b1b610b96 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -15,8 +15,11 @@ module CiStatusHelper end def ci_label_for_status(status) - if status == 'success' + case status + when 'success' 'passed' + when 'success_with_warnings' + 'passed with warnings' else status end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 88fa01c896d082788ccd2d08e16dbc999ea0905d..6d3bbb03484b1074a82b9da677d9ef30b4159878 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -146,6 +146,10 @@ module Ci end end + def has_warnings? + builds.latest.ignored.any? + end + def config_processor return nil unless ci_yaml_file return @config_processor if defined?(@config_processor) diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml index 489c632ae229fd77d72e37f92eb2226b207b84ee..6ef640bb6543d1446ca42b3d71b6543b9260aedf 100644 --- a/app/views/projects/merge_requests/widget/_heading.html.haml +++ b/app/views/projects/merge_requests/widget/_heading.html.haml @@ -1,6 +1,6 @@ - if @pipeline .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_icon_for_status(status) %span diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index a3bd8fdf30b3b0943c31e788dfb52b5ceedec809..0d4c86955ceb37c67ac07e29ada97e5d7e887c79 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -504,4 +504,42 @@ describe Ci::Pipeline, models: true do 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