summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2015-12-17 11:00:53 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 12:48:12 +0100
commit7027bf40c6898a26557d7325356e5e8760a3ff40 (patch)
treed73501f9fab614dc10dd0507d70d89c41ed7ee53 /db
parent2c6b11198aa636b7e54a55bf63d0daabcfb716d8 (diff)
downloadgitlab-ce-7027bf40c6898a26557d7325356e5e8760a3ff40.tar.gz
Add database seed for build artifacts
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/14_builds.rb25
1 files changed, 18 insertions, 7 deletions
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_builds.rb
index 73cffcbc01e..f9b4482cbf9 100644
--- a/db/fixtures/development/14_builds.rb
+++ b/db/fixtures/development/14_builds.rb
@@ -1,24 +1,35 @@
Gitlab::Seeder.quiet do
+ build_artifacts_path = Rails.root + 'spec/fixtures/ci_build_artifacts.tar.gz'
+ build_artifacts_cache_file = build_artifacts_path.to_s.gsub('ci_', '')
+
Project.all.sample(5).each do |project|
- commits = project.repository.commits('master', nil, 10)
+ commits = project.repository.commits('master', nil, 5)
commits_sha = commits.map { |commit| commit.raw.id }
ci_commits = commits_sha.map do |sha|
project.ensure_ci_commit(sha)
end
ci_commits.each do |ci_commit|
- attributes = { type: 'Ci::Build', name: 'test build',
- commands: "$ build command", stage: 'test',
- stage_idx: 1, ref: 'master', user_id: User.first,
- gl_project_id: project.id, options: '---- opts',
+ attributes = { type: 'Ci::Build', name: 'test build', commands: "$ build command",
+ stage: 'test', stage_idx: 1, ref: 'master',
+ user_id: project.team.users.sample, gl_project_id: project.id,
status: %w(running pending success failed canceled).sample,
- commit_id: ci_commit.id }
+ commit_id: ci_commit.id, created_at: Time.now, updated_at: Time.now }
+
+ build = Ci::Build.new(attributes)
+ build.artifacts_metadata = `tar tzf #{build_artifacts_path}`.split(/\n/)
+
+ FileUtils.copy(build_artifacts_path, build_artifacts_cache_file)
+ build.artifacts_file = artifacts_file = File.open(build_artifacts_cache_file, 'r')
begin
- Ci::Build.create!(attributes)
+ build.save!
print '.'
rescue ActiveRecord::RecordInvalid
+ puts build.error.messages.inspect
print 'F'
+ ensure
+ artifacts_file.close
end
end
end