summaryrefslogtreecommitdiff
path: root/app/models/ci
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-04-16 12:54:47 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-16 12:54:47 +0000
commitc16619c527afdd00aa4dbbbf7544afb2f38477a8 (patch)
tree2d541ceff47cbd16a3a6ea72e0f5e65b0c7b633b /app/models/ci
parent29a53c4c31b8901f87818c86a9e8339334743616 (diff)
parent0cfa25ff21322d45aaef91fc7a3dd7c570632a05 (diff)
downloadgitlab-ce-c16619c527afdd00aa4dbbbf7544afb2f38477a8.tar.gz
Merge branch 'mc/feature/custom-metrics-ce' into 'master'
Backport metrics report type See merge request gitlab-org/gitlab-ce!26798
Diffstat (limited to 'app/models/ci')
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/models/ci/job_artifact.rb7
-rw-r--r--app/models/ci/pipeline.rb10
3 files changed, 14 insertions, 7 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 0b1f119686a..b8edaf82c3d 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_not_expired.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