diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-18 10:39:44 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-18 17:31:06 +0300 |
commit | dda60230623844b2615742de8d96b49f90ac8a87 (patch) | |
tree | 18e8056f4c5e1a9105422073c64424dd481f8ec4 /db | |
parent | 312c1dce925e97319063e9e9b052607a8a26c5ed (diff) |
Fix build artifacts in fixtures in development env
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/14_builds.rb | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_builds.rb index 903b75c924b..55af91c1cb8 100644 --- a/db/fixtures/development/14_builds.rb +++ b/db/fixtures/development/14_builds.rb @@ -69,46 +69,52 @@ class Gitlab::Seeder::Builds end def build_create!(pipeline, opts = {}) - attributes = build_attributes_for(pipeline, opts) + attributes = job_attributes(pipeline, opts) + .merge(commands: '$ build command') Ci::Build.create!(attributes).tap do |build| - if opts[:name].start_with?('build') - artifacts_cache_file(artifacts_archive_path) do |file| - build.artifacts_file = file - end - - artifacts_cache_file(artifacts_metadata_path) do |file| - build.artifacts_metadata = file - end - end + setup_artifacts(build) + setup_build_log(build) + build.save + end + end - ## - # We need to set build trace after saving a build (id required) - # That is why we need `#tap` method instead of passing block - # directly to `Ci::Build#create!`. - # - if %w(running success failed).include?(build.status) - build.trace = FFaker::Lorem.paragraphs(6).join("\n\n") - end + def setup_artifacts(build) + return unless %w[build test].include?(build.stage) + + artifacts_cache_file(artifacts_archive_path) do |file| + build.artifacts_file = file + end + + artifacts_cache_file(artifacts_metadata_path) do |file| + build.artifacts_metadata = file + end + end + + def setup_build_log(build) + ## + # We need to set build trace after saving a build (id required) + # That is why we need `#tap` method instead of passing block + # directly to `Ci::Build#create!`. + # + if %w(running success failed).include?(build.status) + build.trace = FFaker::Lorem.paragraphs(6).join("\n\n") end end def commit_status_create!(pipeline, opts = {}) - attributes = commit_status_attributes_for(pipeline, opts) + attributes = job_attributes(pipeline, opts) + GenericCommitStatus.create!(attributes) end - def commit_status_attributes_for(pipeline, opts) + def job_attributes(pipeline, opts) { name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]), ref: 'master', tag: false, user: build_user, project: @project, pipeline: pipeline, created_at: Time.now, updated_at: Time.now }.merge(opts) end - def build_attributes_for(pipeline, opts) - commit_status_attributes_for(pipeline, opts).merge(commands: '$ build command') - end - def build_user @project.team.users.sample end |