diff options
Diffstat (limited to 'db/fixtures/development/14_pipelines.rb')
-rw-r--r-- | db/fixtures/development/14_pipelines.rb | 138 |
1 files changed, 70 insertions, 68 deletions
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb index db043e39d2c..9a380af8f85 100644 --- a/db/fixtures/development/14_pipelines.rb +++ b/db/fixtures/development/14_pipelines.rb @@ -1,61 +1,61 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" class Gitlab::Seeder::Pipelines STAGES = %w[build test security deploy notify] BUILDS = [ # build stage - { name: 'build:linux', stage: 'build', status: :success, - queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago }, - { name: 'build:osx', stage: 'build', status: :success, - queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago }, + {name: "build:linux", stage: "build", status: :success, + queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago,}, + {name: "build:osx", stage: "build", status: :success, + queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago,}, # test stage - { name: 'rspec:linux 0 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:linux 1 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:linux 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 0 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 1 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:osx', stage: 'test', status_event: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'spinach:linux', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'spinach:osx', stage: 'test', status: :failed, allow_failure: true, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, + {name: "rspec:linux 0 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:linux 1 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:linux 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 0 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 1 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:osx", stage: "test", status_event: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "spinach:linux", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "spinach:osx", stage: "test", status: :failed, allow_failure: true, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, # security stage - { name: 'dast', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'sast', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'dependency_scanning', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'container_scanning', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, + {name: "dast", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "sast", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "dependency_scanning", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "container_scanning", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, # deploy stage - { name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success, - options: { environment: { action: 'start', on_stop: 'stop staging' } }, - queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago }, - { name: 'stop staging', stage: 'deploy', environment: 'staging', - when: 'manual', status: :skipped }, - { name: 'production', stage: 'deploy', environment: 'production', - when: 'manual', status: :skipped }, + {name: "staging", stage: "deploy", environment: "staging", status_event: :success, + options: {environment: {action: "start", on_stop: "stop staging"}}, + queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,}, + {name: "stop staging", stage: "deploy", environment: "staging", + when: "manual", status: :skipped,}, + {name: "production", stage: "deploy", environment: "production", + when: "manual", status: :skipped,}, # notify stage - { name: 'slack', stage: 'notify', when: 'manual', status: :success }, + {name: "slack", stage: "notify", when: "manual", status: :success}, ] EXTERNAL_JOBS = [ - { name: 'jenkins', stage: 'test', status: :success, - queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago }, + {name: "jenkins", stage: "test", status: :success, + queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,}, ] def initialize(project) @@ -78,15 +78,15 @@ class Gitlab::Seeder::Pipelines end def create_master_pipelines - @project.repository.commits('master', limit: 4).map do |commit| - create_pipeline!(@project, 'master', commit) + @project.repository.commits("master", limit: 4).map do |commit| + create_pipeline!(@project, "master", commit) end rescue [] end def create_merge_request_pipelines - pipelines = @project.merge_requests.first(3).map do |merge_request| + pipelines = @project.merge_requests.first(3).map { |merge_request| project = merge_request.source_project branch = merge_request.source_branch @@ -95,7 +95,7 @@ class Gitlab::Seeder::Pipelines merge_request.update!(head_pipeline_id: pipeline.id) end end - end + } pipelines.flatten rescue @@ -110,7 +110,7 @@ class Gitlab::Seeder::Pipelines attributes = job_attributes(pipeline, opts) attributes[:options] ||= {} - attributes[:options][:script] = 'build command' + attributes[:options][:script] = "build command" Ci::Build.create!(attributes).tap do |build| # We need to set build trace and artifacts after saving a build @@ -126,8 +126,8 @@ class Gitlab::Seeder::Pipelines end setup_build_log(build) - build.project.environments. - find_or_create_by(name: build.expanded_environment_name) + build.project.environments + .find_or_create_by(name: build.expanded_environment_name) build.save! end @@ -164,14 +164,15 @@ class Gitlab::Seeder::Pipelines # we have two sources: master and feature-branch branch_name = build.ref == build.project.default_branch ? - 'master' : 'feature-branch' + "master" : "feature-branch" artifacts_cache_file(security_reports_path(branch_name, build.name)) do |file| build.job_artifacts.build( project: build.project, file_type: build.name, file_format: :raw, - file: file) + file: file +) end end @@ -180,14 +181,15 @@ class Gitlab::Seeder::Pipelines # we have two sources: master and feature-branch branch_name = build.ref == build.project.default_branch ? - 'master' : 'feature-branch' + "master" : "feature-branch" artifacts_cache_file(security_reports_archive_path(branch_name)) do |file| build.job_artifacts.build( project: build.project, file_type: :archive, file_format: :zip, - file: file) + file: file +) end # assign dummy metadata @@ -196,20 +198,21 @@ class Gitlab::Seeder::Pipelines project: build.project, file_type: :metadata, file_format: :gzip, - file: file) + file: file +) end build.options = { artifacts: { paths: [ - Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym) - ] - } + Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym), + ], + }, } end def setup_build_log(build) - if %w(running success failed).include?(build.status) + if %w[running success failed].include?(build.status) build.trace.set(FFaker::Lorem.paragraphs(6).join("\n\n")) end end @@ -221,10 +224,9 @@ class Gitlab::Seeder::Pipelines end def job_attributes(pipeline, opts) - { name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]), + {name: "test build", stage: "test", stage_idx: stage_index(opts[:stage]), ref: pipeline.ref, tag: false, user: build_user, project: @project, pipeline: pipeline, - created_at: Time.now, updated_at: Time.now - }.merge(opts) + created_at: Time.now, updated_at: Time.now},.merge(opts) end def build_user @@ -240,28 +242,28 @@ class Gitlab::Seeder::Pipelines end def artifacts_archive_path - Rails.root + 'spec/fixtures/ci_build_artifacts.zip' + Rails.root + "spec/fixtures/ci_build_artifacts.zip" end def artifacts_metadata_path - Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz' + Rails.root + "spec/fixtures/ci_build_artifacts_metadata.gz" end def test_reports_pass_path - Rails.root + 'spec/fixtures/junit/junit_ant.xml.gz' + Rails.root + "spec/fixtures/junit/junit_ant.xml.gz" end def test_reports_failed_path - Rails.root + 'spec/fixtures/junit/junit.xml.gz' + Rails.root + "spec/fixtures/junit/junit.xml.gz" end def security_reports_archive_path(branch) - Rails.root.join('spec', 'fixtures', 'security-reports', branch + '.zip') + Rails.root.join("spec", "fixtures", "security-reports", branch + ".zip") end def security_reports_path(branch, name) file_name = Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(name.to_sym) - Rails.root.join('spec', 'fixtures', 'security-reports', branch, file_name) + Rails.root.join("spec", "fixtures", "security-reports", branch, file_name) end def artifacts_cache_file(file_path) |