Sha256: 9d329f9496d7b74ae98080ec05e01bead9874cebde08bd909ef92a528dc7d501

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module GitlabQuality
  module TestTooling
    module Report
      module Concerns
        module Utils
          MAX_TITLE_LENGTH = 255

          def title_from_test(test)
            title = new_issue_title(test)

            return title unless title.length > MAX_TITLE_LENGTH

            "#{title[0...MAX_TITLE_LENGTH - 3]}..."
          end

          def new_issue_title(test)
            "#{partial_file_path(test.file)} | #{search_safe(test.name)}".strip
          end

          def partial_file_path(path)
            path.match(/((ee|api|browser_ui).*)/i)[1]
          end

          def search_safe(value)
            value.delete('"')
          end

          def pipeline
            # Gets the name of the pipeline the test was run in, to be used as the key of a scoped label
            #
            # Tests can be run in several pipelines:
            #   gitlab, nightly, staging, canary, production, preprod, MRs, and the default branch (master/main)
            #
            # Some of those run in their own project, so CI_PROJECT_NAME is the name we need. Those are:
            #   nightly, staging, canary, production, and preprod
            #
            # MR, master/main, and gitlab tests run in gitlab-qa, but we only want to report tests run on
            # master/main because the other pipelines will be monitored by the author of the MR that triggered them.
            # So we assume that we're reporting a master/main pipeline if the project name is 'gitlab'.

            @pipeline ||= Runtime::Env.pipeline_from_project_name
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-0.5.0 lib/gitlab_quality/test_tooling/report/concerns/utils.rb
gitlab_quality-test_tooling-0.4.3 lib/gitlab_quality/test_tooling/report/concerns/utils.rb
gitlab_quality-test_tooling-0.4.2 lib/gitlab_quality/test_tooling/report/concerns/utils.rb
gitlab_quality-test_tooling-0.4.1 lib/gitlab_quality/test_tooling/report/concerns/utils.rb