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
Tatuya Kamada
gitlab-ce
Commits
8dbd1e7d
Commit
8dbd1e7d
authored
Jan 09, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add concrete success warning status to stage factory
parent
8b30dd98
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
20 deletions
+115
-20
app/models/ci/stage.rb
app/models/ci/stage.rb
+8
-0
lib/gitlab/ci/status/pipeline/factory.rb
lib/gitlab/ci/status/pipeline/factory.rb
+1
-1
lib/gitlab/ci/status/pipeline/success_warning.rb
lib/gitlab/ci/status/pipeline/success_warning.rb
+0
-13
lib/gitlab/ci/status/stage/factory.rb
lib/gitlab/ci/status/stage/factory.rb
+4
-0
lib/gitlab/ci/status/success_warning.rb
lib/gitlab/ci/status/success_warning.rb
+2
-4
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+3
-2
spec/lib/gitlab/ci/status/stage/factory_spec.rb
spec/lib/gitlab/ci/status/stage/factory_spec.rb
+22
-0
spec/lib/gitlab/ci/status/success_warning_spec.rb
spec/lib/gitlab/ci/status/success_warning_spec.rb
+75
-0
No files found.
app/models/ci/stage.rb
View file @
8dbd1e7d
...
@@ -39,5 +39,13 @@ module Ci
...
@@ -39,5 +39,13 @@ module Ci
def
builds
def
builds
@builds
||=
pipeline
.
builds
.
where
(
stage:
name
)
@builds
||=
pipeline
.
builds
.
where
(
stage:
name
)
end
end
def
success?
status
.
to_s
==
'success'
end
def
has_warnings?
statuses
.
latest
.
failed_but_allowed
.
any?
end
end
end
end
end
lib/gitlab/ci/status/pipeline/factory.rb
View file @
8dbd1e7d
...
@@ -4,7 +4,7 @@ module Gitlab
...
@@ -4,7 +4,7 @@ module Gitlab
module
Pipeline
module
Pipeline
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
def
self
.
extended_statuses
def
self
.
extended_statuses
[
Pipeline
::
SuccessWarning
]
[
Status
::
SuccessWarning
]
end
end
def
self
.
common_helpers
def
self
.
common_helpers
...
...
lib/gitlab/ci/status/pipeline/success_warning.rb
deleted
100644 → 0
View file @
8b30dd98
module
Gitlab
module
Ci
module
Status
module
Pipeline
class
SuccessWarning
<
Status
::
SuccessWarning
def
self
.
matches?
(
pipeline
,
user
)
pipeline
.
success?
&&
pipeline
.
has_warnings?
end
end
end
end
end
end
lib/gitlab/ci/status/stage/factory.rb
View file @
8dbd1e7d
...
@@ -3,6 +3,10 @@ module Gitlab
...
@@ -3,6 +3,10 @@ module Gitlab
module
Status
module
Status
module
Stage
module
Stage
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
def
self
.
extended_statuses
[
Status
::
SuccessWarning
]
end
def
self
.
common_helpers
def
self
.
common_helpers
Status
::
Stage
::
Common
Status
::
Stage
::
Common
end
end
...
...
lib/gitlab/ci/status/success_warning.rb
View file @
8dbd1e7d
...
@@ -2,9 +2,7 @@ module Gitlab
...
@@ -2,9 +2,7 @@ module Gitlab
module
Ci
module
Ci
module
Status
module
Status
##
##
# Abstract extended status used when pipeline/stage/build passed
# Extended status used when pipeline or stage passed conditionally.
# conditionally.
#
# This means that failed jobs that are allowed to fail were present.
# This means that failed jobs that are allowed to fail were present.
#
#
class
SuccessWarning
<
SimpleDelegator
class
SuccessWarning
<
SimpleDelegator
...
@@ -27,7 +25,7 @@ module Gitlab
...
@@ -27,7 +25,7 @@ module Gitlab
end
end
def
self
.
matches?
(
subject
,
user
)
def
self
.
matches?
(
subject
,
user
)
raise
NotImplementedError
subject
.
success?
&&
subject
.
has_warnings?
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
View file @
8dbd1e7d
...
@@ -49,11 +49,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
...
@@ -49,11 +49,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
it
'fabricates extended "success with warnings" status'
do
it
'fabricates extended "success with warnings" status'
do
expect
(
status
)
expect
(
status
)
.
to
be_a
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWarning
.
to
be_a
Gitlab
::
Ci
::
Status
::
SuccessWarning
end
end
it
'extends core status with common pipeline method
s
'
do
it
'extends core status with common pipeline method'
do
expect
(
status
).
to
have_details
expect
(
status
).
to
have_details
expect
(
status
.
details_path
).
to
include
"pipelines/
#{
pipeline
.
id
}
"
end
end
end
end
end
end
spec/lib/gitlab/ci/status/stage/factory_spec.rb
View file @
8dbd1e7d
...
@@ -42,5 +42,27 @@ describe Gitlab::Ci::Status::Stage::Factory do
...
@@ -42,5 +42,27 @@ describe Gitlab::Ci::Status::Stage::Factory do
end
end
end
end
end
end
end
context
'when stage has warnings'
do
let
(
:stage
)
do
build
(
:ci_stage
,
name:
'test'
,
status: :success
,
pipeline:
pipeline
)
end
before
do
create
(
:ci_build
,
:allowed_to_fail
,
:failed
,
stage:
'test'
,
pipeline:
stage
.
pipeline
)
end
it
'fabricates extended "success with warnings" status'
do
expect
(
status
)
.
to
be_a
Gitlab
::
Ci
::
Status
::
SuccessWarning
end
it
'extends core status with common stage method'
do
expect
(
status
).
to
have_details
expect
(
status
.
details_path
).
to
include
"pipelines/
#{
pipeline
.
id
}
#
#{
stage
.
name
}
"
end
end
end
end
end
spec/lib/gitlab/ci/status/
pipeline/
success_warning_spec.rb
→
spec/lib/gitlab/ci/status/success_warning_spec.rb
View file @
8dbd1e7d
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWarning
do
describe
Gitlab
::
Ci
::
Status
::
SuccessWarning
do
subject
do
subject
do
described_class
.
new
(
double
(
'status'
))
described_class
.
new
(
double
(
'status'
))
end
end
...
@@ -22,46 +22,52 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWarning do
...
@@ -22,46 +22,52 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWarning do
end
end
describe
'.matches?'
do
describe
'.matches?'
do
context
'when pipeline is successful'
do
let
(
:matchable
)
{
double
(
'matchable'
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
status: :success
)
context
'when matchable subject is successful'
do
before
do
allow
(
matchable
).
to
receive
(
:success?
).
and_return
(
true
)
end
end
context
'when
pipeline
has warnings'
do
context
'when
matchable subject
has warnings'
do
before
do
before
do
allow
(
pipelin
e
).
to
receive
(
:has_warnings?
).
and_return
(
true
)
allow
(
matchabl
e
).
to
receive
(
:has_warnings?
).
and_return
(
true
)
end
end
it
'is a correct match'
do
it
'is a correct match'
do
expect
(
described_class
.
matches?
(
pipelin
e
,
double
)).
to
eq
true
expect
(
described_class
.
matches?
(
matchabl
e
,
double
)).
to
eq
true
end
end
end
end
context
'when pipeline does not have warnings'
do
context
'when matchable subject does not have warnings'
do
before
do
allow
(
matchable
).
to
receive
(
:has_warnings?
).
and_return
(
false
)
end
it
'does not match'
do
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipelin
e
,
double
)).
to
eq
false
expect
(
described_class
.
matches?
(
matchabl
e
,
double
)).
to
eq
false
end
end
end
end
end
end
context
'when
pipeline
is not successful'
do
context
'when
matchable subject
is not successful'
do
let
(
:pipeline
)
do
before
do
create
(
:ci_pipeline
,
status: :skipped
)
allow
(
matchable
).
to
receive
(
:success?
).
and_return
(
false
)
end
end
context
'when
pipeline
has warnings'
do
context
'when
matchable subject
has warnings'
do
before
do
before
do
allow
(
pipelin
e
).
to
receive
(
:has_warnings?
).
and_return
(
true
)
allow
(
matchabl
e
).
to
receive
(
:has_warnings?
).
and_return
(
true
)
end
end
it
'does not match'
do
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipelin
e
,
double
)).
to
eq
false
expect
(
described_class
.
matches?
(
matchabl
e
,
double
)).
to
eq
false
end
end
end
end
context
'when
pipeline
does not have warnings'
do
context
'when
matchable subject
does not have warnings'
do
it
'does not match'
do
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipelin
e
,
double
)).
to
eq
false
expect
(
described_class
.
matches?
(
matchabl
e
,
double
)).
to
eq
false
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