summaryrefslogtreecommitdiff
path: root/db/fixtures
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-08-18 09:39:44 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-08-18 16:31:06 +0200
commitdda60230623844b2615742de8d96b49f90ac8a87 (patch)
tree18e8056f4c5e1a9105422073c64424dd481f8ec4 /db/fixtures
parent312c1dce925e97319063e9e9b052607a8a26c5ed (diff)
downloadgitlab-ce-dda60230623844b2615742de8d96b49f90ac8a87.tar.gz
Fix build artifacts in fixtures in development env
Diffstat (limited to 'db/fixtures')
-rw-r--r--db/fixtures/development/14_builds.rb54
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