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
34cc7a01
Commit
34cc7a01
authored
Jun 17, 2020
by
Vladimir Shushlin
Committed by
Oswaldo Ferreira
Jun 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add build artifact entity for release evidence
And add build artifacts to release evidence json schema
parent
ab5cf3d9
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
200 additions
and
2 deletions
+200
-2
app/serializers/evidences/release_entity.rb
app/serializers/evidences/release_entity.rb
+2
-0
app/services/releases/create_evidence_service.rb
app/services/releases/create_evidence_service.rb
+8
-2
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/serializers/ee/evidences/release_entity.rb
ee/app/serializers/ee/evidences/release_entity.rb
+16
-0
ee/app/serializers/evidences/build_artifact_entity.rb
ee/app/serializers/evidences/build_artifact_entity.rb
+17
-0
ee/app/services/ee/releases/create_evidence_service.rb
ee/app/services/ee/releases/create_evidence_service.rb
+24
-0
ee/changelogs/unreleased/32773-include-test-results-within-release-evidence-6.yml
.../32773-include-test-results-within-release-evidence-6.yml
+5
-0
ee/spec/serializers/ee/evidences/release_entity_spec.rb
ee/spec/serializers/ee/evidences/release_entity_spec.rb
+33
-0
ee/spec/serializers/evidences/build_artifact_entity_spec.rb
ee/spec/serializers/evidences/build_artifact_entity_spec.rb
+16
-0
ee/spec/serializers/evidences/evidence_entity_spec.rb
ee/spec/serializers/evidences/evidence_entity_spec.rb
+21
-0
ee/spec/services/ee/releases/create_evidence_service_spec.rb
ee/spec/services/ee/releases/create_evidence_service_spec.rb
+43
-0
spec/fixtures/api/schemas/evidences/build_artifact.json
spec/fixtures/api/schemas/evidences/build_artifact.json
+10
-0
spec/fixtures/api/schemas/evidences/release.json
spec/fixtures/api/schemas/evidences/release.json
+4
-0
No files found.
app/serializers/evidences/release_entity.rb
View file @
34cc7a01
...
@@ -11,3 +11,5 @@ module Evidences
...
@@ -11,3 +11,5 @@ module Evidences
expose
:milestones
,
using:
Evidences
::
MilestoneEntity
expose
:milestones
,
using:
Evidences
::
MilestoneEntity
end
end
end
end
Evidences
::
ReleaseEntity
.
prepend_if_ee
(
'EE::Evidences::ReleaseEntity'
)
app/services/releases/create_evidence_service.rb
View file @
34cc7a01
...
@@ -10,7 +10,7 @@ module Releases
...
@@ -10,7 +10,7 @@ module Releases
def
execute
def
execute
evidence
=
release
.
evidences
.
build
evidence
=
release
.
evidences
.
build
summary
=
Evidences
::
EvidenceSerializer
.
new
.
represent
(
evidence
)
# rubocop: disable CodeReuse/Serializer
summary
=
::
Evidences
::
EvidenceSerializer
.
new
.
represent
(
evidence
,
evidence_options
)
# rubocop: disable CodeReuse/Serializer
evidence
.
summary
=
summary
evidence
.
summary
=
summary
# TODO: fix the sha generating https://gitlab.com/gitlab-org/gitlab/-/issues/209000
# TODO: fix the sha generating https://gitlab.com/gitlab-org/gitlab/-/issues/209000
evidence
.
summary_sha
=
Gitlab
::
CryptoHelper
.
sha256
(
summary
)
evidence
.
summary_sha
=
Gitlab
::
CryptoHelper
.
sha256
(
summary
)
...
@@ -20,6 +20,12 @@ module Releases
...
@@ -20,6 +20,12 @@ module Releases
private
private
attr_reader
:release
attr_reader
:release
,
:pipeline
def
evidence_options
{}
end
end
end
end
end
Releases
::
CreateEvidenceService
.
prepend_if_ee
(
'EE::Releases::CreateEvidenceService'
)
ee/app/models/license.rb
View file @
34cc7a01
...
@@ -124,6 +124,7 @@ class License < ApplicationRecord
...
@@ -124,6 +124,7 @@ class License < ApplicationRecord
enforce_pat_expiration
enforce_pat_expiration
prometheus_alerts
prometheus_alerts
pseudonymizer
pseudonymizer
release_evidence_test_artifacts
report_approver_rules
report_approver_rules
requirements
requirements
sast
sast
...
...
ee/app/serializers/ee/evidences/release_entity.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
module
EE
module
Evidences
module
ReleaseEntity
extend
ActiveSupport
::
Concern
prepended
do
expose
:report_artifacts
,
using:
::
Evidences
::
BuildArtifactEntity
,
if:
->
(
release
)
{
release
.
project
.
feature_available?
(
:release_evidence_test_artifacts
)
}
do
|
_
,
options
|
options
[
:report_artifacts
]
end
end
end
end
end
ee/app/serializers/evidences/build_artifact_entity.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
module
Evidences
class
BuildArtifactEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:url
do
|
job
|
download_project_job_artifacts_url
(
project
,
job
)
end
private
def
project
object
.
project
end
end
end
ee/app/services/ee/releases/create_evidence_service.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
module
EE
module
Releases
module
CreateEvidenceService
extend
::
Gitlab
::
Utils
::
Override
override
:evidence_options
def
evidence_options
options
=
super
.
dup
if
release
.
project
.
feature_available?
(
:release_evidence_test_artifacts
)
options
[
:report_artifacts
]
=
report_artifacts
end
options
end
def
report_artifacts
pipeline
&
.
latest_report_builds
||
[]
end
end
end
end
ee/changelogs/unreleased/32773-include-test-results-within-release-evidence-6.yml
0 → 100644
View file @
34cc7a01
---
title
:
Add report artifacts' links to release evidence
merge_request
:
34058
author
:
type
:
added
ee/spec/serializers/ee/evidences/release_entity_spec.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
require
'spec_helper'
describe
Evidences
::
ReleaseEntity
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:release
)
{
build
(
:release
,
project:
project
)
}
context
'when report artifacts are passed'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
sha:
release
.
sha
,
project:
project
)
}
let
(
:build_test_report
)
{
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
)
}
let
(
:build_coverage_report
)
{
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
)
}
subject
{
described_class
.
new
(
release
,
report_artifacts:
[
build_test_report
,
build_coverage_report
]).
as_json
}
it
'has no report_artifacts if feature is unlicenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
false
)
expect
(
subject
).
not_to
have_key
(
:report_artifacts
)
end
it
'exposes build artifacts if feature is licenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
true
)
expect
(
subject
[
:report_artifacts
]).
to
(
contain_exactly
(
Evidences
::
BuildArtifactEntity
.
new
(
build_test_report
).
as_json
,
Evidences
::
BuildArtifactEntity
.
new
(
build_coverage_report
).
as_json
)
)
end
end
end
ee/spec/serializers/evidences/build_artifact_entity_spec.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
require
'spec_helper'
describe
Evidences
::
BuildArtifactEntity
do
include
Gitlab
::
Routing
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:entity
)
{
described_class
.
new
(
build
)
}
subject
{
entity
.
as_json
}
it
'exposes the artifacts url'
do
expect
(
subject
[
:url
]).
to
eq
(
download_project_job_artifacts_url
(
build
.
project
,
build
))
end
end
ee/spec/serializers/evidences/evidence_entity_spec.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
require
'spec_helper'
describe
Evidences
::
EvidenceEntity
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:release
)
{
create
(
:release
,
project:
project
)
}
let
(
:evidence
)
{
build
(
:evidence
,
release:
release
)
}
let
(
:schema_file
)
{
'evidences/evidence'
}
it
'matches the schema when evidence has report artifacts'
do
stub_licensed_features
(
release_evidence_test_artifacts:
true
)
pipeline
=
create
(
:ci_empty_pipeline
,
sha:
release
.
sha
,
project:
project
)
build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
)
evidence_hash
=
described_class
.
represent
(
evidence
,
report_artifacts:
[
build
]).
as_json
expect
(
evidence_hash
[
:release
][
:report_artifacts
]).
not_to
be_empty
expect
(
evidence_hash
.
to_json
).
to
match_schema
(
schema_file
)
end
end
ee/spec/services/ee/releases/create_evidence_service_spec.rb
0 → 100644
View file @
34cc7a01
# frozen_string_literal: true
require
'spec_helper'
describe
Releases
::
CreateEvidenceService
do
include
Gitlab
::
Routing
let
(
:project
)
{
create
(
:project
)
}
let
(
:release
)
{
create
(
:release
,
project:
project
)
}
context
'when pipeline with artifacts is passed'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
sha:
release
.
sha
,
project:
project
)
}
let!
(
:build_with_artifacts
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let!
(
:build_test_report
)
{
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
)
}
let!
(
:build_coverage_report
)
{
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
)
}
let
(
:service
)
{
described_class
.
new
(
release
,
pipeline:
pipeline
)
}
it
'includes test reports in evidence if feature is licenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
true
)
service
.
execute
evidence
=
Releases
::
Evidence
.
last
evidence_reports
=
evidence
.
summary
.
dig
(
'release'
,
'report_artifacts'
)
.
map
{
|
artifact
|
artifact
[
'url'
]
}
expect
(
evidence_reports
).
to
(
contain_exactly
(
download_project_job_artifacts_url
(
project
,
build_test_report
),
download_project_job_artifacts_url
(
project
,
build_coverage_report
)
)
)
end
it
'includes test reports in evidence if feature is unlincenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
false
)
service
.
execute
expect
(
Releases
::
Evidence
.
last
.
summary
[
'release'
]).
not_to
have_key
(
'report_artifacts'
)
end
end
end
spec/fixtures/api/schemas/evidences/build_artifact.json
0 → 100644
View file @
34cc7a01
{
"type"
:
"object"
,
"required"
:
[
"url"
],
"properties"
:
{
"url"
:
{
"type"
:
"string"
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/evidences/release.json
View file @
34cc7a01
...
@@ -19,6 +19,10 @@
...
@@ -19,6 +19,10 @@
"milestones"
:
{
"milestones"
:
{
"type"
:
"array"
,
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"milestone.json"
}
"items"
:
{
"$ref"
:
"milestone.json"
}
},
"report_artifacts"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"build_artifact.json"
}
}
}
},
},
"additionalProperties"
:
false
"additionalProperties"
:
false
...
...
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