2019-07-25 05:11:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2019-11-13 12:06:22 +00:00
|
|
|
# TODO: we can remove this factory in favour of :ci_pipeline
|
2020-01-09 18:07:52 +00:00
|
|
|
factory :ci_empty_pipeline, class: 'Ci::Pipeline' do
|
2019-10-02 00:06:26 +00:00
|
|
|
source { :push }
|
|
|
|
ref { 'master' }
|
2020-04-14 03:09:39 +00:00
|
|
|
sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
|
2019-10-02 00:06:26 +00:00
|
|
|
status { 'pending' }
|
|
|
|
add_attribute(:protected) { false }
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2015-09-28 11:14:34 +00:00
|
|
|
|
2017-05-19 20:51:07 +00:00
|
|
|
# Persist merge request head_pipeline_id
|
|
|
|
# on pipeline factories to avoid circular references
|
2019-10-02 00:06:26 +00:00
|
|
|
transient { head_pipeline_of { nil } }
|
2017-05-19 20:51:07 +00:00
|
|
|
|
2020-10-13 15:08:53 +00:00
|
|
|
transient { child_of { nil } }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
if evaluator.child_of
|
|
|
|
pipeline.project = evaluator.child_of.project
|
|
|
|
pipeline.source = :parent_pipeline
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-19 20:51:07 +00:00
|
|
|
after(:create) do |pipeline, evaluator|
|
|
|
|
merge_request = evaluator.head_pipeline_of
|
2020-07-21 12:09:30 +00:00
|
|
|
merge_request&.update!(head_pipeline: pipeline)
|
2020-10-13 15:08:53 +00:00
|
|
|
|
|
|
|
if evaluator.child_of
|
|
|
|
bridge = create(:ci_bridge, pipeline: evaluator.child_of)
|
|
|
|
create(:ci_sources_pipeline,
|
|
|
|
source_job: bridge,
|
|
|
|
pipeline: pipeline)
|
|
|
|
end
|
2017-05-19 20:51:07 +00:00
|
|
|
end
|
|
|
|
|
2016-06-03 14:22:26 +00:00
|
|
|
factory :ci_pipeline do
|
2020-06-10 09:08:35 +00:00
|
|
|
transient { ci_ref_presence { true } }
|
|
|
|
|
2020-09-28 18:09:40 +00:00
|
|
|
before(:create) do |pipeline, evaluator|
|
2020-06-10 09:08:35 +00:00
|
|
|
pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil?
|
|
|
|
end
|
|
|
|
|
2017-01-04 11:48:24 +00:00
|
|
|
trait :invalid do
|
2020-02-24 18:09:05 +00:00
|
|
|
status { :failed }
|
2019-11-13 12:06:22 +00:00
|
|
|
yaml_errors { 'invalid YAML' }
|
2019-10-02 00:06:26 +00:00
|
|
|
failure_reason { :config_error }
|
2017-01-04 11:48:24 +00:00
|
|
|
end
|
2017-03-08 10:44:36 +00:00
|
|
|
|
2019-02-27 02:13:06 +00:00
|
|
|
trait :created do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :created }
|
2019-02-27 02:13:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :preparing do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :preparing }
|
2019-02-27 02:13:06 +00:00
|
|
|
end
|
|
|
|
|
2017-03-08 10:44:36 +00:00
|
|
|
trait :blocked do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :manual }
|
2017-03-08 10:44:36 +00:00
|
|
|
end
|
|
|
|
|
2018-10-03 06:28:17 +00:00
|
|
|
trait :scheduled do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :scheduled }
|
2018-10-03 06:28:17 +00:00
|
|
|
end
|
|
|
|
|
2017-03-08 10:44:36 +00:00
|
|
|
trait :success do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :success }
|
2017-03-08 10:44:36 +00:00
|
|
|
end
|
2017-03-30 11:29:52 +00:00
|
|
|
|
2018-08-02 06:05:07 +00:00
|
|
|
trait :running do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :running }
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
|
2017-03-30 11:29:52 +00:00
|
|
|
trait :failed do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :failed }
|
2017-03-30 11:29:52 +00:00
|
|
|
end
|
2017-08-31 12:13:40 +00:00
|
|
|
|
|
|
|
trait :protected do
|
2019-10-02 00:06:26 +00:00
|
|
|
add_attribute(:protected) { true }
|
2017-08-31 12:13:40 +00:00
|
|
|
end
|
2018-08-02 06:05:07 +00:00
|
|
|
|
2020-06-19 18:08:39 +00:00
|
|
|
trait :with_report_results do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :report_results, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-17 06:09:11 +00:00
|
|
|
trait :with_codequality_report do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :codequality_report, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-03 11:08:13 +00:00
|
|
|
trait :with_test_reports do
|
2019-10-02 00:06:26 +00:00
|
|
|
status { :success }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
2018-08-03 11:08:13 +00:00
|
|
|
pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project)
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
2018-09-06 19:20:42 +00:00
|
|
|
|
2020-04-03 06:09:14 +00:00
|
|
|
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-04-21 15:21:10 +00:00
|
|
|
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)
|
2020-05-07 09:09:51 +00:00
|
|
|
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)
|
2020-04-21 15:21:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-17 18:09:44 +00:00
|
|
|
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-08-25 12:04:30 +00:00
|
|
|
trait :with_coverage_report_artifact do
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
trait :with_terraform_reports do
|
|
|
|
status { :success }
|
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, :terraform_reports, pipeline: pipeline, project: pipeline.project)
|
2020-06-10 15:08:07 +00:00
|
|
|
pipeline.builds << build(:ci_build, :terraform_reports, pipeline: pipeline, project: pipeline.project)
|
2020-04-21 15:21:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-21 15:05:58 +00:00
|
|
|
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-03-12 16:05:29 +00:00
|
|
|
trait :with_job do
|
|
|
|
after(:build) do |pipeline, evaluator|
|
|
|
|
pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-06 19:20:42 +00:00
|
|
|
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-03-30 18:08:07 +00:00
|
|
|
|
|
|
|
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
|
2020-05-25 15:07:58 +00:00
|
|
|
|
|
|
|
trait :webide do
|
|
|
|
source { :webide }
|
|
|
|
config_source { :webide_source }
|
|
|
|
end
|
2016-11-25 14:11:56 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|