File: diffblue_cover.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (126 lines) | stat: -rw-r--r-- 4,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# frozen_string_literal: true

module Integrations
  class DiffblueCover < Integration
    field :diffblue_license_key,
      section: SECTION_TYPE_CONNECTION,
      type: :password,
      title: -> { s_('DiffblueCover|License key') },
      description: -> { s_('DiffblueCover|Diffblue Cover license key.') },
      non_empty_password_title: -> { s_('DiffblueCover|License key') },
      non_empty_password_help: -> {
        s_(
          'DiffblueCover|Leave blank to use your current license key.'
        )
      },
      exposes_secrets: true,
      required: true,
      is_secret: true,
      placeholder: 'XXXX-XXXX-XXXX-XXXX',
      help: -> {
        format(
          s_(
            'DiffblueCover|Enter your Diffblue Cover license key or ' \
            'go to %{diffblue_link} to obtain a free trial license.'
          ),
          diffblue_link: diffblue_link
        )
      }

    field :diffblue_access_token_name,
      section: SECTION_TYPE_CONFIGURATION,
      title: -> { s_('DiffblueCover|Name') },
      description: -> { s_('DiffblueCover|Access token name used by Diffblue Cover in pipelines.') },
      required: true,
      placeholder: -> { s_('DiffblueCover|My token name') }

    field :diffblue_access_token_secret,
      section: SECTION_TYPE_CONFIGURATION,
      type: :password,
      title: -> { s_('DiffblueCover|Secret') },
      description: -> { s_('DiffblueCover|Access token secret used by Diffblue Cover in pipelines.') },
      non_empty_password_title: -> { s_('DiffblueCover|Secret') },
      non_empty_password_help: -> { s_('DiffblueCover|Leave blank to use your current secret value.') },
      required: true,
      is_secret: true,
      placeholder: 'glpat-XXXXXXXXXXXXXXXXXXXX' # gitleaks:allow

    with_options if: :activated? do
      validates :diffblue_license_key, presence: true
      validates :diffblue_access_token_name, presence: true
      validates :diffblue_access_token_secret, presence: true
    end

    def self.title
      'Diffblue Cover'
    end

    def self.description
      s_('DiffblueCover|Automatically write comprehensive, human-like Java unit tests.')
    end

    def self.to_param
      'diffblue_cover'
    end

    def self.help
      s_('DiffblueCover|Automatically write comprehensive, human-like Java unit tests.')
    end

    def avatar_url
      ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/diffblue.svg')
    end

    def self.supported_events
      []
    end

    def sections
      [
        {
          type: SECTION_TYPE_CONNECTION,
          title: s_('DiffblueCover|Integration details'),
          description:
            s_(
              'DiffblueCover|Diffblue Cover is a generative AI platform that automatically ' \
              'writes comprehensive, human-like Java unit tests. Integrate Diffblue ' \
              'Cover into your CI/CD workflow for fully autonomous operation.'
            )
        },
        {
          type: SECTION_TYPE_CONFIGURATION,
          title: s_('DiffblueCover|Access token'),
          description:
            'You must have a GitLab access token for Diffblue Cover to access your project. ' \
            'Use a GitLab access token with at least the Developer role and ' \
            'the <code>api</code> and <code>write_repository</code> permissions.'
        }
      ]
    end

    def execute(_data) end

    def ci_variables
      return [] unless activated?

      [
        { key: 'DIFFBLUE_LICENSE_KEY', value: diffblue_license_key, public: false, masked: true },
        { key: 'DIFFBLUE_ACCESS_TOKEN_NAME', value: diffblue_access_token_name, public: false, masked: true },
        { key: 'DIFFBLUE_ACCESS_TOKEN', value: diffblue_access_token_secret, public: false, masked: true }
      ]
    end

    def testable?
      false
    end

    def self.diffblue_link
      ActionController::Base.helpers.link_to(
        s_('DiffblueCover|Try Diffblue Cover'),
        'https://www.diffblue.com/try-cover/gitlab/',
        target: '_blank',
        rel: 'noopener noreferrer'
      )
    end
  end
end