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'; ...@@ -6,6 +6,7 @@ export const RUNNING = 'running';
export const SUCCESS = 'success'; export const SUCCESS = 'success';
export const FAILED = 'failed'; export const FAILED = 'failed';
export const CANCELED = 'canceled'; export const CANCELED = 'canceled';
export const SKIPPED = 'skipped';
// ACTION STATUSES // ACTION STATUSES
export const STOPPING = 'stopping'; export const STOPPING = 'stopping';
......
...@@ -4,7 +4,15 @@ import { __ } from '~/locale'; ...@@ -4,7 +4,15 @@ import { __ } from '~/locale';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import MemoryUsage from './memory_usage.vue'; 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 { export default {
name: 'DeploymentInfo', name: 'DeploymentInfo',
...@@ -38,6 +46,7 @@ export default { ...@@ -38,6 +46,7 @@ export default {
[SUCCESS]: __('Deployed to'), [SUCCESS]: __('Deployed to'),
[FAILED]: __('Failed to deploy to'), [FAILED]: __('Failed to deploy to'),
[CANCELED]: __('Canceled deployment to'), [CANCELED]: __('Canceled deployment to'),
[SKIPPED]: __('Skipped deployment to'),
}, },
computed: { computed: {
deployTimeago() { deployTimeago() {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
} }
&.ci-canceled, &.ci-canceled,
&.ci-skipped,
&.ci-disabled, &.ci-disabled,
&.ci-scheduled, &.ci-scheduled,
&.ci-manual { &.ci-manual {
......
...@@ -52,6 +52,8 @@ module EnvironmentHelper ...@@ -52,6 +52,8 @@ module EnvironmentHelper
s_('Deployment|failed') s_('Deployment|failed')
when 'canceled' when 'canceled'
s_('Deployment|canceled') s_('Deployment|canceled')
when 'skipped'
s_('Deployment|skipped')
end end
klass = "ci-status ci-#{status.dasherize}" klass = "ci-status ci-#{status.dasherize}"
......
...@@ -379,8 +379,16 @@ module Ci ...@@ -379,8 +379,16 @@ module Ci
Ci::BuildRunnerSession.where(build: build).delete_all Ci::BuildRunnerSession.where(build: build).delete_all
end end
after_transition any => [:skipped, :canceled] do |build| after_transition any => [:skipped, :canceled] do |build, transition|
build.deployment&.cancel 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
end end
......
...@@ -63,6 +63,10 @@ class Deployment < ApplicationRecord ...@@ -63,6 +63,10 @@ class Deployment < ApplicationRecord
transition any - [:canceled] => :canceled transition any - [:canceled] => :canceled
end end
event :skip do
transition any - [:skipped] => :skipped
end
before_transition any => FINISHED_STATUSES do |deployment| before_transition any => FINISHED_STATUSES do |deployment|
deployment.finished_at = Time.current deployment.finished_at = Time.current
end end
...@@ -105,7 +109,8 @@ class Deployment < ApplicationRecord ...@@ -105,7 +109,8 @@ class Deployment < ApplicationRecord
running: 1, running: 1,
success: 2, success: 2,
failed: 3, failed: 3,
canceled: 4 canceled: 4,
skipped: 5
} }
def self.last_for_environment(environment) def self.last_for_environment(environment)
...@@ -297,6 +302,8 @@ class Deployment < ApplicationRecord ...@@ -297,6 +302,8 @@ class Deployment < ApplicationRecord
drop drop
when 'canceled' when 'canceled'
cancel cancel
when 'skipped'
skip
else else
raise ArgumentError, "The status #{status.inspect} is invalid" raise ArgumentError, "The status #{status.inspect} is invalid"
end 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 "" ...@@ -9235,6 +9235,9 @@ msgstr ""
msgid "Deployment|running" msgid "Deployment|running"
msgstr "" msgstr ""
msgid "Deployment|skipped"
msgstr ""
msgid "Deployment|success" msgid "Deployment|success"
msgstr "" msgstr ""
...@@ -25107,6 +25110,9 @@ msgstr "" ...@@ -25107,6 +25110,9 @@ msgstr ""
msgid "Skipped" msgid "Skipped"
msgstr "" msgstr ""
msgid "Skipped deployment to"
msgstr ""
msgid "Slack application" msgid "Slack application"
msgstr "" msgstr ""
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
SUCCESS, SUCCESS,
FAILED, FAILED,
CANCELED, CANCELED,
SKIPPED,
} from '~/vue_merge_request_widget/components/deployment/constants'; } from '~/vue_merge_request_widget/components/deployment/constants';
import { deploymentMockData, playDetails, retryDetails } from './deployment_mock_data'; import { deploymentMockData, playDetails, retryDetails } from './deployment_mock_data';
...@@ -77,6 +78,10 @@ describe('Deployment component', () => { ...@@ -77,6 +78,10 @@ describe('Deployment component', () => {
${CANCELED} | ${true} | ${noDetails} | ${'Canceled deployment to'} | ${defaultGroup} ${CANCELED} | ${true} | ${noDetails} | ${'Canceled deployment to'} | ${defaultGroup}
${CANCELED} | ${false} | ${deployDetail} | ${'Canceled deployment to'} | ${noActions} ${CANCELED} | ${false} | ${deployDetail} | ${'Canceled deployment to'} | ${noActions}
${CANCELED} | ${false} | ${noDetails} | ${'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: $previous + manual: $deploymentDetails.isManual',
({ status, previous, deploymentDetails, text, actionButtons }) => { ({ status, previous, deploymentDetails, text, actionButtons }) => {
......
...@@ -1151,12 +1151,26 @@ RSpec.describe Ci::Build do ...@@ -1151,12 +1151,26 @@ RSpec.describe Ci::Build do
end end
context 'when transits to skipped' do context 'when transits to skipped' do
before do context 'when cd_skipped_deployment_status is disabled' do
build.skip! 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 end
it 'transits deployment status to canceled' do context 'when cd_skipped_deployment_status is enabled' do
expect(deployment).to be_canceled 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
end end
......
...@@ -202,6 +202,31 @@ RSpec.describe Deployment do ...@@ -202,6 +202,31 @@ RSpec.describe Deployment do
deployment.cancel! deployment.cancel!
end end
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 end
describe '#success?' do describe '#success?' do
...@@ -320,6 +345,7 @@ RSpec.describe Deployment do ...@@ -320,6 +345,7 @@ RSpec.describe Deployment do
deployment2 = create(:deployment, status: :running ) deployment2 = create(:deployment, status: :running )
create(:deployment, status: :failed ) create(:deployment, status: :failed )
create(:deployment, status: :canceled ) create(:deployment, status: :canceled )
create(:deployment, status: :skipped)
is_expected.to contain_exactly(deployment1, deployment2) is_expected.to contain_exactly(deployment1, deployment2)
end end
...@@ -350,6 +376,20 @@ RSpec.describe Deployment do ...@@ -350,6 +376,20 @@ RSpec.describe Deployment do
is_expected.to contain_exactly(with_deployable) is_expected.to contain_exactly(with_deployable)
end end
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 end
describe '#includes_commit?' do 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