Class: Gitlab::Ci::Status::Composite
- Inherits:
-
Object
- Object
- Gitlab::Ci::Status::Composite
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/status/composite.rb
Instance Method Summary collapse
-
#initialize(all_jobs, with_allow_failure: true, dag: false, project: nil) ⇒ Composite
constructor
This class accepts an array of arrays/hashes/or objects ‘with_allow_failure` will be removed when deleting ci_remove_ensure_stage_service.
-
#status ⇒ Object
The status calculation is order dependent, 1.
-
#warnings? ⇒ Boolean
rubocop: enable Metrics/CyclomaticComplexity rubocop: enable Metrics/PerceivedComplexity.
Constructor Details
#initialize(all_jobs, with_allow_failure: true, dag: false, project: nil) ⇒ Composite
This class accepts an array of arrays/hashes/or objects ‘with_allow_failure` will be removed when deleting ci_remove_ensure_stage_service
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab/ci/status/composite.rb', line 11 def initialize(all_jobs, with_allow_failure: true, dag: false, project: nil) unless all_jobs.respond_to?(:pluck) raise ArgumentError, "all_jobs needs to respond to `.pluck`" end @status_set = Set.new @status_key = 0 @allow_failure_key = 1 if with_allow_failure @dag = dag @project = project consume_all_jobs(all_jobs) end |
Instance Method Details
#status ⇒ Object
The status calculation is order dependent,
-
In some cases we assume that that status is exact if the we only have given statues,
-
In other cases we assume that status is of that type based on what statuses are no longer valid based on the data set that we have
This method is used for three cases:
-
When it is called for a stage or a pipeline (with ‘all_jobs` from all jobs in a stage or a pipeline), then, the returned status is assigned to the stage or pipeline.
-
When it is called for a job (with ‘all_jobs` from all previous jobs or all needed jobs), then, the returned status is used to determine if the job is processed or not.
-
When it is called for a group (of jobs that are related), then, the returned status is used to show the overall status of the group.
rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/PerceivedComplexity
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gitlab/ci/status/composite.rb', line 41 def status return if none? strong_memoize(:status) do if @dag && any_skipped_or_ignored? # The DAG job is skipped if one of the needs does not run at all. 'skipped' elsif only_of?(:skipped, :ignored) 'skipped' elsif only_of?(:success, :skipped, :success_with_warnings, :ignored) 'success' elsif only_of?(:created, :success_with_warnings, :ignored) 'created' elsif only_of?(:preparing, :success_with_warnings, :ignored) 'preparing' elsif only_of?(:canceled, :success, :skipped, :success_with_warnings, :ignored) 'canceled' elsif only_of?(:pending, :created, :skipped, :success_with_warnings, :ignored) 'pending' elsif any_of?(:running, :pending) 'running' elsif any_of?(:waiting_for_resource) 'waiting_for_resource' elsif any_of?(:waiting_for_callback) 'waiting_for_callback' elsif any_of?(:manual) 'manual' elsif any_of?(:scheduled) 'scheduled' elsif any_of?(:preparing) 'preparing' elsif any_of?(:created) 'running' elsif any_of?(:canceling) 'canceling' else 'failed' end end end |
#warnings? ⇒ Boolean
rubocop: enable Metrics/CyclomaticComplexity rubocop: enable Metrics/PerceivedComplexity
84 85 86 |
# File 'lib/gitlab/ci/status/composite.rb', line 84 def warnings? @status_set.include?(:success_with_warnings) end |