diff options
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/ci/pipeline/artifact/code_coverage.rb | 33 | ||||
-rw-r--r-- | lib/gitlab/ci/reports/test_case.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/reports/test_suite.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/regex.rb | 4 |
4 files changed, 21 insertions, 34 deletions
diff --git a/lib/gitlab/ci/pipeline/artifact/code_coverage.rb b/lib/gitlab/ci/pipeline/artifact/code_coverage.rb deleted file mode 100644 index d8f28bde7ce..00000000000 --- a/lib/gitlab/ci/pipeline/artifact/code_coverage.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Ci - module Pipeline - module Artifact - class CodeCoverage - include Gitlab::Utils::StrongMemoize - - def initialize(pipeline_artifact) - @pipeline_artifact = pipeline_artifact - end - - def for_files(filenames) - coverage_files = raw_report["files"].select { |key| filenames.include?(key) } - - { files: coverage_files } - end - - private - - def raw_report - strong_memoize(:raw_report) do - @pipeline_artifact.each_blob do |blob| - Gitlab::Json.parse(blob) - end - end - end - end - end - end - end -end diff --git a/lib/gitlab/ci/reports/test_case.rb b/lib/gitlab/ci/reports/test_case.rb index 75898745366..15a3c862c9e 100644 --- a/lib/gitlab/ci/reports/test_case.rb +++ b/lib/gitlab/ci/reports/test_case.rb @@ -8,7 +8,7 @@ module Gitlab STATUS_FAILED = 'failed' STATUS_SKIPPED = 'skipped' STATUS_ERROR = 'error' - STATUS_TYPES = [STATUS_SUCCESS, STATUS_FAILED, STATUS_SKIPPED, STATUS_ERROR].freeze + STATUS_TYPES = [STATUS_ERROR, STATUS_FAILED, STATUS_SUCCESS, STATUS_SKIPPED].freeze attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key, :attachment, :job diff --git a/lib/gitlab/ci/reports/test_suite.rb b/lib/gitlab/ci/reports/test_suite.rb index 5ee779227ec..e9b78b841e4 100644 --- a/lib/gitlab/ci/reports/test_suite.rb +++ b/lib/gitlab/ci/reports/test_suite.rb @@ -78,11 +78,27 @@ module Gitlab end end + def sorted + sort_by_status + sort_by_execution_time_desc + self + end + private def existing_key?(test_case) @test_cases[test_case.status]&.key?(test_case.key) end + + def sort_by_status + @test_cases = @test_cases.sort_by { |status, _| Gitlab::Ci::Reports::TestCase::STATUS_TYPES.index(status) }.to_h + end + + def sort_by_execution_time_desc + @test_cases = @test_cases.keys.each_with_object({}) do |key, hash| + hash[key] = @test_cases[key].sort_by { |_key, test_case| -test_case.execution_time }.to_h + end + end end end end diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 2702dfc85ae..0f52d8ab95d 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -104,6 +104,10 @@ module Gitlab \b (?# word boundary) /ix.freeze end + + def generic_package_version_regex + /\A\d+\.\d+\.\d+\z/ + end end extend self |