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
04d83aec
Commit
04d83aec
authored
Oct 22, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `performance:` to use new reports feature
parent
a5f8eab9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
11 additions
and
117 deletions
+11
-117
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+0
-6
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+6
-14
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+0
-7
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+5
-9
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+0
-4
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+0
-26
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+0
-39
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+0
-12
No files found.
ee/app/models/ee/ci/build.rb
View file @
04d83aec
...
...
@@ -8,7 +8,6 @@ module EE
extend
ActiveSupport
::
Concern
LICENSE_MANAGEMENT_FILE
=
'gl-license-management-report.json'
.
freeze
PERFORMANCE_FILE
=
'performance.json'
.
freeze
LICENSED_PARSER_FEATURES
=
{
sast: :sast
...
...
@@ -34,11 +33,6 @@ module EE
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick
(
:build
,
id
)
end
def
has_performance_json?
name_in?
(
%w[performance deploy]
)
&&
has_artifact?
(
PERFORMANCE_FILE
)
end
def
has_license_management_json?
name_in?
(
'license_management'
)
&&
has_artifact?
(
LICENSE_MANAGEMENT_FILE
)
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
04d83aec
...
...
@@ -27,7 +27,8 @@ module EE
sast:
%i[sast]
,
dependency_scanning:
%i[dependency_scanning]
,
container_scanning:
%i[container_scanning sast_container]
,
dast:
%i[dast]
dast:
%i[dast]
,
performance:
%i[:merge_request_performance_metrics]
}.
freeze
# Deprecated, to be removed in 12.0
...
...
@@ -54,6 +55,10 @@ module EE
dast:
{
names:
%w(dast)
,
files:
%w(gl-dast-report.json)
},
performance:
{
names:
%w(performance deploy)
,
files:
%w(performance.json)
}
}.
freeze
...
...
@@ -96,10 +101,6 @@ module EE
nil
end
def
performance_artifact
@performance_artifact
||=
artifacts_with_files
.
find
(
&
:has_performance_json?
)
end
def
license_management_artifact
@license_management_artifact
||=
artifacts_with_files
.
find
(
&
:has_license_management_json?
)
end
...
...
@@ -108,20 +109,11 @@ module EE
license_management_artifact
&
.
success?
end
def
has_performance_data?
performance_artifact
&
.
success?
end
def
expose_license_management_data?
project
.
feature_available?
(
:license_management
)
&&
has_license_management_data?
end
def
expose_performance_data?
project
.
feature_available?
(
:merge_request_performance_metrics
)
&&
has_performance_data?
end
def
has_security_reports?
complete?
&&
builds
.
latest
.
with_security_reports
.
any?
end
...
...
ee/app/models/ee/merge_request.rb
View file @
04d83aec
...
...
@@ -16,8 +16,6 @@ module EE
validate
:validate_approvals_before_merge
,
unless: :importing?
delegate
:performance_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:performance_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sha
,
to: :head_pipeline
,
prefix: :head_pipeline
,
allow_nil:
true
...
...
@@ -40,11 +38,6 @@ module EE
false
end
def
expose_performance_data?
!!
(
head_pipeline
&
.
expose_performance_data?
&&
base_pipeline
&
.
expose_performance_data?
)
end
def
validate_approvals_before_merge
return
true
unless
approvals_before_merge
return
true
unless
target_project
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
04d83aec
...
...
@@ -26,17 +26,13 @@ module EE
end
end
expose
:performance
,
if:
->
(
mr
,
_
)
{
mr
.
expose_performance_data?
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_performance_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
head_performance_artifact
,
path:
Ci
::
Build
::
PERFORMANCE_FILE
)
expose
:performance
,
if:
->
(
mr
,
_
)
{
head_pipeline_downloadable_path_for_report_type
(
:performance
)
}
do
expose
:head_path
do
|
merge_request
|
head_pipeline_downloadable_path_for_report_type
(
:performance
)
end
expose
:base_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
base_performance_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
merge_request
.
base_performance_artifact
,
path:
Ci
::
Build
::
PERFORMANCE_FILE
)
expose
:base_path
do
|
merge_request
|
base_pipeline_downloadable_path_for_report_type
(
:performance
)
end
end
...
...
ee/spec/models/ci/build_spec.rb
View file @
04d83aec
...
...
@@ -116,10 +116,6 @@ describe Ci::Build do
end
build_artifacts_methods
=
{
has_performance_json?:
{
filename:
Ci
::
Build
::
PERFORMANCE_FILE
,
job_names:
%w[performance deploy]
},
has_license_management_json?:
{
filename:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
job_names:
%w[license_management]
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
04d83aec
...
...
@@ -21,7 +21,6 @@ describe Ci::Pipeline do
end
PIPELINE_ARTIFACTS_METHODS
=
[
{
method: :performance_artifact
,
options:
[
Ci
::
Build
::
PERFORMANCE_FILE
,
'performance'
]
},
{
method: :license_management_artifact
,
options:
[
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
'license_management'
]
}
].
freeze
...
...
@@ -277,31 +276,6 @@ describe Ci::Pipeline do
end
end
context
'performance'
do
def
create_build
(
job_name
,
filename
)
create
(
:ci_build
,
:artifacts
,
name:
job_name
,
pipeline:
pipeline
,
options:
{
artifacts:
{
paths:
[
filename
]
}
}
)
end
it
'does not perform extra queries when calling pipeline artifacts methods after the first'
do
create_build
(
'performance'
,
'performance.json'
)
create_build
(
'license_management'
,
'gl-license-management-report.json'
)
pipeline
.
performance_artifact
expect
{
pipeline
.
license_management_artifact
}.
not_to
exceed_query_limit
(
0
)
end
end
describe
'#has_security_reports?'
do
subject
{
pipeline
.
has_security_reports?
}
...
...
ee/spec/models/merge_request_spec.rb
View file @
04d83aec
...
...
@@ -41,28 +41,6 @@ describe MergeRequest do
it
{
expect
(
subject
.
base_pipeline
).
to
eq
(
pipeline
)
}
end
describe
'#base_performance_artifact'
do
before
do
allow
(
subject
.
base_pipeline
).
to
receive
(
:performance_artifact
)
.
and_return
(
1
)
end
it
'delegates to merge request diff'
do
expect
(
subject
.
base_performance_artifact
).
to
eq
(
1
)
end
end
describe
'#head_performance_artifact'
do
before
do
allow
(
subject
.
head_pipeline
).
to
receive
(
:performance_artifact
)
.
and_return
(
1
)
end
it
'delegates to merge request diff'
do
expect
(
subject
.
head_performance_artifact
).
to
eq
(
1
)
end
end
describe
'#base_license_management_artifact'
do
before
do
allow
(
subject
.
base_pipeline
).
to
receive
(
:license_management_artifact
)
...
...
@@ -85,23 +63,6 @@ describe MergeRequest do
end
end
describe
'#expose_performance_data?'
do
context
'with performance data'
do
let
(
:pipeline
)
{
double
(
expose_performance_data?:
true
)
}
before
do
allow
(
subject
).
to
receive
(
:head_pipeline
).
and_return
(
pipeline
)
allow
(
subject
).
to
receive
(
:base_pipeline
).
and_return
(
pipeline
)
end
it
{
expect
(
subject
.
expose_performance_data?
).
to
be_truthy
}
end
context
'without performance data'
do
it
{
expect
(
subject
.
expose_performance_data?
).
to
be_falsey
}
end
end
describe
'#expose_license_management_data?'
do
before
do
allow
(
subject
.
head_pipeline
).
to
receive
(
:expose_license_management_data?
)
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
04d83aec
...
...
@@ -74,18 +74,6 @@ describe MergeRequestWidgetEntity do
end
end
it
'has performance data'
do
build
=
create
(
:ci_build
,
name:
'job'
)
allow
(
merge_request
).
to
receive_messages
(
expose_performance_data?:
true
,
base_performance_artifact:
build
,
head_performance_artifact:
build
)
expect
(
subject
.
as_json
).
to
include
(
:performance
)
end
describe
'#license_management'
do
before
do
build
=
create
(
:ci_build
,
name:
'license_management'
,
pipeline:
pipeline
)
...
...
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