Commit ad5302ba authored by Grzegorz Bizon's avatar Grzegorz Bizon

Seed db on development with artifacts metadata fixture

parent 662f4b9e
...@@ -9,11 +9,14 @@ class Gitlab::Seeder::Builds ...@@ -9,11 +9,14 @@ class Gitlab::Seeder::Builds
ci_commits.each do |ci_commit| ci_commits.each do |ci_commit|
build = Ci::Build.new(build_attributes_for(ci_commit)) build = Ci::Build.new(build_attributes_for(ci_commit))
FileUtils.copy(artifacts_path, artifacts_cache_file_path) artifacts_cache_file(artifacts_archive_path) do |file|
File.open(artifacts_cache_file_path, 'r') do |file|
build.artifacts_file = file build.artifacts_file = file
end end
artifacts_cache_file(artifacts_metadata_path) do |file|
build.artifacts_metadata = file
end
begin begin
build.save! build.save!
print '.' print '.'
...@@ -49,12 +52,22 @@ class Gitlab::Seeder::Builds ...@@ -49,12 +52,22 @@ class Gitlab::Seeder::Builds
BUILD_STATUSES.sample BUILD_STATUSES.sample
end end
def artifacts_path def artifacts_archive_path
Rails.root + 'spec/fixtures/ci_build_artifacts.zip' Rails.root + 'spec/fixtures/ci_build_artifacts.zip'
end end
def artifacts_cache_file_path def artifacts_metadata_path
artifacts_path.to_s.gsub('ci_', "p#{@project.id}_") Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz'
end
def artifacts_cache_file(file_path)
cache_path = file_path.to_s.gsub('ci_', "p#{@project.id}_")
FileUtils.copy(file_path, cache_path)
File.open(cache_path) do |file|
yield file
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment