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
50020977
Commit
50020977
authored
Apr 27, 2020
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ci::Pipeline#latest_report_builds method
parent
76e12073
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+8
-4
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+24
-0
No files found.
app/models/ci/pipeline.rb
View file @
50020977
...
...
@@ -800,13 +800,17 @@ module Ci
@latest_builds_with_artifacts
||=
builds
.
latest
.
with_artifacts_not_expired
.
to_a
end
def
latest_report_builds
(
reports_scope
=
::
Ci
::
JobArtifact
.
with_reports
)
builds
.
latest
.
with_reports
(
reports_scope
)
end
def
has_reports?
(
reports_scope
)
complete?
&&
builds
.
latest
.
with_report
s
(
reports_scope
).
exists?
complete?
&&
latest_report_build
s
(
reports_scope
).
exists?
end
def
test_reports
Gitlab
::
Ci
::
Reports
::
TestReports
.
new
.
tap
do
|
test_reports
|
builds
.
latest
.
with_report
s
(
Ci
::
JobArtifact
.
test_reports
).
preload
(
:project
).
find_each
do
|
build
|
latest_report_build
s
(
Ci
::
JobArtifact
.
test_reports
).
preload
(
:project
).
find_each
do
|
build
|
build
.
collect_test_reports!
(
test_reports
)
end
end
...
...
@@ -828,7 +832,7 @@ module Ci
def
coverage_reports
Gitlab
::
Ci
::
Reports
::
CoverageReports
.
new
.
tap
do
|
coverage_reports
|
builds
.
latest
.
with_report
s
(
Ci
::
JobArtifact
.
coverage_reports
).
each
do
|
build
|
latest_report_build
s
(
Ci
::
JobArtifact
.
coverage_reports
).
each
do
|
build
|
build
.
collect_coverage_reports!
(
coverage_reports
)
end
end
...
...
@@ -836,7 +840,7 @@ module Ci
def
terraform_reports
::
Gitlab
::
Ci
::
Reports
::
TerraformReports
.
new
.
tap
do
|
terraform_reports
|
builds
.
latest
.
with_report
s
(
::
Ci
::
JobArtifact
.
terraform_reports
).
each
do
|
build
|
latest_report_build
s
(
::
Ci
::
JobArtifact
.
terraform_reports
).
each
do
|
build
|
build
.
collect_terraform_reports!
(
terraform_reports
)
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
50020977
...
...
@@ -2749,6 +2749,30 @@ describe Ci::Pipeline, :mailer do
end
end
describe
'#latest_report_builds'
do
it
'returns build with test artifacts'
do
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
coverage_build
=
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
project:
project
)
expect
(
pipeline
.
latest_report_builds
).
to
contain_exactly
(
test_build
,
coverage_build
)
end
it
'filters builds by scope'
do
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
,
project:
project
)
expect
(
pipeline
.
latest_report_builds
(
Ci
::
JobArtifact
.
test_reports
)).
to
contain_exactly
(
test_build
)
end
it
'only returns not retried builds'
do
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:test_reports
,
:retried
,
pipeline:
pipeline
,
project:
project
)
expect
(
pipeline
.
latest_report_builds
).
to
contain_exactly
(
test_build
)
end
end
describe
'#has_reports?'
do
subject
{
pipeline
.
has_reports?
(
Ci
::
JobArtifact
.
test_reports
)
}
...
...
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