Commit e265fc3e authored by Shinya Maeda's avatar Shinya Maeda Committed by Alessio Caiazza

Rename delayed to scheduled

parent a5d296e9
...@@ -186,9 +186,8 @@ module Ci ...@@ -186,9 +186,8 @@ 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
end end
end end
...@@ -237,22 +236,30 @@ module Ci ...@@ -237,22 +236,30 @@ module Ci
action? && (manual? || retryable?) action? && (manual? || retryable?)
end end
def delayed? def schedulable?
manual? && options[:start_in].present? manual? && options[:start_in].present?
end end
def execute_at def scheduled?
ChronicDuration.parse(options[:start_in])&.seconds&.from_now build.build_schedule.exist?
end end
def schedule_delayed_execution def schedule
return unless delayed? return unless schedulable?
create_build_schedule!(execute_at: execute_at) create_build_schedule!(execute_at: execute_at)
end end
def unschedule
build&.build_schedule&.delete
end
def execute_at
ChronicDuration.parse(options[:start_in])&.seconds&.from_now
end
def action? def action?
self.when == 'manual' || self.when == 'delayed' %w[manual delayed].include?(self.when)
end end
# rubocop: disable CodeReuse/ServiceClass # rubocop: disable CodeReuse/ServiceClass
......
...@@ -9,7 +9,6 @@ class BuildFinishedWorker ...@@ -9,7 +9,6 @@ class BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
build&.build_schedule&.delete
# We execute that in sync as this access the files in order to access local file, and reduce IO # We execute that in sync as this access the files in order to access local file, and reduce IO
BuildTraceSectionsWorker.new.perform(build.id) BuildTraceSectionsWorker.new.perform(build.id)
BuildCoverageWorker.new.perform(build.id) BuildCoverageWorker.new.perform(build.id)
......
...@@ -9,7 +9,11 @@ module Ci ...@@ -9,7 +9,11 @@ module Ci
::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build| ::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build|
break unless build.build_schedule.present? break unless build.build_schedule.present?
Ci::PlayBuildService.new(build.project, build.user).execute(build) begin
Ci::PlayBuildService.new(build.project, build.user).execute(build)
ensure
build.unschedule
end
end end
end end
end end
......
...@@ -119,7 +119,7 @@ module Gitlab ...@@ -119,7 +119,7 @@ module Gitlab
end end
def manual_action? def manual_action?
self.when == 'manual' || self.when == 'delayed' %w[manual delayed].include?(self.when)
end end
def ignored? def ignored?
......
...@@ -5,7 +5,7 @@ module Gitlab ...@@ -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::Delayed, Status::Build::Scheduled,
Status::Build::Manual, Status::Build::Manual,
Status::Build::Canceled, Status::Build::Canceled,
Status::Build::Created, Status::Build::Created,
......
...@@ -2,11 +2,7 @@ module Gitlab ...@@ -2,11 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Delayed < Status::Extended class Scheduled < Status::Extended
###
# TODO: Those are random values. We have to fix accoding to the UX review
###
### ###
# Core override # Core override
### ###
...@@ -23,7 +19,7 @@ module Gitlab ...@@ -23,7 +19,7 @@ module Gitlab
end end
def favicon def favicon
'favicon_status_manual_with_auto_play' 'favicon_status_scheduled'
end end
### ###
...@@ -33,17 +29,23 @@ module Gitlab ...@@ -33,17 +29,23 @@ module Gitlab
{ {
image: 'illustrations/canceled-job_empty.svg', image: 'illustrations/canceled-job_empty.svg',
size: 'svg-394', size: 'svg-394',
title: _('This job is a scheduled job with manual actions!'), title: _("This is a scheduled to run in ") + " #{execute_in}",
content: _('auto playyyyyyyyyyyyyy! This job depends on a user to trigger its process. Often they are used to deploy code to production environments') content: _("This job will automatically run after it's timer finishes. Often they are used for incremental roll-out deploys to production environments. When unscheduled it converts into a manual action.")
} }
end end
def status_tooltip def status_tooltip
@status.status_tooltip + " (scheulded) : Execute in #{subject.build_schedule.execute_in.round} sec" "scheduled manual action (#{execute_in})"
end end
def self.matches?(build, user) def self.matches?(build, user)
build.delayed? && !build.canceled? build.schedulable? && !build.canceled?
end
private
def execute_in
Time.at(subject.build_schedule.execute_in).utc.strftime("%H:%M:%S")
end 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