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
8ce03988
Commit
8ce03988
authored
Jul 30, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix current spec failures
parent
c0abcc68
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
16 deletions
+12
-16
app/models/ci/build.rb
app/models/ci/build.rb
+4
-8
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+7
-7
No files found.
app/models/ci/build.rb
View file @
8ce03988
...
@@ -8,8 +8,6 @@ module Ci
...
@@ -8,8 +8,6 @@ module Ci
include
Importable
include
Importable
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
Utils
::
StrongMemoize
MissingDependenciesError
=
Class
.
new
(
StandardError
)
belongs_to
:project
,
inverse_of: :builds
belongs_to
:project
,
inverse_of: :builds
belongs_to
:runner
belongs_to
:runner
belongs_to
:trigger_request
belongs_to
:trigger_request
...
@@ -581,15 +579,13 @@ module Ci
...
@@ -581,15 +579,13 @@ module Ci
options
[
:dependencies
]
&
.
empty?
options
[
:dependencies
]
&
.
empty?
end
end
def
valid_build_dependencies?
def
has_
valid_build_dependencies?
return
unless
Feature
.
enabled?
(
'ci_disable_validates_dependencies'
)
return
true
unless
Feature
.
enabled?
(
'ci_disable_validates_dependencies'
)
dependencies
.
each
do
|
dependency
|
dependencies
.
all?
(
&
:is_valid_dependency?
)
raise
MissingDependenciesError
unless
dependency
.
valid_dependency?
end
end
end
def
valid_dependency?
def
is_
valid_dependency?
return
false
if
artifacts_expired?
return
false
if
artifacts_expired?
return
false
if
erased?
return
false
if
erased?
...
...
app/services/ci/register_job_service.rb
View file @
8ce03988
...
@@ -70,7 +70,7 @@ module Ci
...
@@ -70,7 +70,7 @@ module Ci
build
.
runner_id
=
runner
.
id
build
.
runner_id
=
runner
.
id
build
.
runner_session_attributes
=
params
[
:session
]
if
params
[
:session
].
present?
build
.
runner_session_attributes
=
params
[
:session
]
if
params
[
:session
].
present?
unless
build
.
valid_build_dependencies?
unless
build
.
has_
valid_build_dependencies?
build
.
drop!
(
:missing_dependency_failure
)
build
.
drop!
(
:missing_dependency_failure
)
return
false
return
false
end
end
...
...
spec/models/ci/build_spec.rb
View file @
8ce03988
...
@@ -2409,18 +2409,18 @@ describe Ci::Build do
...
@@ -2409,18 +2409,18 @@ describe Ci::Build do
end
end
end
end
describe
'
state transition: any => [:running]
'
do
describe
'
#has_valid_build_dependencies?
'
do
shared_examples
'validation is active'
do
shared_examples
'validation is active'
do
context
'when depended job has not been completed yet'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
it
{
expect
{
job
.
run!
}.
to
have_valid_build_dependencies
}
end
end
context
'when artifacts of depended job has been expired'
do
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
job
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
it
{
expect
{
job
.
run!
}.
not_to
have_valid_build_dependencies
}
end
end
context
'when artifacts of depended job has been erased'
do
context
'when artifacts of depended job has been erased'
do
...
@@ -2430,7 +2430,7 @@ describe Ci::Build do
...
@@ -2430,7 +2430,7 @@ describe Ci::Build do
pre_stage_job
.
erase
pre_stage_job
.
erase
end
end
it
{
expect
{
job
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
it
{
expect
{
job
.
run!
}.
not_to
have_valid_build_dependencies
}
end
end
end
end
...
@@ -2438,12 +2438,12 @@ describe Ci::Build do
...
@@ -2438,12 +2438,12 @@ describe Ci::Build do
context
'when depended job has not been completed yet'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
it
{
expect
{
job
.
run!
}.
to
have_valid_build_dependencies
}
end
end
context
'when artifacts of depended job has been expired'
do
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
it
{
expect
{
job
.
run!
}.
to
have_valid_build_dependencies
}
end
end
context
'when artifacts of depended job has been erased'
do
context
'when artifacts of depended job has been erased'
do
...
@@ -2453,7 +2453,7 @@ describe Ci::Build do
...
@@ -2453,7 +2453,7 @@ describe Ci::Build do
pre_stage_job
.
erase
pre_stage_job
.
erase
end
end
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
it
{
expect
{
job
.
run!
}.
to
have_valid_build_dependencies
}
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