2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2021-03-11 19:13:27 +05:30
|
|
|
factory :ci_build, class: 'Ci::Build', parent: :ci_processable do
|
2019-12-21 20:55:43 +05:30
|
|
|
name { 'test' }
|
|
|
|
add_attribute(:protected) { false }
|
|
|
|
created_at { 'Di 29. Okt 09:50:00 CET 2013' }
|
2022-01-26 12:08:38 +05:30
|
|
|
scheduling_type { 'stage' }
|
2018-03-17 18:26:18 +05:30
|
|
|
pending
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
options do
|
|
|
|
{
|
2022-06-21 17:19:12 +05:30
|
|
|
image: 'image:1.0',
|
2019-02-15 15:39:39 +05:30
|
|
|
services: ['postgres'],
|
|
|
|
script: ['ls -a']
|
2015-09-25 12:07:36 +05:30
|
|
|
}
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
yaml_variables do
|
|
|
|
[
|
2017-08-17 22:00:37 +05:30
|
|
|
{ key: 'DB_NAME', value: 'postgres', public: true }
|
2016-08-24 12:49:21 +05:30
|
|
|
]
|
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
project { pipeline.project }
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
trait :with_token do
|
|
|
|
transient do
|
|
|
|
generate_token { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |build, evaluator|
|
|
|
|
build.ensure_token if evaluator.generate_token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
trait :degenerated do
|
2019-12-21 20:55:43 +05:30
|
|
|
options { nil }
|
|
|
|
yaml_variables { nil }
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
trait :unique_name do
|
|
|
|
name { generate(:job_name) }
|
|
|
|
end
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
trait :matrix do
|
|
|
|
sequence(:name) { |n| "job: [#{n}]" }
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
parallel: {
|
|
|
|
total: 2,
|
|
|
|
matrix: [{ ID: %w[1 2] }]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
trait :dependent do
|
2022-01-26 12:08:38 +05:30
|
|
|
scheduling_type { 'dag' }
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
transient do
|
|
|
|
sequence(:needed_name) { |n| "dependency #{n}" }
|
|
|
|
needed { association(:ci_build, name: needed_name, pipeline: pipeline) }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
build.needs << create(:ci_build_need, build: build, name: evaluator.needed.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :started do
|
2019-12-21 20:55:43 +05:30
|
|
|
started_at { 'Di 29. Okt 09:51:28 CET 2013' }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :finished do
|
|
|
|
started
|
2019-12-21 20:55:43 +05:30
|
|
|
finished_at { 'Di 29. Okt 09:53:28 CET 2013' }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
trait :success do
|
2018-03-17 18:26:18 +05:30
|
|
|
finished
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'success' }
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :failed do
|
2018-03-17 18:26:18 +05:30
|
|
|
finished
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'failed' }
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
trait :canceled do
|
2018-03-17 18:26:18 +05:30
|
|
|
finished
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'canceled' }
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :skipped do
|
2018-03-17 18:26:18 +05:30
|
|
|
started
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'skipped' }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
trait :running do
|
2018-03-17 18:26:18 +05:30
|
|
|
started
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'running' }
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :pending do
|
2023-01-13 00:05:48 +05:30
|
|
|
with_token
|
2019-12-21 20:55:43 +05:30
|
|
|
queued_at { 'Di 29. Okt 09:50:59 CET 2013' }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'pending' }
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
trait :created do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'created' }
|
2023-01-13 00:05:48 +05:30
|
|
|
generate_token { false }
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
trait :preparing do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'preparing' }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
trait :scheduled do
|
|
|
|
schedulable
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'scheduled' }
|
2019-03-02 22:35:43 +05:30
|
|
|
scheduled_at { 1.minute.since }
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :expired_scheduled do
|
|
|
|
schedulable
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'scheduled' }
|
2018-12-05 23:21:45 +05:30
|
|
|
scheduled_at { 1.minute.ago }
|
|
|
|
end
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
trait :manual do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'manual' }
|
|
|
|
self.when { 'manual' }
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :teardown_environment do
|
2019-12-21 20:55:43 +05:30
|
|
|
environment { 'staging' }
|
2019-02-15 15:39:39 +05:30
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'staging',
|
2022-10-11 01:57:18 +05:30
|
|
|
action: 'stop',
|
|
|
|
url: 'http://staging.example.com/$CI_JOB_NAME' }
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
trait :environment_with_deployment_tier do
|
|
|
|
environment { 'test_portal' }
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'test_portal',
|
2022-10-11 01:57:18 +05:30
|
|
|
action: 'start',
|
|
|
|
url: 'http://staging.example.com/$CI_JOB_NAME',
|
|
|
|
deployment_tier: 'testing' }
|
2021-10-27 15:23:28 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
trait :deploy_to_production do
|
2019-12-21 20:55:43 +05:30
|
|
|
environment { 'production' }
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'production',
|
2022-10-11 01:57:18 +05:30
|
|
|
url: 'http://prd.example.com/$CI_JOB_NAME' }
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :start_review_app do
|
2019-12-21 20:55:43 +05:30
|
|
|
environment { 'review/$CI_COMMIT_REF_NAME' }
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'review/$CI_COMMIT_REF_NAME',
|
2022-10-11 01:57:18 +05:30
|
|
|
url: 'http://staging.example.com/$CI_JOB_NAME',
|
|
|
|
on_stop: 'stop_review_app' }
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :stop_review_app do
|
2019-12-21 20:55:43 +05:30
|
|
|
name { 'stop_review_app' }
|
|
|
|
environment { 'review/$CI_COMMIT_REF_NAME' }
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'review/$CI_COMMIT_REF_NAME',
|
2022-10-11 01:57:18 +05:30
|
|
|
url: 'http://staging.example.com/$CI_JOB_NAME',
|
|
|
|
action: 'stop' }
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
trait :prepare_staging do
|
|
|
|
name { 'prepare staging' }
|
|
|
|
environment { 'staging' }
|
|
|
|
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'staging', action: 'prepare' }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
set_expanded_environment_name
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :start_staging do
|
|
|
|
name { 'start staging' }
|
|
|
|
environment { 'staging' }
|
|
|
|
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'staging', action: 'start' }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
set_expanded_environment_name
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :stop_staging do
|
|
|
|
name { 'stop staging' }
|
|
|
|
environment { 'staging' }
|
|
|
|
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: %w(ls),
|
|
|
|
environment: { name: 'staging', action: 'stop' }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
set_expanded_environment_name
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :set_expanded_environment_name do
|
|
|
|
after(:build) do |build, evaluator|
|
|
|
|
build.assign_attributes(
|
|
|
|
metadata_attributes: {
|
|
|
|
expanded_environment_name: build.expanded_environment_name
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
trait :allowed_to_fail do
|
2019-12-21 20:55:43 +05:30
|
|
|
allow_failure { true }
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :ignored do
|
|
|
|
allowed_to_fail
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :playable do
|
|
|
|
manual
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :retryable do
|
|
|
|
success
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
trait :schedulable do
|
2019-12-21 20:55:43 +05:30
|
|
|
self.when { 'delayed' }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
script: ['ls -a'],
|
|
|
|
start_in: '1 minute'
|
|
|
|
}
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :actionable do
|
2019-12-21 20:55:43 +05:30
|
|
|
self.when { 'manual' }
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
trait :retried do
|
2019-12-21 20:55:43 +05:30
|
|
|
retried { true }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :cancelable do
|
|
|
|
pending
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :erasable do
|
|
|
|
success
|
|
|
|
artifacts
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :tags do
|
2019-12-21 20:55:43 +05:30
|
|
|
tag_list do
|
|
|
|
[:docker, :ruby]
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :on_tag do
|
2019-12-21 20:55:43 +05:30
|
|
|
tag { true }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :triggered do
|
2018-03-17 18:26:18 +05:30
|
|
|
trigger_request factory: :ci_trigger_request
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
trait :with_deployment do
|
|
|
|
after(:build) do |build, evaluator|
|
|
|
|
##
|
|
|
|
# Build deployment/environment relations if environment name is set
|
|
|
|
# to the job. If `build.deployment` has already been set, it doesn't
|
|
|
|
# build a new instance.
|
2023-01-13 00:05:48 +05:30
|
|
|
Environments::CreateForBuildService.new.execute(build)
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
Deployments::CreateForBuildService.new.execute(build)
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :tag do
|
2019-12-21 20:55:43 +05:30
|
|
|
tag { true }
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
2016-01-19 16:12:03 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :coverage do
|
2019-12-21 20:55:43 +05:30
|
|
|
coverage { 99.9 }
|
|
|
|
coverage_regex { '/(d+)/' }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
trait :trace_with_coverage do
|
|
|
|
coverage { nil }
|
|
|
|
coverage_regex { '(\d+\.\d+)%' }
|
|
|
|
|
|
|
|
transient do
|
|
|
|
trace_coverage { 60.0 }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
build.trace.set("Coverage #{evaluator.trace_coverage}%")
|
|
|
|
build.trace.archive! if build.complete?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :trace_live do
|
2016-04-02 18:10:28 +05:30
|
|
|
after(:create) do |build, evaluator|
|
2017-08-17 22:00:37 +05:30
|
|
|
build.trace.set('BUILD TRACE')
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
end
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :trace_artifact do
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
create(:ci_job_artifact, :trace, job: build)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
trait :unarchived_trace_artifact do
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
create(:ci_job_artifact, :unarchived_trace_artifact, job: build)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
trait :trace_with_duplicate_sections do
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
trace = File.binread(
|
|
|
|
File.expand_path(
|
|
|
|
Rails.root.join('spec/fixtures/trace/trace_with_duplicate_sections')))
|
|
|
|
|
|
|
|
build.trace.set(trace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :trace_with_sections do
|
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
trace = File.binread(
|
|
|
|
File.expand_path(
|
|
|
|
Rails.root.join('spec/fixtures/trace/trace_with_sections')))
|
|
|
|
|
|
|
|
build.trace.set(trace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :unicode_trace_live do
|
2017-09-10 17:25:29 +05:30
|
|
|
after(:create) do |build, evaluator|
|
|
|
|
trace = File.binread(
|
|
|
|
File.expand_path(
|
|
|
|
Rails.root.join('spec/fixtures/trace/ansi-sequence-and-unicode')))
|
|
|
|
|
|
|
|
build.trace.set(trace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :erased do
|
2018-12-05 23:21:45 +05:30
|
|
|
erased_at { Time.now }
|
2017-08-17 22:00:37 +05:30
|
|
|
erased_by factory: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :queued do
|
2018-12-05 23:21:45 +05:30
|
|
|
queued_at { Time.now }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
after(:create) do |build|
|
|
|
|
build.create_queuing_entry!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :picked do
|
|
|
|
running
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
runner factory: :ci_runner
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
after(:create) do |build|
|
|
|
|
build.create_runtime_metadata!
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :artifacts do
|
|
|
|
after(:create) do |build|
|
|
|
|
create(:ci_job_artifact, :archive, job: build, expire_at: build.artifacts_expire_at)
|
|
|
|
create(:ci_job_artifact, :metadata, job: build, expire_at: build.artifacts_expire_at)
|
|
|
|
build.reload
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
trait :report_results do
|
|
|
|
after(:build) do |build|
|
|
|
|
build.report_results << build(:ci_build_report_result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :codequality_report do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :codequality, job: build)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
trait :sast_report do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :sast, job: build)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :secret_detection_report do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :secret_detection, job: build)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
trait :test_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :junit, job: build)
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
trait :test_reports_with_attachment do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :junit_with_attachment, job: build)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
trait :broken_test_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :junit_with_corrupted_data, job: build)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
trait :test_reports_with_duplicate_failed_test_names do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :junit_with_duplicate_failed_test_names, job: build)
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :test_reports_with_three_failures do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :junit_with_three_failures, job: build)
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
trait :accessibility_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :accessibility, job: build)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
trait :coverage_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :cobertura, job: build)
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
trait :codequality_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :codequality, job: build)
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
trait :codequality_reports_without_degradation do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :codequality_without_errors, job: build)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
trait :terraform_reports do
|
|
|
|
after(:build) do |build|
|
2022-11-25 23:54:43 +05:30
|
|
|
build.job_artifacts << build(:ci_job_artifact, :terraform, job: build)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :expired do
|
2018-12-05 23:21:45 +05:30
|
|
|
artifacts_expire_at { 1.minute.ago }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
trait :with_artifacts_paths do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: {
|
|
|
|
name: 'artifacts_file',
|
|
|
|
untracked: false,
|
|
|
|
paths: ['out/'],
|
|
|
|
when: 'always',
|
|
|
|
expire_in: '7d'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :with_commit do
|
|
|
|
after(:build) do |build|
|
2022-07-23 23:45:48 +05:30
|
|
|
commit = build(:commit, :without_author)
|
|
|
|
stub_method(build, :commit) { commit }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_commit_and_author do
|
|
|
|
after(:build) do |build|
|
2022-07-23 23:45:48 +05:30
|
|
|
commit = build(:commit)
|
|
|
|
stub_method(build, :commit) { commit }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :extended_options do
|
|
|
|
options do
|
|
|
|
{
|
2022-06-21 17:19:12 +05:30
|
|
|
image: { name: 'image:1.0', entrypoint: '/bin/sh' },
|
2021-12-11 22:18:48 +05:30
|
|
|
services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }, { name: 'mysql:latest', variables: { MYSQL_ROOT_PASSWORD: 'root123.' } }],
|
2019-12-21 20:55:43 +05:30
|
|
|
script: %w(echo),
|
|
|
|
after_script: %w(ls date),
|
|
|
|
artifacts: {
|
|
|
|
name: 'artifacts_file',
|
|
|
|
untracked: false,
|
|
|
|
paths: ['out/'],
|
|
|
|
when: 'always',
|
|
|
|
expire_in: '7d'
|
|
|
|
},
|
|
|
|
cache: {
|
|
|
|
key: 'cache_key',
|
|
|
|
untracked: false,
|
|
|
|
paths: ['vendor/*'],
|
2021-01-03 14:25:43 +05:30
|
|
|
policy: 'pull-push',
|
|
|
|
when: 'on_success'
|
2019-12-21 20:55:43 +05:30
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
trait :release_options do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
only: 'tags',
|
|
|
|
script: ['make changelog | tee release_changelog.txt'],
|
|
|
|
release: {
|
|
|
|
name: 'Release $CI_COMMIT_SHA',
|
|
|
|
description: 'Created using the release-cli $EXTRA_DESCRIPTION',
|
|
|
|
tag_name: 'release-$CI_COMMIT_SHA',
|
2021-06-08 01:23:25 +05:30
|
|
|
ref: '$CI_COMMIT_SHA',
|
|
|
|
assets: { links: [{ name: 'asset1', url: 'https://example.com/assets/1' }] }
|
2020-06-23 00:09:42 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :no_options do
|
|
|
|
options { {} }
|
|
|
|
end
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
trait :coverage_report_cobertura do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: {
|
|
|
|
expire_in: '7d',
|
|
|
|
reports: {
|
|
|
|
coverage_report: {
|
|
|
|
coverage_format: 'cobertura',
|
|
|
|
path: 'cobertura.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
# TODO: move Security traits to ee_ci_build
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/210486
|
2019-12-21 20:55:43 +05:30
|
|
|
trait :dast do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { dast: 'gl-dast-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :sast do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { sast: 'gl-sast-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
trait :secret_detection do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { secret_detection: 'gl-secret-detection-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
trait :dependency_scanning do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { dependency_scanning: 'gl-dependency-scanning-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :container_scanning do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { container_scanning: 'gl-container-scanning-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
trait :cluster_image_scanning do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { cluster_image_scanning: 'gl-cluster-image-scanning-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
trait :coverage_fuzzing do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { reports: { coverage_fuzzing: 'gl-coverage-fuzzing-report.json' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
trait :license_scanning do
|
|
|
|
options do
|
|
|
|
{
|
2021-04-17 20:07:23 +05:30
|
|
|
artifacts: { reports: { license_scanning: 'gl-license-scanning-report.json' } }
|
2020-04-08 14:13:33 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
trait :multiple_report_artifacts do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: {
|
|
|
|
reports: {
|
|
|
|
sast: 'gl-sast-report.json',
|
|
|
|
container_scanning: 'gl-container-scanning-report.json'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
trait :non_public_artifacts do
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
artifacts: { public: false }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
trait :non_playable do
|
2019-12-21 20:55:43 +05:30
|
|
|
status { 'created' }
|
|
|
|
self.when { 'manual' }
|
2017-08-17 22:00:37 +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-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
trait :script_failure do
|
|
|
|
failed
|
2019-12-21 20:55:43 +05:30
|
|
|
failure_reason { 1 }
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
trait :api_failure do
|
|
|
|
failed
|
2019-12-21 20:55:43 +05:30
|
|
|
failure_reason { 2 }
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
trait :prerequisite_failure do
|
|
|
|
failed
|
2019-12-21 20:55:43 +05:30
|
|
|
failure_reason { 10 }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
trait :forward_deployment_failure do
|
|
|
|
failed
|
|
|
|
failure_reason { 13 }
|
|
|
|
end
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
trait :deployment_rejected do
|
|
|
|
failed
|
|
|
|
failure_reason { 22 }
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
trait :with_runner_session do
|
|
|
|
after(:build) do |build|
|
2023-01-10 11:22:00 +05:30
|
|
|
build.build_runner_session(url: 'https://gitlab.example.com')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
trait :interruptible do
|
|
|
|
after(:build) do |build|
|
|
|
|
build.metadata.interruptible = true
|
|
|
|
end
|
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|