Class: Confiner::Plugins::Gitlab
- Inherits:
-
Confiner::Plugin
- Object
- Confiner::Plugin
- Confiner::Plugins::Gitlab
- Defined in:
- lib/confiner/plugins/gitlab.rb
Constant Summary collapse
- MERGE_REQUEST_TITLE =
'[QUARANTINE] %s'
- QUARANTINE_METADATA =
%(, quarantine: { issue: '%s', type: :investigating })
Instance Attribute Summary
Attributes inherited from Confiner::Plugin
Instance Method Summary collapse
-
#dequarantine ⇒ Object
Dequarantine Action - Automatically Dequarantine tests.
-
#initialize(**args) ⇒ Gitlab
constructor
A new instance of Gitlab.
-
#quarantine ⇒ Object
Quarantine Action - Automatically Quarantine tests.
Methods inherited from Confiner::Plugin
Methods included from Logger
Constructor Details
#initialize(**args) ⇒ Gitlab
Returns a new instance of Gitlab.
22 23 24 25 26 27 28 |
# File 'lib/confiner/plugins/gitlab.rb', line 22 def initialize(**args) super ENV['GITLAB_API_HTTPARTY_OPTIONS'] = ENV.fetch('GITLAB_API_HTTPARTY_OPTIONS') { "{read_timeout: #{timeout}}" } @gitlab_client = ::Gitlab.client(private_token: private_token, endpoint: endpoint) end |
Instance Method Details
#dequarantine ⇒ Object
Dequarantine Action - Automatically Dequarantine tests
74 75 76 |
# File 'lib/confiner/plugins/gitlab.rb', line 74 def dequarantine end |
#quarantine ⇒ Object
Quarantine Action - Automatically Quarantine tests
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 |
# File 'lib/confiner/plugins/gitlab.rb', line 31 def quarantine log :gitlab, 'Beginning Quarantine Process', 2 # store the examples from the pipelines @examples = get_examples @examples.select(&:failed?).map(&:name).uniq.each do |failed_example| # count the number of failures consecutively for this example number_of_failures = @examples.select { _1.name == failed_example && _1.failed? }.size if number_of_failures >= threshold example = @examples.find { _1.name == failed_example } log :quarantine, "Quarantining #{failed_example} (#{number_of_failures} >= #{threshold})", 3 # check to see if there is a merge request first # if there is no merge request... # - Check for an existing issue # - Check for an existing Quarantine MR # - Add a quarantine tag: `it 'should be quarantined', quarantine: { issue: 'https://issue', type: :investigating }` # - File the merge request begin # begin the quarantining process failure_issue = get_failure_issue_for_example(example) file_contents = get_example_file_contents(example) new_contents, changed_line_no = (file_contents, example, failure_issue) branch = create_branch(failure_issue, example) commit_changes(branch, example, new_contents) create_merge_request(example, branch, changed_line_no, failure_issue) log :quarantine, "Done Quarantining #{failed_example}", 3 rescue => e log :fatal, "There was an issue quarantining #{example}. Error was #{e.}\n#{e.backtrace}" end end end log :gitlab, 'Done with Quarantine Process', 2 end |