Support new syntax
This commit is contained in:
parent
3fc4c096a5
commit
c03631a996
|
@ -186,6 +186,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
after_transition any => [:manual] do |build|
|
after_transition any => [:manual] do |build|
|
||||||
|
puts "#{self.class.name} - #{__callee__}: 1"
|
||||||
build.run_after_commit do
|
build.run_after_commit do
|
||||||
build.schedule_delayed_execution
|
build.schedule_delayed_execution
|
||||||
end
|
end
|
||||||
|
@ -236,22 +237,22 @@ module Ci
|
||||||
action? && (manual? || retryable?)
|
action? && (manual? || retryable?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoplay?
|
def delayed?
|
||||||
manual? && options[:autoplay_in].present?
|
manual? && options[:start_in].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoplay_at
|
def execute_at
|
||||||
ChronicDuration.parse(options[:autoplay_in])&.seconds&.from_now
|
ChronicDuration.parse(options[:start_in])&.seconds&.from_now
|
||||||
end
|
end
|
||||||
|
|
||||||
def schedule_delayed_execution
|
def schedule_delayed_execution
|
||||||
return unless autoplay?
|
return unless delayed?
|
||||||
|
|
||||||
create_build_schedule!(execute_at: autoplay_at)
|
create_build_schedule!(execute_at: execute_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def action?
|
def action?
|
||||||
self.when == 'manual'
|
self.when == 'manual' || self.when == 'delayed'
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: disable CodeReuse/ServiceClass
|
# rubocop: disable CodeReuse/ServiceClass
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Ci
|
||||||
%w[failed]
|
%w[failed]
|
||||||
when 'always'
|
when 'always'
|
||||||
%w[success failed skipped]
|
%w[success failed skipped]
|
||||||
when 'manual'
|
when 'manual', 'delayed'
|
||||||
%w[success skipped]
|
%w[success skipped]
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Gitlab
|
||||||
include Attributable
|
include Attributable
|
||||||
|
|
||||||
ALLOWED_KEYS = %i[tags script only except type image services
|
ALLOWED_KEYS = %i[tags script only except type image services
|
||||||
allow_failure type stage when autoplay_in artifacts cache
|
allow_failure type stage when start_in artifacts cache
|
||||||
dependencies before_script after_script variables
|
dependencies before_script after_script variables
|
||||||
environment coverage retry extends].freeze
|
environment coverage retry extends].freeze
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module Gitlab
|
||||||
greater_than_or_equal_to: 0,
|
greater_than_or_equal_to: 0,
|
||||||
less_than_or_equal_to: 2 }
|
less_than_or_equal_to: 2 }
|
||||||
validates :when,
|
validates :when,
|
||||||
inclusion: { in: %w[on_success on_failure always manual],
|
inclusion: { in: %w[on_success on_failure always manual delayed],
|
||||||
message: 'should be on_success, on_failure, ' \
|
message: 'should be on_success, on_failure, ' \
|
||||||
'always or manual' }
|
'always or manual' }
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ module Gitlab
|
||||||
validates :extends, type: String
|
validates :extends, type: String
|
||||||
|
|
||||||
with_options if: :manual_action? do
|
with_options if: :manual_action? do
|
||||||
validates :autoplay_in, duration: true, allow_nil: true
|
validates :start_in, duration: true, allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
||||||
with_options unless: :manual_action? do
|
with_options unless: :manual_action? do
|
||||||
validates :autoplay_in, presence: false
|
validates :start_in, presence: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ module Gitlab
|
||||||
:artifacts, :commands, :environment, :coverage, :retry
|
:artifacts, :commands, :environment, :coverage, :retry
|
||||||
|
|
||||||
attributes :script, :tags, :allow_failure, :when, :dependencies,
|
attributes :script, :tags, :allow_failure, :when, :dependencies,
|
||||||
:retry, :extends, :autoplay_in
|
:retry, :extends, :start_in
|
||||||
|
|
||||||
def compose!(deps = nil)
|
def compose!(deps = nil)
|
||||||
super do
|
super do
|
||||||
|
@ -119,7 +119,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def manual_action?
|
def manual_action?
|
||||||
self.when == 'manual'
|
self.when == 'manual' || self.when == 'delayed'
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignored?
|
def ignored?
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Gitlab
|
||||||
module Ci
|
module Ci
|
||||||
module Status
|
module Status
|
||||||
module Build
|
module Build
|
||||||
class ManualWithAutoPlay < Status::Extended
|
class Delayed < Status::Extended
|
||||||
###
|
###
|
||||||
# TODO: Those are random values. We have to fix accoding to the UX review
|
# TODO: Those are random values. We have to fix accoding to the UX review
|
||||||
###
|
###
|
||||||
|
@ -43,7 +43,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.matches?(build, user)
|
def self.matches?(build, user)
|
||||||
build.autoplay? && !build.canceled?
|
build.delayed? && !build.canceled?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -5,7 +5,7 @@ module Gitlab
|
||||||
class Factory < Status::Factory
|
class Factory < Status::Factory
|
||||||
def self.extended_statuses
|
def self.extended_statuses
|
||||||
[[Status::Build::Erased,
|
[[Status::Build::Erased,
|
||||||
Status::Build::ManualWithAutoPlay,
|
Status::Build::Delayed,
|
||||||
Status::Build::Manual,
|
Status::Build::Manual,
|
||||||
Status::Build::Canceled,
|
Status::Build::Canceled,
|
||||||
Status::Build::Created,
|
Status::Build::Created,
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Gitlab
|
||||||
after_script: job[:after_script],
|
after_script: job[:after_script],
|
||||||
environment: job[:environment],
|
environment: job[:environment],
|
||||||
retry: job[:retry],
|
retry: job[:retry],
|
||||||
autoplay_in: job[:autoplay_in],
|
start_in: job[:start_in],
|
||||||
}.compact }
|
}.compact }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue