Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
eb7721e1
Commit
eb7721e1
authored
Feb 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add second build for each commit in build seeds
parent
479d412e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
db/fixtures/development/14_builds.rb
db/fixtures/development/14_builds.rb
+25
-14
No files found.
db/fixtures/development/14_builds.rb
View file @
eb7721e1
class
Gitlab::Seeder::Builds
class
Gitlab::Seeder::Builds
BUILD_STATUSES
=
%w(running pending success failed canceled)
def
initialize
(
project
)
def
initialize
(
project
)
@project
=
project
@project
=
project
end
end
def
seed!
def
seed!
ci_commits
.
each
do
|
ci_commit
|
ci_commits
.
each
do
|
ci_commit
|
build
=
Ci
::
Build
.
new
(
build_attributes_for
(
ci_commit
))
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
begin
begin
build
.
save!
build_create!
(
ci_commit
,
name:
'test build 1'
)
build_create!
(
ci_commit
,
status:
'success'
,
name:
'test build 2'
)
print
'.'
print
'.'
rescue
ActiveRecord
::
RecordInvalid
rescue
ActiveRecord
::
RecordInvalid
print
'F'
print
'F'
...
@@ -36,6 +25,28 @@ class Gitlab::Seeder::Builds
...
@@ -36,6 +25,28 @@ class Gitlab::Seeder::Builds
[]
[]
end
end
def
build_create!
(
ci_commit
,
opts
=
{})
attributes
=
build_attributes_for
(
ci_commit
).
merge
(
opts
)
build
=
Ci
::
Build
.
new
(
attributes
)
if
%w(success failed)
.
include?
(
build
.
status
)
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
build
.
save!
if
%w(running success failed)
.
include?
(
build
.
status
)
# We need to set build trace after saving a build (id required)
build
.
trace
=
FFaker
::
Lorem
.
paragraphs
(
6
).
join
(
"
\n\n
"
)
end
end
def
build_attributes_for
(
ci_commit
)
def
build_attributes_for
(
ci_commit
)
{
name:
'test build'
,
commands:
"$ build command"
,
{
name:
'test build'
,
commands:
"$ build command"
,
stage:
'test'
,
stage_idx:
1
,
ref:
'master'
,
stage:
'test'
,
stage_idx:
1
,
ref:
'master'
,
...
@@ -49,7 +60,7 @@ class Gitlab::Seeder::Builds
...
@@ -49,7 +60,7 @@ class Gitlab::Seeder::Builds
end
end
def
build_status
def
build_status
BUILD
_STATUSES
.
sample
Ci
::
Build
::
AVAILABLE
_STATUSES
.
sample
end
end
def
artifacts_archive_path
def
artifacts_archive_path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment