2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-16 16:58:20 -04:00
|
|
|
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
|
|
|
|
CALLOUT_FAILURE_MESSAGES = {
|
2018-07-30 11:05:50 -04:00
|
|
|
unknown_failure: 'There is an unknown failure, please try again',
|
|
|
|
script_failure: nil,
|
|
|
|
api_failure: 'There has been an API failure, please try again',
|
|
|
|
stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again',
|
|
|
|
runner_system_failure: 'There has been a runner system failure, please try again',
|
|
|
|
missing_dependency_failure: 'There has been a missing dependency failure',
|
2018-09-26 01:43:03 -04:00
|
|
|
runner_unsupported: 'Your runner is outdated, please upgrade your runner',
|
2018-10-28 14:31:08 -04:00
|
|
|
stale_schedule: 'Delayed job could not be executed by some reason, please try again',
|
2018-10-23 06:58:41 -04:00
|
|
|
job_execution_timeout: 'The script exceeded the maximum execution time set for the job',
|
2019-03-03 18:56:20 -05:00
|
|
|
archived_failure: 'The job is archived and cannot be run',
|
|
|
|
unmet_prerequisites: 'The job failed to complete prerequisite tasks'
|
2018-05-16 16:58:20 -04:00
|
|
|
}.freeze
|
|
|
|
|
2018-09-05 16:46:13 -04:00
|
|
|
private_constant :CALLOUT_FAILURE_MESSAGES
|
|
|
|
|
2018-05-16 16:58:20 -04:00
|
|
|
presents :build
|
|
|
|
|
2018-09-05 16:46:13 -04:00
|
|
|
def self.callout_failure_messages
|
|
|
|
CALLOUT_FAILURE_MESSAGES
|
|
|
|
end
|
|
|
|
|
2018-05-16 16:58:20 -04:00
|
|
|
def callout_failure_message
|
2018-09-05 16:46:13 -04:00
|
|
|
self.class.callout_failure_messages.fetch(failure_reason.to_sym)
|
2018-05-16 16:58:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def recoverable?
|
|
|
|
failed? && !unrecoverable?
|
|
|
|
end
|
|
|
|
|
|
|
|
def unrecoverable?
|
2018-10-23 06:58:41 -04:00
|
|
|
script_failure? || missing_dependency_failure? || archived_failure?
|
2018-05-16 16:58:20 -04:00
|
|
|
end
|
2018-05-15 14:03:09 -04:00
|
|
|
end
|