debian-mirror-gitlab/app/presenters/commit_status_presenter.rb

41 lines
1.8 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
CALLOUT_FAILURE_MESSAGES = {
2018-11-18 11:00:15 +05:30
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-12-05 23:21:45 +05:30
runner_unsupported: 'Your runner is outdated, please upgrade your runner',
2018-12-13 13:39:08 +05:30
stale_schedule: 'Delayed job could not be executed by some reason, please try again',
job_execution_timeout: 'The script exceeded the maximum execution time set for the job',
2019-07-07 11:18:12 +05:30
archived_failure: 'The job is archived and cannot be run',
2019-12-26 22:10:19 +05:30
unmet_prerequisites: 'The job failed to complete prerequisite tasks',
scheduler_failure: 'The scheduler failed to assign job to the runner, please try again or contact system administrator',
data_integrity_failure: 'There has been a structural integrity problem detected, please contact system administrator'
2018-10-15 14:42:47 +05:30
}.freeze
2018-11-20 20:47:30 +05:30
private_constant :CALLOUT_FAILURE_MESSAGES
2018-10-15 14:42:47 +05:30
presents :build
2019-12-04 20:38:33 +05:30
prepend_if_ee('::EE::CommitStatusPresenter') # rubocop: disable Cop/InjectEnterpriseEditionModule
2018-11-20 20:47:30 +05:30
def self.callout_failure_messages
CALLOUT_FAILURE_MESSAGES
end
2018-10-15 14:42:47 +05:30
def callout_failure_message
2018-11-20 20:47:30 +05:30
self.class.callout_failure_messages.fetch(failure_reason.to_sym)
2018-10-15 14:42:47 +05:30
end
def recoverable?
failed? && !unrecoverable?
end
def unrecoverable?
2019-12-26 22:10:19 +05:30
script_failure? || missing_dependency_failure? || archived_failure? || scheduler_failure? || data_integrity_failure?
2018-10-15 14:42:47 +05:30
end
end