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
a8da5238
Commit
a8da5238
authored
Nov 02, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Gitlab::Ci::Config::Normalizer
parent
8a6a312d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
lib/gitlab/ci/config/normalizer.rb
lib/gitlab/ci/config/normalizer.rb
+27
-17
No files found.
lib/gitlab/ci/config/normalizer.rb
View file @
a8da5238
...
...
@@ -6,6 +6,13 @@ module Gitlab
class
Normalizer
class
<<
self
def
normalize_jobs
(
jobs_config
)
parallelized_config
,
parallelized_jobs
=
parallelize_jobs
(
jobs_config
)
parallelize_dependencies
(
parallelized_config
,
parallelized_jobs
)
end
private
def
parallelize_jobs
(
jobs_config
)
parallelized_jobs
=
{}
parallelized_config
=
jobs_config
.
map
do
|
name
,
config
|
...
...
@@ -19,29 +26,32 @@ module Gitlab
end
end
.
reduce
(
:merge
)
parallelized_config
.
each
do
|
name
,
config
|
next
unless
config
[
:dependencies
]
[
parallelized_config
,
parallelized_jobs
]
end
def
parallelize_dependencies
(
jobs_config
,
parallelized_jobs
)
jobs_config
.
map
do
|
name
,
config
|
if
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
{
name
=>
config
.
merge
(
dependencies:
deps
)
}
else
{
name
=>
config
}
end
end
.
reduce
(
:merge
)
end
private
def
parallelize_job_names
(
name
,
total
)
jobs
=
[]
total
.
times
do
|
idx
|
jobs
<<
[
"
#{
name
}
#{
idx
+
1
}
/
#{
total
}
"
,
idx
+
1
]
1
.
upto
(
total
)
do
|
idx
|
jobs
<<
[
"
#{
name
}
#{
idx
}
/
#{
total
}
"
,
idx
]
end
jobs
...
...
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