Commit 5ebf75c8 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '37947-skipped-deployments' into 'master'

Add "skipped" status to deployments

See merge request gitlab-org/gitlab!46614
parents a57f669e 6f59a1b7
......@@ -6,6 +6,7 @@ export const RUNNING = 'running';
export const SUCCESS = 'success';
export const FAILED = 'failed';
export const CANCELED = 'canceled';
export const SKIPPED = 'skipped';
// ACTION STATUSES
export const STOPPING = 'stopping';
......
......@@ -4,7 +4,15 @@ import { __ } from '~/locale';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import MemoryUsage from './memory_usage.vue';
import { MANUAL_DEPLOY, WILL_DEPLOY, RUNNING, SUCCESS, FAILED, CANCELED } from './constants';
import {
MANUAL_DEPLOY,
WILL_DEPLOY,
RUNNING,
SUCCESS,
FAILED,
CANCELED,
SKIPPED,
} from './constants';
export default {
name: 'DeploymentInfo',
......@@ -38,6 +46,7 @@ export default {
[SUCCESS]: __('Deployed to'),
[FAILED]: __('Failed to deploy to'),
[CANCELED]: __('Canceled deployment to'),
[SKIPPED]: __('Skipped deployment to'),
},
computed: {
deployTimeago() {
......
......@@ -26,6 +26,7 @@
}
&.ci-canceled,
&.ci-skipped,
&.ci-disabled,
&.ci-scheduled,
&.ci-manual {
......
......@@ -52,6 +52,8 @@ module EnvironmentHelper
s_('Deployment|failed')
when 'canceled'
s_('Deployment|canceled')
when 'skipped'
s_('Deployment|skipped')
end
klass = "ci-status ci-#{status.dasherize}"
......
......@@ -379,8 +379,16 @@ module Ci
Ci::BuildRunnerSession.where(build: build).delete_all
end
after_transition any => [:skipped, :canceled] do |build|
build.deployment&.cancel
after_transition any => [:skipped, :canceled] do |build, transition|
if Feature.enabled?(:cd_skipped_deployment_status, build.project)
if transition.to_name == :skipped
build.deployment&.skip
else
build.deployment&.cancel
end
else
build.deployment&.cancel
end
end
end
......
......@@ -63,6 +63,10 @@ class Deployment < ApplicationRecord
transition any - [:canceled] => :canceled
end
event :skip do
transition any - [:skipped] => :skipped
end
before_transition any => FINISHED_STATUSES do |deployment|
deployment.finished_at = Time.current
end
......@@ -105,7 +109,8 @@ class Deployment < ApplicationRecord
running: 1,
success: 2,
failed: 3,
canceled: 4
canceled: 4,
skipped: 5
}
def self.last_for_environment(environment)
......@@ -297,6 +302,8 @@ class Deployment < ApplicationRecord
drop
when 'canceled'
cancel
when 'skipped'
skip
else
raise ArgumentError, "The status #{status.inspect} is invalid"
end
......
---
title: Skipped jobs no longer trigger a cancelled deployment
merge_request: 46614
author: David Barr @davebarr
type: fixed
name: cd_skipped_deployment_status
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46614
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/283884
milestone: '13.6'
type: development
group: group::release
default_enabled: false
......@@ -9235,6 +9235,9 @@ msgstr ""
msgid "Deployment|running"
msgstr ""
msgid "Deployment|skipped"
msgstr ""
msgid "Deployment|success"
msgstr ""
......@@ -25107,6 +25110,9 @@ msgstr ""
msgid "Skipped"
msgstr ""
msgid "Skipped deployment to"
msgstr ""
msgid "Slack application"
msgstr ""
......
......@@ -8,6 +8,7 @@ import {
SUCCESS,
FAILED,
CANCELED,
SKIPPED,
} from '~/vue_merge_request_widget/components/deployment/constants';
import { deploymentMockData, playDetails, retryDetails } from './deployment_mock_data';
......@@ -77,6 +78,10 @@ describe('Deployment component', () => {
${CANCELED} | ${true} | ${noDetails} | ${'Canceled deployment to'} | ${defaultGroup}
${CANCELED} | ${false} | ${deployDetail} | ${'Canceled deployment to'} | ${noActions}
${CANCELED} | ${false} | ${noDetails} | ${'Canceled deployment to'} | ${noActions}
${SKIPPED} | ${true} | ${deployDetail} | ${'Skipped deployment to'} | ${defaultGroup}
${SKIPPED} | ${true} | ${noDetails} | ${'Skipped deployment to'} | ${defaultGroup}
${SKIPPED} | ${false} | ${deployDetail} | ${'Skipped deployment to'} | ${noActions}
${SKIPPED} | ${false} | ${noDetails} | ${'Skipped deployment to'} | ${noActions}
`(
'$status + previous: $previous + manual: $deploymentDetails.isManual',
({ status, previous, deploymentDetails, text, actionButtons }) => {
......
......@@ -1151,12 +1151,26 @@ RSpec.describe Ci::Build do
end
context 'when transits to skipped' do
before do
build.skip!
context 'when cd_skipped_deployment_status is disabled' do
before do
stub_feature_flags(cd_skipped_deployment_status: false)
build.skip!
end
it 'transits deployment status to canceled' do
expect(deployment).to be_canceled
end
end
it 'transits deployment status to canceled' do
expect(deployment).to be_canceled
context 'when cd_skipped_deployment_status is enabled' do
before do
stub_feature_flags(cd_skipped_deployment_status: project)
build.skip!
end
it 'transits deployment status to skipped' do
expect(deployment).to be_skipped
end
end
end
......
......@@ -202,6 +202,31 @@ RSpec.describe Deployment do
deployment.cancel!
end
end
context 'when deployment was skipped' do
let(:deployment) { create(:deployment, :running) }
it 'has correct status' do
deployment.skip!
expect(deployment).to be_skipped
expect(deployment.finished_at).to be_nil
end
it 'does not execute Deployments::LinkMergeRequestWorker asynchronously' do
expect(Deployments::LinkMergeRequestWorker)
.not_to receive(:perform_async).with(deployment.id)
deployment.skip!
end
it 'does not execute Deployments::ExecuteHooksWorker' do
expect(Deployments::ExecuteHooksWorker)
.not_to receive(:perform_async).with(deployment.id)
deployment.skip!
end
end
end
describe '#success?' do
......@@ -320,6 +345,7 @@ RSpec.describe Deployment do
deployment2 = create(:deployment, status: :running )
create(:deployment, status: :failed )
create(:deployment, status: :canceled )
create(:deployment, status: :skipped)
is_expected.to contain_exactly(deployment1, deployment2)
end
......@@ -350,6 +376,20 @@ RSpec.describe Deployment do
is_expected.to contain_exactly(with_deployable)
end
end
describe 'visible' do
subject { described_class.visible }
it 'retrieves the visible deployments' do
deployment1 = create(:deployment, status: :running)
deployment2 = create(:deployment, status: :success)
deployment3 = create(:deployment, status: :failed)
deployment4 = create(:deployment, status: :canceled)
create(:deployment, status: :skipped)
is_expected.to contain_exactly(deployment1, deployment2, deployment3, deployment4)
end
end
end
describe '#includes_commit?' do
......
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