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
3bcd25f1
Commit
3bcd25f1
authored
May 29, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
88efa803
328740c6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
2 deletions
+97
-2
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+11
-2
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+5
-0
app/serializers/job_artifact_report_entity.rb
app/serializers/job_artifact_report_entity.rb
+13
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+12
-0
spec/models/ci/job_artifact_spec.rb
spec/models/ci/job_artifact_spec.rb
+15
-0
spec/serializers/build_details_entity_spec.rb
spec/serializers/build_details_entity_spec.rb
+9
-0
spec/serializers/job_artifact_report_entity_spec.rb
spec/serializers/job_artifact_report_entity_spec.rb
+28
-0
No files found.
app/models/ci/build.rb
View file @
3bcd25f1
...
...
@@ -765,6 +765,10 @@ module Ci
end
end
def
report_artifacts
job_artifacts
.
with_reports
end
# Virtual deployment status depending on the environment status.
def
deployment_status
return
unless
starts_environment?
...
...
app/models/ci/job_artifact.rb
View file @
3bcd25f1
...
...
@@ -26,10 +26,13 @@ module Ci
metrics:
'metrics.txt'
}.
freeze
TYPE_AND_FORMAT_PAIR
S
=
{
INTERNAL_TYPE
S
=
{
archive: :zip
,
metadata: :gzip
,
trace: :raw
,
trace: :raw
}.
freeze
REPORT_TYPES
=
{
junit: :gzip
,
metrics: :gzip
,
...
...
@@ -45,6 +48,8 @@ module Ci
performance: :raw
}.
freeze
TYPE_AND_FORMAT_PAIRS
=
INTERNAL_TYPES
.
merge
(
REPORT_TYPES
).
freeze
belongs_to
:project
belongs_to
:job
,
class_name:
"Ci::Build"
,
foreign_key: :job_id
...
...
@@ -66,6 +71,10 @@ module Ci
where
(
file_type:
types
)
end
scope
:with_reports
,
->
do
with_file_types
(
REPORT_TYPES
.
keys
.
map
(
&
:to_s
))
end
scope
:test_reports
,
->
do
with_file_types
(
TEST_REPORT_FILE_TYPES
)
end
...
...
app/serializers/build_details_entity.rb
View file @
3bcd25f1
...
...
@@ -44,6 +44,11 @@ class BuildDetailsEntity < JobEntity
end
end
expose
:report_artifacts
,
as: :reports
,
using:
JobArtifactReportEntity
,
if:
->
(
*
)
{
can?
(
current_user
,
:read_build
,
build
)
}
expose
:erased_by
,
if:
->
(
*
)
{
build
.
erased?
},
using:
UserEntity
expose
:erase_path
,
if:
->
(
*
)
{
build
.
erasable?
&&
can?
(
current_user
,
:erase_build
,
build
)
}
do
|
build
|
erase_project_job_path
(
project
,
build
)
...
...
app/serializers/job_artifact_report_entity.rb
0 → 100644
View file @
3bcd25f1
# frozen_string_literal: true
class
JobArtifactReportEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:file_type
expose
:file_format
expose
:size
expose
:download_path
do
|
artifact
|
download_project_job_artifacts_path
(
artifact
.
job
.
project
,
artifact
.
job
,
file_type:
artifact
.
file_format
)
end
end
spec/models/ci/build_spec.rb
View file @
3bcd25f1
...
...
@@ -3490,6 +3490,18 @@ describe Ci::Build do
end
end
describe
'#report_artifacts'
do
subject
{
build
.
report_artifacts
}
context
'when the build has reports'
do
let!
(
:report
)
{
create
(
:ci_job_artifact
,
:codequality
,
job:
build
)
}
it
'returns the artifacts with reports'
do
expect
(
subject
).
to
contain_exactly
(
report
)
end
end
end
describe
'#artifacts_metadata_entry'
do
set
(
:build
)
{
create
(
:ci_build
,
project:
project
)
}
let
(
:path
)
{
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
}
...
...
spec/models/ci/job_artifact_spec.rb
View file @
3bcd25f1
...
...
@@ -23,6 +23,21 @@ describe Ci::JobArtifact do
it_behaves_like
'having unique enum values'
describe
'.with_reports'
do
let!
(
:artifact
)
{
create
(
:ci_job_artifact
,
:archive
)
}
subject
{
described_class
.
with_reports
}
it
{
is_expected
.
to
be_empty
}
context
'when there are reports'
do
let!
(
:metrics_report
)
{
create
(
:ci_job_artifact
,
:junit
)
}
let!
(
:codequality_report
)
{
create
(
:ci_job_artifact
,
:codequality
)
}
it
{
is_expected
.
to
eq
([
metrics_report
,
codequality_report
])
}
end
end
describe
'.test_reports'
do
subject
{
described_class
.
test_reports
}
...
...
spec/serializers/build_details_entity_spec.rb
View file @
3bcd25f1
...
...
@@ -146,5 +146,14 @@ describe BuildDetailsEntity do
end
end
end
context
'when the build has reports'
do
let!
(
:report
)
{
create
(
:ci_job_artifact
,
:codequality
,
job:
build
)
}
it
'exposes the report artifacts'
do
expect
(
subject
[
:reports
].
count
).
to
eq
(
1
)
expect
(
subject
[
:reports
].
first
[
:file_type
]).
to
eq
(
'codequality'
)
end
end
end
end
spec/serializers/job_artifact_report_entity_spec.rb
0 → 100644
View file @
3bcd25f1
# frozen_string_literal: true
require
'spec_helper'
describe
JobArtifactReportEntity
do
let
(
:report
)
{
create
(
:ci_job_artifact
,
:codequality
)
}
let
(
:entity
)
{
described_class
.
new
(
report
,
request:
double
)
}
describe
'#as_json'
do
subject
{
entity
.
as_json
}
it
'exposes file_type'
do
expect
(
subject
[
:file_type
]).
to
eq
(
report
.
file_type
)
end
it
'exposes file_format'
do
expect
(
subject
[
:file_format
]).
to
eq
(
report
.
file_format
)
end
it
'exposes size'
do
expect
(
subject
[
:size
]).
to
eq
(
report
.
size
)
end
it
'exposes download path'
do
expect
(
subject
[
:download_path
]).
to
include
(
"jobs/
#{
report
.
job
.
id
}
/artifacts/download"
)
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