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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3c8dd4cc
Commit
3c8dd4cc
authored
Oct 31, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move parallelization to Ci::Config::Normalizer
parent
8f8a89f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
9 deletions
+52
-9
lib/gitlab/ci/config/entry/jobs.rb
lib/gitlab/ci/config/entry/jobs.rb
+1
-9
lib/gitlab/ci/config/normalizer.rb
lib/gitlab/ci/config/normalizer.rb
+51
-0
No files found.
lib/gitlab/ci/config/entry/jobs.rb
View file @
3c8dd4cc
...
...
@@ -29,15 +29,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
compose!
(
deps
=
nil
)
super
do
@config
=
@config
.
map
do
|
name
,
config
|
total
=
config
[
:parallel
]
if
total
Array
.
new
(
total
)
{
{
name
=>
config
}
}
.
each_with_index
{
|
build
,
idx
|
build
[
"
#{
name
}
#{
idx
+
1
}
/
#{
total
}
"
.
to_sym
]
=
build
.
delete
(
name
)
}
else
{
name
=>
config
}
end
end
.
flatten
.
reduce
(
:merge
)
@config
=
Ci
::
Config
::
Normalizer
.
normalize_jobs
(
@config
)
@config
.
each
do
|
name
,
config
|
node
=
hidden?
(
name
)
?
Entry
::
Hidden
:
Entry
::
Job
...
...
lib/gitlab/ci/config/normalizer.rb
0 → 100644
View file @
3c8dd4cc
module
Gitlab
module
Ci
class
Config
class
Normalizer
class
<<
self
def
normalize_jobs
(
jobs_config
)
parallelized_jobs
=
{}
parallelized_config
=
jobs_config
.
map
do
|
name
,
config
|
if
config
&
.
[
](
:parallel
)
total
=
config
[
:parallel
]
names
=
parallelize_job_names
(
name
,
total
)
parallelized_jobs
[
name
]
=
names
Hash
[
names
.
collect
{
|
job_name
|
[
job_name
.
to_sym
,
config
]
}]
else
{
name
=>
config
}
end
end
.
reduce
(
:merge
)
parallelized_config
.
each
do
|
name
,
config
|
next
unless
config
[
:dependencies
]
deps
=
config
[
:dependencies
].
map
do
|
dep
|
if
parallelized_jobs
.
keys
.
include?
(
dep
.
to_sym
)
config
[
:dependencies
].
delete
(
dep
)
parallelized_jobs
[
dep
.
to_sym
]
else
dep
end
end
.
flatten
config
[
:dependencies
]
=
deps
end
end
private
def
parallelize_job_names
(
name
,
total
)
jobs
=
[]
total
.
times
do
|
idx
|
jobs
<<
"
#{
name
}
#{
idx
+
1
}
/
#{
total
}
"
end
jobs
end
end
end
end
end
end
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