2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2019-12-26 22:10:19 +05:30
|
|
|
# TODO: we can remove this factory in favour of :ci_pipeline
|
2020-03-13 15:44:24 +05:30
|
|
|
factory :ci_empty_pipeline, class: 'Ci::Pipeline' do
|
2019-12-21 20:55:43 +05:30
|
|
|
source { :push }
|
|
|
|
ref { 'master' }
|
2020-04-22 19:07:51 +05:30
|
|
|
sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'pending' }
|
|
|
|
add_attribute(: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
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
# Persist merge request head_pipeline_id
|
|
|
|
# on pipeline factories to avoid circular references
|
2019-12-21 20:55:43 +05:30
|
|
|
transient { head_pipeline_of { nil } }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
trait :invalid do
|
2020-04-08 14:13:33 +05:30
|
|
|
status { :failed }
|
2019-12-26 22:10:19 +05:30
|
|
|
yaml_errors { 'invalid YAML' }
|
2019-12-21 20:55:43 +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
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :created }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :preparing do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :preparing }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :blocked do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :manual }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
trait :scheduled do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :scheduled }
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :success do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :success }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
trait :running do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :running }
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :failed do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :failed }
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
trait :protected do
|
2019-12-21 20:55:43 +05:30
|
|
|
add_attribute(:protected) { true }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
trait :with_test_reports do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { :success }
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
trait :with_test_reports_attachment do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :test_reports_with_attachment, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
trait :with_broken_test_reports do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, _evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :broken_test_reports, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_accessibility_reports do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :accessibility_reports, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
trait :with_coverage_reports do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :coverage_reports, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
trait :with_terraform_reports do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :terraform_reports, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
trait :with_exposed_artifacts do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :artifacts,
|
|
|
|
pipeline: pipeline,
|
|
|
|
project: pipeline.project,
|
|
|
|
options: { artifacts: { expose_as: 'the artifact', paths: ['ci_artifacts.txt'] } })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
trait :detached_merge_request_pipeline do
|
|
|
|
merge_request
|
|
|
|
|
|
|
|
source { :merge_request_event }
|
|
|
|
project { merge_request.source_project }
|
|
|
|
sha { merge_request.source_branch_sha }
|
|
|
|
ref { merge_request.ref_path }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :legacy_detached_merge_request_pipeline do
|
|
|
|
detached_merge_request_pipeline
|
|
|
|
|
|
|
|
ref { merge_request.source_branch }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :merged_result_pipeline do
|
|
|
|
detached_merge_request_pipeline
|
|
|
|
|
|
|
|
sha { 'test-merge-sha'}
|
|
|
|
ref { merge_request.merge_ref_path }
|
|
|
|
source_sha { merge_request.source_branch_sha }
|
|
|
|
target_sha { merge_request.target_branch_sha }
|
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|