diff options
author | Matija Čupić <matteeyah@gmail.com> | 2019-04-16 13:06:52 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2019-04-16 13:06:52 +0200 |
commit | 0cfa25ff21322d45aaef91fc7a3dd7c570632a05 (patch) | |
tree | 11e9c6393808c22ecb0bfd3ccee945a39029145f /app/models | |
parent | fc1dfae41c7e6e1bbaa95bc4a1e087ffddfcc57b (diff) | |
download | gitlab-ce-0cfa25ff21322d45aaef91fc7a3dd7c570632a05.tar.gz |
Backport changes from EE
This backports the changes from
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/10452
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/ci/job_artifact.rb | 7 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 10 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index b8a76e662b0..5cf9bb4979a 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -104,8 +104,8 @@ module Ci where('NOT EXISTS (?)', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').trace) end - scope :with_test_reports, ->() do - with_existing_job_artifacts(Ci::JobArtifact.test_reports) + scope :with_reports, ->(reports_scope) do + with_existing_job_artifacts(reports_scope) .eager_load_job_artifacts end diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 99512a7c1dd..9695d49d18b 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -21,7 +21,8 @@ module Ci container_scanning: 'gl-container-scanning-report.json', dast: 'gl-dast-report.json', license_management: 'gl-license-management-report.json', - performance: 'performance.json' + performance: 'performance.json', + metrics: 'metrics.txt' }.freeze TYPE_AND_FORMAT_PAIRS = { @@ -29,6 +30,7 @@ module Ci metadata: :gzip, trace: :raw, junit: :gzip, + metrics: :gzip, # All these file formats use `raw` as we need to store them uncompressed # for Frontend to fetch the files and do analysis @@ -88,7 +90,8 @@ module Ci dast: 8, ## EE-specific codequality: 9, ## EE-specific license_management: 10, ## EE-specific - performance: 11 ## EE-specific + performance: 11, ## EE-specific + metrics: 12 ## EE-specific } enum file_format: { diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index b81a3cf8362..16f14fe9408 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -210,6 +210,10 @@ module Ci where(source: branch_pipeline_sources).where(ref: ref, tag: false) end + scope :with_reports, -> (reports_scope) do + where('EXISTS (?)', ::Ci::Build.latest.with_reports(reports_scope).where('ci_pipelines.id=ci_builds.commit_id').select(1)) + end + # Returns the pipelines in descending order (= newest first), optionally # limited to a number of references. # @@ -689,13 +693,13 @@ module Ci @latest_builds_with_artifacts ||= builds.latest.with_artifacts_archive.to_a end - def has_test_reports? - complete? && builds.latest.with_test_reports.any? + def has_reports?(reports_scope) + complete? && builds.latest.with_reports(reports_scope).exists? end def test_reports Gitlab::Ci::Reports::TestReports.new.tap do |test_reports| - builds.latest.with_test_reports.each do |build| + builds.latest.with_reports(Ci::JobArtifact.test_reports).each do |build| build.collect_test_reports!(test_reports) end end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 0a39a720766..251a7ff41f5 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1152,7 +1152,7 @@ class MergeRequest < ApplicationRecord end def has_test_reports? - actual_head_pipeline&.has_test_reports? + actual_head_pipeline&.has_reports?(Ci::JobArtifact.test_reports) end def predefined_variables |