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/builds.rb72
-rw-r--r--spec/factories/ci/job_artifacts.rb50
2 files changed, 120 insertions, 2 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 011021f6320..56c12d73a3b 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -10,7 +10,7 @@ FactoryBot.define do
options do
{
- image: 'ruby:2.7',
+ image: 'image:1.0',
services: ['postgres'],
script: ['ls -a']
}
@@ -175,6 +175,58 @@ FactoryBot.define do
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
@@ -455,7 +507,7 @@ FactoryBot.define do
trait :extended_options do
options do
{
- image: { name: 'ruby:2.7', entrypoint: '/bin/sh' },
+ image: { name: 'image:1.0', entrypoint: '/bin/sh' },
services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }, { name: 'mysql:latest', variables: { MYSQL_ROOT_PASSWORD: 'root123.' } }],
script: %w(echo),
after_script: %w(ls date),
@@ -497,6 +549,22 @@ FactoryBot.define do
options { {} }
end
+ trait :coverage_report_cobertura do
+ options do
+ {
+ artifacts: {
+ expire_in: '7d',
+ reports: {
+ coverage_report: {
+ coverage_format: 'cobertura',
+ path: 'cobertura.xml'
+ }
+ }
+ }
+ }
+ end
+ end
+
# TODO: move Security traits to ee_ci_build
# https://gitlab.com/gitlab-org/gitlab/-/issues/210486
trait :dast do
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index 77b07c4a404..cdbcdced5f4 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -302,6 +302,56 @@ FactoryBot.define do
end
end
+ # Bandit reports are correctly de-duplicated when ran in the same pipeline
+ # as a corresponding semgrep report.
+ # This report does not include signature tracking.
+ trait :sast_bandit 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-bandit.json'), 'application/json')
+ end
+ end
+
+ # Equivalent Semgrep report for :sast_bandit report.
+ # This report includes signature tracking.
+ trait :sast_semgrep_for_bandit 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-semgrep-for-bandit.json'), 'application/json')
+ end
+ end
+
+ # Gosec reports are not correctly de-duplicated when ran in the same pipeline
+ # as a corresponding semgrep report.
+ # This report includes signature tracking.
+ trait :sast_gosec 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-gosec.json'), 'application/json')
+ end
+ end
+
+ # Equivalent Semgrep report for :sast_gosec report.
+ # This report includes signature tracking.
+ trait :sast_semgrep_for_gosec 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-semgrep-for-gosec.json'), 'application/json')
+ end
+ end
+
trait :common_security_report do
file_format { :raw }
file_type { :dependency_scanning }