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:
Diffstat (limited to 'spec/factories/ci')
-rw-r--r--spec/factories/ci/bridge.rb18
-rw-r--r--spec/factories/ci/builds.rb32
-rw-r--r--spec/factories/ci/daily_build_group_report_results.rb1
-rw-r--r--spec/factories/ci/job_artifacts.rb20
-rw-r--r--spec/factories/ci/pipeline_artifacts.rb33
-rw-r--r--spec/factories/ci/pipelines.rb24
-rw-r--r--spec/factories/ci/processable.rb26
-rw-r--r--spec/factories/ci/reports/codequality_degradations.rb98
-rw-r--r--spec/factories/ci/resource.rb2
9 files changed, 221 insertions, 33 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb
index 7727a468633..6cbcabca7ab 100644
--- a/spec/factories/ci/bridge.rb
+++ b/spec/factories/ci/bridge.rb
@@ -1,17 +1,10 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :ci_bridge, class: 'Ci::Bridge' do
+ factory :ci_bridge, class: 'Ci::Bridge', parent: :ci_processable do
name { 'bridge' }
- stage { 'test' }
- stage_idx { 0 }
- ref { 'master' }
- tag { false }
created_at { '2013-10-29 09:50:00 CET' }
status { :created }
- scheduling_type { 'stage' }
-
- pipeline factory: :ci_pipeline
trait :variables do
yaml_variables do
@@ -53,6 +46,11 @@ FactoryBot.define do
finished_at { '2013-10-29 09:53:28 CET' }
end
+ trait :success do
+ finished
+ status { 'success' }
+ end
+
trait :failed do
finished
status { 'failed' }
@@ -75,5 +73,9 @@ FactoryBot.define do
trait :playable do
manual
end
+
+ trait :allowed_to_fail do
+ allow_failure { true }
+ end
end
end
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 24abad66530..c4f9a4ce82b 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -3,15 +3,10 @@
include ActionDispatch::TestProcess
FactoryBot.define do
- factory :ci_build, class: 'Ci::Build' do
+ factory :ci_build, class: 'Ci::Build', parent: :ci_processable do
name { 'test' }
- stage { 'test' }
- stage_idx { 0 }
- ref { 'master' }
- tag { false }
add_attribute(:protected) { false }
created_at { 'Di 29. Okt 09:50:00 CET 2013' }
- scheduling_type { 'stage' }
pending
options do
@@ -28,7 +23,6 @@ FactoryBot.define do
]
end
- pipeline factory: :ci_pipeline
project { pipeline.project }
trait :degenerated do
@@ -79,10 +73,6 @@ FactoryBot.define do
status { 'created' }
end
- trait :waiting_for_resource do
- status { 'waiting_for_resource' }
- end
-
trait :preparing do
status { 'preparing' }
end
@@ -213,14 +203,6 @@ FactoryBot.define do
trigger_request factory: :ci_trigger_request
end
- trait :resource_group do
- waiting_for_resource_at { 5.minutes.ago }
-
- after(:build) do |build, evaluator|
- build.resource_group = create(:ci_resource_group, project: build.project)
- end
- end
-
trait :with_deployment do
after(:build) do |build, evaluator|
##
@@ -314,6 +296,18 @@ FactoryBot.define do
end
end
+ trait :sast_report do
+ after(:build) do |build|
+ build.job_artifacts << create(:ci_job_artifact, :sast, job: build)
+ end
+ end
+
+ trait :secret_detection_report do
+ after(:build) do |build|
+ build.job_artifacts << create(:ci_job_artifact, :secret_detection, job: build)
+ end
+ end
+
trait :test_reports do
after(:build) do |build|
build.job_artifacts << create(:ci_job_artifact, :junit, job: build)
diff --git a/spec/factories/ci/daily_build_group_report_results.rb b/spec/factories/ci/daily_build_group_report_results.rb
index d836ee9567c..55f4f116c97 100644
--- a/spec/factories/ci/daily_build_group_report_results.rb
+++ b/spec/factories/ci/daily_build_group_report_results.rb
@@ -7,6 +7,7 @@ FactoryBot.define do
project
last_pipeline factory: :ci_pipeline
group_name { 'rspec' }
+ group
data do
{ 'coverage' => 77.0 }
end
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index ad98e9d1f24..bfd8506566b 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -269,6 +269,26 @@ FactoryBot.define do
end
end
+ trait :sast do
+ file_type { :sast }
+ file_format { :raw }
+
+ after(:build) do |artifact, _|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/security_reports/master/gl-sast-report.json'), 'application/json')
+ end
+ end
+
+ trait :secret_detection do
+ file_type { :secret_detection }
+ file_format { :raw }
+
+ after(:build) do |artifact, _|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/security_reports/master/gl-secret-detection-report.json'), 'application/json')
+ end
+ end
+
trait :lsif do
file_type { :lsif }
file_format { :zip }
diff --git a/spec/factories/ci/pipeline_artifacts.rb b/spec/factories/ci/pipeline_artifacts.rb
index fa33609dd6c..05ff7afed7c 100644
--- a/spec/factories/ci/pipeline_artifacts.rb
+++ b/spec/factories/ci/pipeline_artifacts.rb
@@ -4,18 +4,30 @@ FactoryBot.define do
factory :ci_pipeline_artifact, class: 'Ci::PipelineArtifact' do
pipeline factory: :ci_pipeline
project { pipeline.project }
- file_type { :code_coverage }
file_format { :raw }
file_store { ObjectStorage::SUPPORTED_STORES.first }
- size { 1.megabytes }
-
+ size { 1.megabyte }
+ file_type { :code_coverage }
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
end
- trait :with_multibyte_characters do
+ trait :with_coverage_report do
+ file_type { :code_coverage }
+
+ after(:build) do |artifact, _evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
+ end
+
+ size { file.size }
+ end
+
+ trait :with_coverage_multibyte_characters do
+ file_type { :code_coverage }
size { { "utf8" => "✓" }.to_json.bytesize }
+
after(:build) do |artifact, _evaluator|
artifact.file = CarrierWaveStringFile.new_file(
file_content: { "utf8" => "✓" }.to_json,
@@ -26,12 +38,25 @@ FactoryBot.define do
end
trait :with_code_coverage_with_multiple_files do
+ file_type { :code_coverage }
+
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage_with_multiple_files.json'), 'application/json'
)
end
+ size { 1.megabyte }
+ end
+
+ trait :with_codequality_mr_diff_report do
+ file_type { :code_quality_mr_diff }
+
+ after(:build) do |artifact, _evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/pipeline_artifacts/code_quality_mr_diff.json'), 'application/json')
+ end
+
size { file.size }
end
end
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 86a8b008e48..e0d7ad3c133 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -101,6 +101,22 @@ FactoryBot.define do
end
end
+ trait :with_sast_report do
+ status { :success }
+
+ after(:build) do |pipeline, evaluator|
+ pipeline.builds << build(:ci_build, :sast_report, pipeline: pipeline, project: pipeline.project)
+ end
+ end
+
+ trait :with_secret_detection_report do
+ status { :success }
+
+ after(:build) do |pipeline, evaluator|
+ pipeline.builds << build(:ci_build, :secret_detection_report, pipeline: pipeline, project: pipeline.project)
+ end
+ end
+
trait :with_test_reports do
status { :success }
@@ -159,7 +175,13 @@ FactoryBot.define do
trait :with_coverage_report_artifact do
after(:build) do |pipeline, evaluator|
- pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, pipeline: pipeline, project: pipeline.project)
+ pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, :with_coverage_report, pipeline: pipeline, project: pipeline.project)
+ end
+ end
+
+ trait :with_codequality_mr_diff_report do
+ after(:build) do |pipeline, evaluator|
+ pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, :with_codequality_mr_diff_report, pipeline: pipeline, project: pipeline.project)
end
end
diff --git a/spec/factories/ci/processable.rb b/spec/factories/ci/processable.rb
new file mode 100644
index 00000000000..0550f4c23fa
--- /dev/null
+++ b/spec/factories/ci/processable.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :ci_processable, class: 'Ci::Processable' do
+ name { 'processable' }
+ stage { 'test' }
+ stage_idx { 0 }
+ ref { 'master' }
+ tag { false }
+ pipeline factory: :ci_pipeline
+ project { pipeline.project }
+ scheduling_type { 'stage' }
+
+ trait :waiting_for_resource do
+ status { 'waiting_for_resource' }
+ end
+
+ trait :resource_group do
+ waiting_for_resource_at { 5.minutes.ago }
+
+ after(:build) do |processable, evaluator|
+ processable.resource_group = create(:ci_resource_group, project: processable.project)
+ end
+ end
+ end
+end
diff --git a/spec/factories/ci/reports/codequality_degradations.rb b/spec/factories/ci/reports/codequality_degradations.rb
new file mode 100644
index 00000000000..d82157b457a
--- /dev/null
+++ b/spec/factories/ci/reports/codequality_degradations.rb
@@ -0,0 +1,98 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :codequality_degradation_1, class: Hash do
+ skip_create
+
+ initialize_with do
+ {
+ "categories": [
+ "Complexity"
+ ],
+ "check_name": "argument_count",
+ "content": {
+ "body": ""
+ },
+ "description": "Avoid parameter lists longer than 5 parameters. [12/5]",
+ "fingerprint": "15cdb5c53afd42bc22f8ca366a08d547",
+ "location": {
+ "path": "file_a.rb",
+ "lines": {
+ "begin": 10,
+ "end": 10
+ }
+ },
+ "other_locations": [],
+ "remediation_points": 900000,
+ "severity": "major",
+ "type": "issue",
+ "engine_name": "structure"
+ }.with_indifferent_access
+ end
+ end
+
+ factory :codequality_degradation_2, class: Hash do
+ skip_create
+
+ initialize_with do
+ {
+ "categories": [
+ "Complexity"
+ ],
+ "check_name": "argument_count",
+ "content": {
+ "body": ""
+ },
+ "description": "Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.",
+ "fingerprint": "f3bdc1e8c102ba5fbd9e7f6cda51c95e",
+ "location": {
+ "path": "file_a.rb",
+ "lines": {
+ "begin": 10,
+ "end": 10
+ }
+ },
+ "other_locations": [],
+ "remediation_points": 900000,
+ "severity": "major",
+ "type": "issue",
+ "engine_name": "structure"
+ }.with_indifferent_access
+ end
+ end
+
+ factory :codequality_degradation_3, class: Hash do
+ skip_create
+
+ initialize_with do
+ {
+ "type": "Issue",
+ "check_name": "Rubocop/Metrics/ParameterLists",
+ "description": "Avoid parameter lists longer than 5 parameters. [12/5]",
+ "categories": [
+ "Complexity"
+ ],
+ "remediation_points": 550000,
+ "location": {
+ "path": "file_b.rb",
+ "positions": {
+ "begin": {
+ "column": 14,
+ "line": 10
+ },
+ "end": {
+ "column": 39,
+ "line": 10
+ }
+ }
+ },
+ "content": {
+ "body": "This cop checks for methods with too many parameters.\nThe maximum number of parameters is configurable.\nKeyword arguments can optionally be excluded from the total count."
+ },
+ "engine_name": "rubocop",
+ "fingerprint": "ab5f8b935886b942d621399f5a2ca16e",
+ "severity": "minor"
+ }.with_indifferent_access
+ end
+ end
+end
diff --git a/spec/factories/ci/resource.rb b/spec/factories/ci/resource.rb
index 515329506e5..dec26013a25 100644
--- a/spec/factories/ci/resource.rb
+++ b/spec/factories/ci/resource.rb
@@ -5,7 +5,7 @@ FactoryBot.define do
resource_group factory: :ci_resource_group
trait(:retained) do
- build factory: :ci_build
+ processable factory: :ci_build
end
end
end