Module: Ci::HasStatus

Extended by:
ActiveSupport::Concern
Included in:
Pipeline, Stage, CommitStatus
Defined in:
app/models/concerns/ci/has_status.rb

Constant Summary collapse

DEFAULT_STATUS =
'created'
BLOCKED_STATUS =
%w[manual scheduled].freeze
AVAILABLE_STATUSES =
%w[
  created
  waiting_for_resource
  preparing
  waiting_for_callback
  pending
  running
  success
  failed
  canceling
  canceled
  skipped
  manual
  scheduled
].freeze
STARTED_STATUSES =
%w[running success failed].freeze
ACTIVE_STATUSES =
%w[waiting_for_resource preparing waiting_for_callback pending running].freeze
COMPLETED_STATUSES =
%w[success failed canceled skipped].freeze
COMPLETED_WITH_MANUAL_STATUSES =
COMPLETED_STATUSES + %w[manual]
STOPPED_STATUSES =
COMPLETED_STATUSES + BLOCKED_STATUS
ORDERED_STATUSES =
%w[
  failed
  preparing
  pending
  running
  waiting_for_callback
  waiting_for_resource
  manual
  scheduled
  canceling
  canceled
  success
  skipped
  created
].freeze
PASSED_WITH_WARNINGS_STATUSES =
%w[failed canceled].to_set.freeze
IGNORED_STATUSES =
%w[manual].to_set.freeze
EXECUTING_STATUSES =
%w[running canceling].freeze
ALIVE_STATUSES =
ORDERED_STATUSES - COMPLETED_STATUSES - BLOCKED_STATUS
CANCELABLE_STATUSES =
(ALIVE_STATUSES + ['scheduled'] - ['canceling']).freeze
STATUSES_ENUM =
{ created: 0, pending: 1, running: 2, success: 3,
failed: 4, canceled: 5, skipped: 6, manual: 7,
scheduled: 8, preparing: 9, waiting_for_resource: 10,
waiting_for_callback: 11, canceling: 12 }.freeze
UnknownStatusError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'app/models/concerns/ci/has_status.rb', line 146

def active?
  ACTIVE_STATUSES.include?(status)
end

#blocked?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'app/models/concerns/ci/has_status.rb', line 162

def blocked?
  BLOCKED_STATUS.include?(status)
end

#complete?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'app/models/concerns/ci/has_status.rb', line 150

def complete?
  COMPLETED_STATUSES.include?(status)
end

#complete_or_manual?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'app/models/concerns/ci/has_status.rb', line 154

def complete_or_manual?
  COMPLETED_WITH_MANUAL_STATUSES.include?(status)
end

#incomplete?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'app/models/concerns/ci/has_status.rb', line 158

def incomplete?
  COMPLETED_STATUSES.exclude?(status)
end

#started?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'app/models/concerns/ci/has_status.rb', line 142

def started?
  STARTED_STATUSES.include?(status) && !!started_at
end