Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-31 18:11:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-31 18:11:19 +0300
commit7f98cf51aa49426815fe943a5a8dae2a96b59c01 (patch)
tree89047dcbc3bdddcc28895c1ac950cf080b363d1b /spec/factories
parent74ecf758e30be848144df1672b5080a29fafbc0a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/ci/bridge.rb4
-rw-r--r--spec/factories/ci/builds.rb134
-rw-r--r--spec/factories/ci/deployable.rb141
3 files changed, 149 insertions, 130 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb
index 49ac74f6f86..c5c0634994d 100644
--- a/spec/factories/ci/bridge.rb
+++ b/spec/factories/ci/bridge.rb
@@ -1,7 +1,11 @@
# frozen_string_literal: true
+require_relative 'deployable'
+
FactoryBot.define do
factory :ci_bridge, class: 'Ci::Bridge', parent: :ci_processable do
+ instance_eval ::Factories::Ci::Deployable.traits
+
name { 'bridge' }
created_at { '2013-10-29 09:50:00 CET' }
status { :created }
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index dc75e17499c..7325ab30989 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -1,7 +1,11 @@
# frozen_string_literal: true
+require_relative 'deployable'
+
FactoryBot.define do
factory :ci_build, class: 'Ci::Build', parent: :ci_processable do
+ instance_eval ::Factories::Ci::Deployable.traits
+
name { 'test' }
add_attribute(:protected) { false }
created_at { 'Di 29. Okt 09:50:00 CET 2013' }
@@ -137,122 +141,6 @@ FactoryBot.define do
self.when { 'manual' }
end
- trait :teardown_environment do
- environment { 'staging' }
- options do
- {
- script: %w(ls),
- environment: { name: 'staging',
- action: 'stop',
- url: 'http://staging.example.com/$CI_JOB_NAME' }
- }
- end
- end
-
- trait :environment_with_deployment_tier do
- environment { 'test_portal' }
- options do
- {
- script: %w(ls),
- environment: { name: 'test_portal',
- action: 'start',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- deployment_tier: 'testing' }
- }
- end
- end
-
- trait :deploy_to_production do
- environment { 'production' }
-
- options do
- {
- script: %w(ls),
- environment: { name: 'production',
- url: 'http://prd.example.com/$CI_JOB_NAME' }
- }
- end
- end
-
- trait :start_review_app do
- environment { 'review/$CI_COMMIT_REF_NAME' }
-
- options do
- {
- script: %w(ls),
- environment: { name: 'review/$CI_COMMIT_REF_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- on_stop: 'stop_review_app' }
- }
- end
- end
-
- trait :stop_review_app do
- name { 'stop_review_app' }
- environment { 'review/$CI_COMMIT_REF_NAME' }
-
- options do
- {
- script: %w(ls),
- environment: { name: 'review/$CI_COMMIT_REF_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- action: 'stop' }
- }
- end
- end
-
- 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
-
trait :allowed_to_fail do
allow_failure { true }
end
@@ -311,20 +199,6 @@ FactoryBot.define do
trigger_request factory: :ci_trigger_request
end
- 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.
- Environments::CreateForBuildService.new.execute(build)
- end
-
- after(:create) do |build, evaluator|
- Deployments::CreateForBuildService.new.execute(build)
- end
- end
-
trait :tag do
tag { true }
end
diff --git a/spec/factories/ci/deployable.rb b/spec/factories/ci/deployable.rb
new file mode 100644
index 00000000000..15b37e44e07
--- /dev/null
+++ b/spec/factories/ci/deployable.rb
@@ -0,0 +1,141 @@
+# frozen_string_literal: true
+
+module Factories
+ module Ci
+ module Deployable
+ def self.traits
+ <<-RUBY
+ trait :teardown_environment do
+ environment { 'staging' }
+ options do
+ {
+ script: %w(ls),
+ environment: { name: 'staging',
+ action: 'stop',
+ url: 'http://staging.example.com/$CI_JOB_NAME' }
+ }
+ end
+ end
+
+ trait :environment_with_deployment_tier do
+ environment { 'test_portal' }
+ options do
+ {
+ script: %w(ls),
+ environment: { name: 'test_portal',
+ action: 'start',
+ url: 'http://staging.example.com/$CI_JOB_NAME',
+ deployment_tier: 'testing' }
+ }
+ end
+ end
+
+ trait :deploy_to_production do
+ environment { 'production' }
+
+ options do
+ {
+ script: %w(ls),
+ environment: { name: 'production',
+ url: 'http://prd.example.com/$CI_JOB_NAME' }
+ }
+ end
+ end
+
+ trait :start_review_app do
+ environment { 'review/$CI_COMMIT_REF_NAME' }
+
+ options do
+ {
+ script: %w(ls),
+ environment: { name: 'review/$CI_COMMIT_REF_NAME',
+ url: 'http://staging.example.com/$CI_JOB_NAME',
+ on_stop: 'stop_review_app' }
+ }
+ end
+ end
+
+ trait :stop_review_app do
+ name { 'stop_review_app' }
+ environment { 'review/$CI_COMMIT_REF_NAME' }
+
+ options do
+ {
+ script: %w(ls),
+ environment: { name: 'review/$CI_COMMIT_REF_NAME',
+ url: 'http://staging.example.com/$CI_JOB_NAME',
+ action: 'stop' }
+ }
+ end
+ end
+
+ 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 |job, evaluator|
+ job.assign_attributes(
+ metadata_attributes: {
+ expanded_environment_name: job.expanded_environment_name
+ }
+ )
+ end
+ end
+
+ trait :with_deployment do
+ after(:build) do |job, evaluator|
+ ##
+ # Build deployment/environment relations if environment name is set
+ # to the job. If `job.deployment` has already been set, it doesn't
+ # build a new instance.
+ Environments::CreateForJobService.new.execute(job)
+ end
+
+ after(:create) do |job, evaluator|
+ Deployments::CreateForJobService.new.execute(job)
+ end
+ end
+ RUBY
+ end
+ end
+ end
+end