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
end
after_transition any => [:manual] do |build|
puts "#{self.class.name} - #{__callee__}: 1"
build.run_after_commit do
build.schedule_delayed_execution
build.schedule
end
end
......@@ -237,22 +236,30 @@ module Ci
action? && (manual? || retryable?)
end
def delayed?
def schedulable?
manual? && options[:start_in].present?
end
def execute_at
ChronicDuration.parse(options[:start_in])&.seconds&.from_now
def scheduled?
build.build_schedule.exist?
end
def schedule_delayed_execution
return unless delayed?
def schedule
return unless schedulable?
create_build_schedule!(execute_at: execute_at)
end
def unschedule
build&.build_schedule&.delete
end
def execute_at
ChronicDuration.parse(options[:start_in])&.seconds&.from_now
end
def action?
self.when == 'manual' || self.when == 'delayed'
%w[manual delayed].include?(self.when)
end
# rubocop: disable CodeReuse/ServiceClass
......
......@@ -9,7 +9,6 @@ class BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
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
BuildTraceSectionsWorker.new.perform(build.id)
BuildCoverageWorker.new.perform(build.id)
......
......@@ -9,7 +9,11 @@ module Ci
::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build|
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
......
......@@ -119,7 +119,7 @@ module Gitlab
end
def manual_action?
self.when == 'manual' || self.when == 'delayed'
%w[manual delayed].include?(self.when)
end
def ignored?
......
......@@ -5,7 +5,7 @@ module Gitlab
class Factory < Status::Factory
def self.extended_statuses
[[Status::Build::Erased,
Status::Build::Delayed,
Status::Build::Scheduled,
Status::Build::Manual,
Status::Build::Canceled,
Status::Build::Created,
......
......@@ -2,11 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class Delayed < Status::Extended
###
# TODO: Those are random values. We have to fix accoding to the UX review
###
class Scheduled < Status::Extended
###
# Core override
###
......@@ -23,7 +19,7 @@ module Gitlab
end
def favicon
'favicon_status_manual_with_auto_play'
'favicon_status_scheduled'
end
###
......@@ -33,17 +29,23 @@ module Gitlab
{
image: 'illustrations/canceled-job_empty.svg',
size: 'svg-394',
title: _('This job is a scheduled job with manual actions!'),
content: _('auto playyyyyyyyyyyyyy! This job depends on a user to trigger its process. Often they are used to deploy code to production environments')
title: _("This is a scheduled to run in ") + " #{execute_in}",
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
def status_tooltip
@status.status_tooltip + " (scheulded) : Execute in #{subject.build_schedule.execute_in.round} sec"
"scheduled manual action (#{execute_in})"
end
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
......
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