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
8f8a89f9
Commit
8f8a89f9
authored
Oct 31, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement POC config based parallelization
parent
94923328
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
0 deletions
+65
-0
app/models/ci/build.rb
app/models/ci/build.rb
+6
-0
lib/gitlab/ci/config/entry/jobs.rb
lib/gitlab/ci/config/entry/jobs.rb
+10
-0
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+1
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+48
-0
No files found.
app/models/ci/build.rb
View file @
8f8a89f9
...
...
@@ -801,10 +801,16 @@ module Ci
variables
.
append
(
key:
"CI_COMMIT_TAG"
,
value:
ref
)
if
tag?
variables
.
append
(
key:
"CI_PIPELINE_TRIGGERED"
,
value:
'true'
)
if
trigger_request
variables
.
append
(
key:
"CI_JOB_MANUAL"
,
value:
'true'
)
if
action?
variables
.
append
(
key:
"CI_NODE_INDEX"
,
value:
node_index
.
to_s
)
if
self
.
options
&
.
include?
(
:parallel
)
variables
.
append
(
key:
"CI_NODE_TOTAL"
,
value:
(
self
.
options
&
.
dig
(
:parallel
)
||
1
).
to_s
)
variables
.
concat
(
legacy_variables
)
end
end
def
node_index
name
.
match
(
%r{(
\d
+)/
\d
+$}
).
captures
[
0
]
end
def
gitlab_version_info
@gitlab_version_info
||=
Gitlab
::
VersionInfo
.
parse
(
Gitlab
::
VERSION
)
end
...
...
lib/gitlab/ci/config/entry/jobs.rb
View file @
8f8a89f9
...
...
@@ -29,6 +29,16 @@ 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
.
each
do
|
name
,
config
|
node
=
hidden?
(
name
)
?
Entry
::
Hidden
:
Entry
::
Job
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
8f8a89f9
...
...
@@ -50,6 +50,7 @@ module Gitlab
after_script:
job
[
:after_script
],
environment:
job
[
:environment
],
retry:
job
[
:retry
],
parallel:
job
[
:parallel
],
start_in:
job
[
:start_in
]
}.
compact
}
end
...
...
spec/models/ci/build_spec.rb
View file @
8f8a89f9
...
...
@@ -1880,6 +1880,7 @@ describe Ci::Build do
{
key:
'CI_COMMIT_BEFORE_SHA'
,
value:
build
.
before_sha
,
public:
true
},
{
key:
'CI_COMMIT_REF_NAME'
,
value:
build
.
ref
,
public:
true
},
{
key:
'CI_COMMIT_REF_SLUG'
,
value:
build
.
ref_slug
,
public:
true
},
{
key:
'CI_NODE_TOTAL'
,
value:
'1'
,
public:
true
},
{
key:
'CI_BUILD_REF'
,
value:
build
.
sha
,
public:
true
},
{
key:
'CI_BUILD_BEFORE_SHA'
,
value:
build
.
before_sha
,
public:
true
},
{
key:
'CI_BUILD_REF_NAME'
,
value:
build
.
ref
,
public:
true
},
...
...
@@ -2341,6 +2342,28 @@ describe Ci::Build do
end
end
context
'when build is parallelized'
do
let
(
:total
)
{
5
}
let
(
:index
)
{
3
}
before
do
build
.
options
[
:parallel
]
=
total
build
.
name
=
"
#{
build
.
name
}
#{
index
}
/
#{
total
}
"
end
it
'includes CI_NODE_INDEX'
do
is_expected
.
to
include
(
{
key:
'CI_NODE_INDEX'
,
value:
index
.
to_s
,
public:
true
}
)
end
it
'includes correct CI_NODE_TOTAL'
do
is_expected
.
to
include
(
{
key:
'CI_NODE_TOTAL'
,
value:
total
.
to_s
,
public:
true
}
)
end
end
describe
'variables ordering'
do
context
'when variables hierarchy is stubbed'
do
let
(
:build_pre_var
)
{
{
key:
'build'
,
value:
'value'
,
public:
true
}
}
...
...
@@ -2447,6 +2470,31 @@ describe Ci::Build do
end
end
end
describe
'#node_index'
do
subject
{
build
.
send
(
:node_index
)
}
let
(
:index
)
{
4
}
context
'when build has only one index'
do
before
do
build
.
name
=
"
#{
build
.
name
}
#{
index
}
/5"
end
it
'returns the index'
do
expect
(
subject
).
to
eq
(
index
.
to_s
)
end
end
context
'when build has more than one one index'
do
before
do
build
.
name
=
"test_build 1/3
#{
index
}
/5"
end
it
'returns the last index'
do
expect
(
subject
).
to
eq
(
index
.
to_s
)
end
end
end
end
describe
'#scoped_variables'
do
...
...
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