Class: CommitStatus

Inherits:
Ci::ApplicationRecord show all
Includes:
AfterCommitQueue, BulkInsertableAssociations, Ci::HasStatus, Ci::Partitionable, Importable, Presentable
Defined in:
app/models/commit_status.rb

Direct Known Subclasses

Ci::Processable, GenericCommitStatus

Constant Summary

Constants included from Ci::HasStatus

Ci::HasStatus::ACTIVE_STATUSES, Ci::HasStatus::ALIVE_STATUSES, Ci::HasStatus::AVAILABLE_STATUSES, Ci::HasStatus::BLOCKED_STATUS, Ci::HasStatus::CANCELABLE_STATUSES, Ci::HasStatus::COMPLETED_STATUSES, Ci::HasStatus::COMPLETED_WITH_MANUAL_STATUSES, Ci::HasStatus::DEFAULT_STATUS, Ci::HasStatus::EXECUTING_STATUSES, Ci::HasStatus::IGNORED_STATUSES, Ci::HasStatus::ORDERED_STATUSES, Ci::HasStatus::PASSED_WITH_WARNINGS_STATUSES, Ci::HasStatus::STARTED_STATUSES, Ci::HasStatus::STATUSES_ENUM, Ci::HasStatus::STOPPED_STATUSES, Ci::HasStatus::UnknownStatusError

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Attribute Summary

Attributes included from Importable

#importing, #user_contributions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BulkInsertableAssociations

#bulk_insert_associations!, bulk_inserts_enabled?, with_bulk_insert

Methods included from Presentable

#present

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods included from Ci::HasStatus

#active?, #blocked?, #complete?, #complete_or_manual?, #incomplete?, #started?

Methods included from Ci::Partitionable

registered_models

Methods inherited from Ci::ApplicationRecord

model_name, table_name_prefix

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.locking_enabled?Boolean

Returns:

  • (Boolean)


253
254
255
# File 'app/models/commit_status.rb', line 253

def self.locking_enabled?
  false
end

.namesObject



242
243
244
# File 'app/models/commit_status.rb', line 242

def self.names
  select(:name)
end

.update_as_processed!Object



246
247
248
249
250
251
# File 'app/models/commit_status.rb', line 246

def self.update_as_processed!
  # Marks items as processed
  # we do not increase `lock_version`, as we are the one
  # holding given lock_version (Optimisitc Locking)
  update_all(processed: true)
end

Instance Method Details

#all_met_to_become_pending?Boolean

Returns:

  • (Boolean)


315
316
317
# File 'app/models/commit_status.rb', line 315

def all_met_to_become_pending?
  true
end

#archived?Boolean

Returns:

  • (Boolean)


303
304
305
# File 'app/models/commit_status.rb', line 303

def archived?(...)
  pipeline.archived?(...)
end

#auto_canceled?Boolean

Returns:

  • (Boolean)


319
320
321
# File 'app/models/commit_status.rb', line 319

def auto_canceled?
  canceled? && auto_canceled_by_id?
end

#cancelable?Boolean

Returns:

  • (Boolean)


295
296
297
# File 'app/models/commit_status.rb', line 295

def cancelable?
  false
end

#detailed_status(current_user) ⇒ Object



323
324
325
326
327
# File 'app/models/commit_status.rb', line 323

def detailed_status(current_user)
  Gitlab::Ci::Status::Factory
    .new(self, current_user)
    .fabricate!
end

#durationObject

Time spent running.



274
275
276
# File 'app/models/commit_status.rb', line 274

def duration
  calculate_duration(started_at, finished_at)
end

#exit_code=(value) ⇒ Object

Handled only by ci_build



362
# File 'app/models/commit_status.rb', line 362

def exit_code=(value); end

#expire_etag_cache!Object



348
349
350
351
352
# File 'app/models/commit_status.rb', line 348

def expire_etag_cache!
  job_path = Gitlab::Routing.url_helpers.project_build_path(project, id, format: :json)

  Gitlab::EtagCaching::Store.new.touch(job_path)
end

#force_cancelable?Boolean

Returns:

  • (Boolean)


299
300
301
# File 'app/models/commit_status.rb', line 299

def force_cancelable?
  false
end

#group_nameObject



261
262
263
# File 'app/models/commit_status.rb', line 261

def group_name
  Gitlab::Utils::Job.group_name(name)
end

#has_trace?Boolean

Returns:

  • (Boolean)


311
312
313
# File 'app/models/commit_status.rb', line 311

def has_trace?
  false
end

#latest?Boolean

Returns:

  • (Boolean)


283
284
285
# File 'app/models/commit_status.rb', line 283

def latest?
  !retried?
end

#locking_enabled?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'app/models/commit_status.rb', line 257

def locking_enabled?
  will_save_change_to_status?
end

#playable?Boolean

Returns:

  • (Boolean)


287
288
289
# File 'app/models/commit_status.rb', line 287

def playable?
  false
end

#queued_durationObject

Time spent in the pending state.



279
280
281
# File 'app/models/commit_status.rb', line 279

def queued_duration
  calculate_duration(queued_at, started_at || finished_at)
end

#recoverable?Boolean

Returns:

  • (Boolean)


335
336
337
# File 'app/models/commit_status.rb', line 335

def recoverable?
  failed? && !unrecoverable_failure?
end

#resource_parentObject

For AiAction



374
375
376
# File 'app/models/commit_status.rb', line 374

def resource_parent
  project
end

#retryable?Boolean

Returns:

  • (Boolean)


291
292
293
# File 'app/models/commit_status.rb', line 291

def retryable?
  false
end

#sortable_nameObject



329
330
331
332
333
# File 'app/models/commit_status.rb', line 329

def sortable_name
  name.to_s.split(/(\d+)/).map do |v|
    /\d+/.match?(v) ? v.to_i : v
  end
end

#stage_nameObject Also known as: stage



354
355
356
# File 'app/models/commit_status.rb', line 354

def stage_name
  ci_stage&.name
end

#stuck?Boolean

Returns:

  • (Boolean)


307
308
309
# File 'app/models/commit_status.rb', line 307

def stuck?
  false
end

#supports_canceling?Boolean

Returns:

  • (Boolean)


265
266
267
# File 'app/models/commit_status.rb', line 265

def supports_canceling?
  false
end

#supports_force_cancel?Boolean

Returns:

  • (Boolean)


269
270
271
# File 'app/models/commit_status.rb', line 269

def supports_force_cancel?
  false
end

#test_suite_nameObject



369
370
371
# File 'app/models/commit_status.rb', line 369

def test_suite_name
  nil
end

#to_ability_nameObject

For AiAction



365
366
367
# File 'app/models/commit_status.rb', line 365

def to_ability_name
  'build'
end

#update_older_statuses_retried!Object



339
340
341
342
343
344
345
346
# File 'app/models/commit_status.rb', line 339

def update_older_statuses_retried!
  pipeline
    .statuses
    .latest
    .where(name: name)
    .where.not(id: id)
    .update_all(retried: true, processed: true)
end