Class: Gitlab::Ci::Pipeline::Seed::Stage

Inherits:
Base
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/pipeline/seed/stage.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, attributes, previous_stages) ⇒ Stage

Returns a new instance of Stage.



13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 13

def initialize(context, attributes, previous_stages)
  @context = context
  @pipeline = context.pipeline
  @attributes = attributes
  @previous_stages = previous_stages

  @builds = attributes.fetch(:builds).map do |attributes|
    Seed::Build.new(context, attributes, previous_stages + [self])
  end
end

Instance Method Details

#attributesObject



24
25
26
27
28
29
30
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 24

def attributes
  { name: @attributes.fetch(:name),
    position: @attributes.fetch(:index),
    pipeline: @pipeline,
    project: @pipeline.project,
    partition_id: @pipeline.partition_id }
end

#errorsObject



37
38
39
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 37

def errors
  @builds.flat_map(&:errors).compact
end

#included?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 47

def included?
  seeds.any?
end

#seedsObject



32
33
34
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 32

def seeds
  @builds.select(&:included?)
end

#seeds_namesObject



42
43
44
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 42

def seeds_names
  seeds.map(&:name).to_set
end

#to_resourceObject



51
52
53
54
55
# File 'lib/gitlab/ci/pipeline/seed/stage.rb', line 51

def to_resource
  ::Ci::Stage.new(attributes).tap do |stage|
    stage.statuses = seeds.map(&:to_resource)
  end
end