2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2016-06-16 23:09:34 +05:30
|
|
|
factory :ci_empty_pipeline, class: Ci::Pipeline do
|
2017-09-10 17:25:29 +05:30
|
|
|
source :push
|
2016-09-13 17:45:13 +05:30
|
|
|
ref 'master'
|
2015-09-25 12:07:36 +05:30
|
|
|
sha '97de212e80737a608d939f648d959671fb0a0142'
|
2016-09-13 17:45:13 +05:30
|
|
|
status 'pending'
|
2018-03-17 18:26:18 +05:30
|
|
|
protected false
|
2015-10-24 18:46:33 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
factory :ci_pipeline_without_jobs do
|
2017-08-17 22:00:37 +05:30
|
|
|
after(:build) do |pipeline|
|
2017-09-10 17:25:29 +05:30
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({}))
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
factory :ci_pipeline_with_one_job do
|
2017-08-17 22:00:37 +05:30
|
|
|
after(:build) do |pipeline|
|
|
|
|
allow(pipeline).to receive(:ci_yaml_file) do
|
2017-09-10 17:25:29 +05:30
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } }))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
# Persist merge request head_pipeline_id
|
|
|
|
# on pipeline factories to avoid circular references
|
|
|
|
transient { head_pipeline_of nil }
|
|
|
|
|
|
|
|
after(:create) do |pipeline, evaluator|
|
|
|
|
merge_request = evaluator.head_pipeline_of
|
|
|
|
merge_request&.update(head_pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
factory :ci_pipeline do
|
|
|
|
transient { config nil }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
2017-09-10 17:25:29 +05:30
|
|
|
if evaluator.config
|
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config))
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
# Populates pipeline with errors
|
|
|
|
pipeline.config_processor if evaluator.config
|
|
|
|
else
|
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
|
|
|
|
end
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :invalid do
|
|
|
|
config(rspec: nil)
|
2018-03-17 18:26:18 +05:30
|
|
|
failure_reason :config_error
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
trait :created do
|
|
|
|
status :created
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :preparing do
|
|
|
|
status :preparing
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :blocked do
|
|
|
|
status :manual
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
trait :scheduled do
|
|
|
|
status :scheduled
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :success do
|
|
|
|
status :success
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
trait :running do
|
|
|
|
status :running
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :failed do
|
|
|
|
status :failed
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
trait :protected do
|
|
|
|
protected true
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
trait :with_test_reports do
|
|
|
|
status :success
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2019-05-03 19:53:19 +05:30
|
|
|
trait :with_job do
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
trait :auto_devops_source do
|
|
|
|
config_source { Ci::Pipeline.config_sources[:auto_devops_source] }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :repository_source do
|
|
|
|
config_source { Ci::Pipeline.config_sources[:repository_source] }
|
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|