danger-gitlab_reviewbot 1.1.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c66efab79926e5fe804ec34cd49c377885a0f88940fbf954d90068e33edcb3
4
- data.tar.gz: '09d54282e82e046837938f076fb051fa10e77bd3a91d2d9cf68a058dc2304225'
3
+ metadata.gz: f2886d84d0e6fb6e296379feeb66e4e183d5aa8bd8598a3f4e2713aa5b4b5927
4
+ data.tar.gz: 0b1aa53383e71c481256c8893064ca54cda389c8dad6f2dcad014d48117c8edb
5
5
  SHA512:
6
- metadata.gz: 61b5e0b675c6052711bd0d6e04d205b21bb9f314a11c46f4b031aa30e39193188c00fe80cf8ada2ccc915e8cec61621102831bde06d650153f3d7fc3439759d7
7
- data.tar.gz: 14afa37d0cc9f4afcff9f608ebde569834a69b30da6c5c4b58d7aa533dc758c241bc72f727837d592c88567ed72c2e18507bd2de0b8ea21f4073a01a215a9e49
6
+ metadata.gz: 5a4d8a9e9da4ce0883efae5cd949d18497b0e571b916443c4276a884b1fe6be2fe35a143c803665bb0d6f810a16b1687032fde49585a92066d381811ed52507a
7
+ data.tar.gz: '03528aa2084af65294610316cdff1a584c6507ccd88ed407270d87ed27029d6734e73a0ef06f4c9af5b60ce2bd68292debc456187c48107b015760b5f8a1393f'
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,19 @@
1
+ image: "ruby:2.6"
2
+
3
+ cache:
4
+ paths:
5
+ - vendor/bundle/
6
+
7
+ test:
8
+ stage: test
9
+ script:
10
+ - gem install bundler
11
+ - bundle --path vendor/bundle
12
+ - bundle exec rake spec
13
+ - bundle exec rake build
14
+ artifacts:
15
+ paths:
16
+ - rspec.xml
17
+ reports:
18
+ junit: rspec.xml
19
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-gitlab_reviewbot (1.1.1)
4
+ danger-gitlab_reviewbot (1.1.3)
5
5
  danger-gitlab
6
6
  danger-plugin-api (~> 1.0)
7
7
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['fabio.gallonetto@curve.com']
11
11
  spec.description = %q{A review raffle bot for Gitlab }
12
12
  spec.summary = %q{A review raffle bot for Gitlab.}
13
- spec.homepage = 'https://github.com/curve-technology/danger-gitlab_reviewbot'
13
+ spec.homepage = 'https://git.curve.tools/fabio.gallonetto/danger-gitlab_reviewbot'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "gitlab_reviewbot/gem_version"
data/lib/danger_plugin.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "gitlab_reviewbot/plugin"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GitlabReviewbot
2
- VERSION = "1.1.2".freeze
4
+ VERSION = "1.1.4"
3
5
  end
@@ -1,4 +1,6 @@
1
- require 'gitlab'
1
+ # frozen_string_literal: true
2
+
3
+ require "gitlab"
2
4
 
3
5
  module Gitlab
4
6
  class User
@@ -25,12 +27,12 @@ module Gitlab
25
27
  res = group_members(group_id)
26
28
 
27
29
  developer_access_level = 30
28
- res.select { |u| u.state == 'active' && u.access_level >= developer_access_level }.map { |u| User.new(u.id, u.username) }
30
+ res.select { |u| u.state == "active" && u.access_level >= developer_access_level }.map { |u| User.new(u.id, u.username) }
29
31
  end
30
32
 
31
33
  def assign_mr_to_users(project_id, mr_iid, users)
32
34
  user_ids = users.map(&:id)
33
- update_merge_request(project_id, mr_iid, 'assignee_ids' => user_ids)
35
+ update_merge_request(project_id, mr_iid, "assignee_ids" => user_ids)
34
36
  end
35
37
 
36
38
  def fetch_author_for_mr(project_id, mr_iid)
@@ -39,34 +41,34 @@ module Gitlab
39
41
  end
40
42
 
41
43
  def fetch_mrs_requiring_review(project_id)
42
- merge_requests(project_id, :state => 'opened', :per_page => '100').select { |mr| mr.merge_status != 'can_be_merged' }
44
+ merge_requests(project_id, state: "opened", per_page: "100").reject { |mr| mr.merge_status == "can_be_merged" }
43
45
  end
44
46
 
45
47
  def find_user_with_username(username)
46
- users({:username => username}).map { |u| User.new(u.id, u.username) }
48
+ users({ username: username }).map { |u| User.new(u.id, u.username) }
47
49
  end
48
50
 
49
51
  def users_with_pending_mr_review(project_id)
50
52
  outstanding_mrs = fetch_mrs_requiring_review(project_id)
51
53
  all_assignees = outstanding_mrs.reduce([]) { |acc, mr| acc + mr.assignees }
52
- assignees_id_map = all_assignees.reduce({}) { |acc, a|
53
- aid = a['id']
54
- ausername = a['username']
54
+ assignees_id_map = all_assignees.each_with_object({}) do |a, acc|
55
+ aid = a["id"]
56
+ ausername = a["username"]
55
57
  assignee = acc[aid] || User.new(aid, ausername)
56
58
  assignee.review_count += 1
57
59
  acc[aid] = assignee
58
- acc
59
- }
60
+ end
60
61
  assignees_id_map.values
61
62
  end
62
63
 
63
64
  def fetch_mr_reviewers(project_id, mr_iid)
64
- merge_request(project_id, mr_iid).assignees.map { |u| User.new(u['id'], u['username']) }
65
+ merge_request(project_id, mr_iid).assignees.map { |u| User.new(u["id"], u["username"]) }
65
66
  end
66
67
 
67
68
  private
69
+
68
70
  def search_group(group_name)
69
- short_name = group_name.split('/').last
71
+ short_name = group_name.split("/").last
70
72
  res = group_search(short_name)
71
73
  res = res.find { |i| i.full_path == group_name }
72
74
 
@@ -78,4 +80,3 @@ module Gitlab
78
80
  end
79
81
  end
80
82
  end
81
-
@@ -1,5 +1,6 @@
1
- require 'gitlab_reviewbot/strategies'
1
+ # frozen_string_literal: true
2
2
 
3
+ require "gitlab_reviewbot/strategies"
3
4
 
4
5
  module Danger
5
6
  # This is your plugin class. Any attributes or methods you expose here will
@@ -20,8 +21,7 @@ module Danger
20
21
  # @tags monday, weekends, time, rattata
21
22
  #
22
23
  class DangerGitlabReviewbot < Plugin
23
-
24
- # Define the group to take the reviewers from.
24
+ # Define the group to take the reviewers from.
25
25
  # NOTE: This is the group full path as in 'tech/iOS' instead of just the group name
26
26
  #
27
27
  # @return String
@@ -44,31 +44,10 @@ module Danger
44
44
  # * Danger::AssignStrategies::LeastBusyStrategy - assign the N users with the least amount of open MRs
45
45
  # to review
46
46
  #
47
- def strategy
48
- @strategy #|| Danger::AssignStrategies::RandomStrategy.new(client: gitlab.api, project: project_id, mr: mr_iid)
49
- end
50
-
51
47
  def strategy=(klass)
52
- @strategy = klass.new(client: gitlab.api, project: project_id, mr: mr_iid)
53
- end
54
-
55
- def project_id
56
- ENV['CI_PROJECT_ID']
57
- end
58
-
59
- def mr_iid
60
- ENV['CI_MERGE_REQUEST_IID']
48
+ @strategy = klass.new(client: gitlab.api, project: project_id, mr_iid: mr_iid)
61
49
  end
62
50
 
63
- #Once a strategy is in place, adopt the conf methods
64
- def method_missing(method, *args)
65
- super unless method.to_s.start_with? 'strategy_'
66
- if strategy.respond_to? method.to_s.delete_prefix('strategy_')
67
- strategy.send(method.to_s.delete_prefix('strategy_'), *args)
68
- else
69
- super
70
- end
71
- end
72
51
 
73
52
  # Call this method from the Dangerfile to assign reviewers to your merge requests
74
53
  # @return The usernames list of assigned reviewes [Array<String>]
@@ -82,14 +61,14 @@ module Danger
82
61
  raise "Env variable CI_PROJECT_ID doesn't point to a valid project id"
83
62
  end
84
63
 
85
- current_assignees = (ENV['CI_MERGE_REQUEST_ASSIGNEES'] || '').split(',') #buggy?
86
- already_assigned_count = current_assignees.length
87
- required_assignees_count = [assignees_amount - already_assigned_count, 0].max
64
+ current_assignees = (ENV["CI_MERGE_REQUEST_ASSIGNEES"] || "").split(",") # buggy?
65
+ # already_assigned_count = current_assignees.length
66
+ # required_assignees_count = [assignees_amount - already_assigned_count, 0].max
88
67
 
89
- puts "Project ID: #{project_id}" if verbose
90
- puts "MR IID: #{mr_iid}" if verbose
91
- puts "Currently assigned: #{current_assignees}" if verbose
92
- # puts "Required: #{required_assignees_count}" if @verbose
68
+ ui.puts "Project ID: #{project_id}" if verbose
69
+ ui.puts "MR IID: #{mr_iid}" if verbose
70
+ ui.puts "Currently assigned: #{current_assignees}" if verbose
71
+ # puts "Required: #{required_assignees_count}" if @verbose
93
72
 
94
73
  # if required_assignees_count == 0
95
74
  # puts "Nothing to do" if verbose
@@ -100,12 +79,34 @@ module Danger
100
79
 
101
80
  assignees = @strategy.assign! assignees_amount
102
81
 
103
- puts "Assigning: #{assignees}" if verbose
82
+ ui.puts "Assigning: #{assignees}" if verbose
104
83
  return assignees
105
84
  end
106
85
 
107
86
  private
108
87
 
88
+ attr_reader :strategy
89
+
90
+ def project_id
91
+ ENV["CI_PROJECT_ID"]
92
+ end
93
+
94
+ def mr_iid
95
+ ENV["CI_MERGE_REQUEST_IID"]
96
+ end
97
+
98
+ # Once a strategy is in place, adopt the conf methods
99
+ def method_missing(method, *args)
100
+ super unless method.to_s.start_with? "strategy_"
101
+ if strategy.respond_to? method.to_s.delete_prefix("strategy_")
102
+ strategy.send(method.to_s.delete_prefix("strategy_"), *args)
103
+ else
104
+ super
105
+ end
106
+ end
107
+
108
+ def respond_to_missing?(method_name, include_private = false)
109
+ method_name.to_s.start_with?("strategy_") || super
110
+ end
109
111
  end
110
112
  end
111
-
@@ -1,21 +1,22 @@
1
- require 'gitlab_reviewbot/gitlab'
1
+ # frozen_string_literal: true
2
+
3
+ require "gitlab_reviewbot/gitlab"
2
4
 
3
5
  module Danger
4
6
  module AssignStrategies
5
7
  class LeastBusyStrategy < Strategy
6
8
  def assignees(amount)
7
- users_in_group = fetch_users_in_group()
8
- author = fetch_author()
9
- invalid_assignees = [ fetch_author() ] + fetch_assigned_reviewers()
9
+ # This doesn't fetch the review count for the users so we need to fetch it separately later
10
+ users_in_group = fetch_users_in_group
11
+ invalid_assignees = [fetch_author] + fetch_assigned_reviewers
10
12
 
11
- users_with_reviews_pending = client.users_with_pending_mr_review(project_id).filter { |u| users_in_group.include? u }
12
- users_without_reviews_pending = users_in_group.filter { |u| ! users_with_reviews_pending.include? u }
13
+ group_users_with_reviews_pending = client.users_with_pending_mr_review(project_id).filter { |u| users_in_group.include? u }
14
+ group_users_without_reviews_pending = users_in_group.filter { |u| !group_users_with_reviews_pending.include? u }
13
15
 
14
- (users_with_reviews_pending + users_without_reviews_pending).filter { |u| u.id != author.id }
15
- .sort_by(&:review_count)
16
- .first(amount)
16
+ (group_users_with_reviews_pending + group_users_without_reviews_pending).filter { |u| !invalid_assignees.include? u }
17
+ .sort_by(&:review_count)
18
+ .first(amount)
17
19
  end
18
20
  end
19
21
  end
20
22
  end
21
-
@@ -1,12 +1,14 @@
1
- require 'gitlab_reviewbot/gitlab'
1
+ # frozen_string_literal: true
2
+
3
+ require "gitlab_reviewbot/gitlab"
2
4
 
3
5
  module Danger
4
6
  module AssignStrategies
5
7
  class RandomStrategy < Strategy
6
8
  def assignees(amount)
7
- invalid_assignees = [ fetch_author() ] + fetch_assigned_reviewers()
8
- fetch_users_in_group.filter { |u| ! invalid_assignees.include? u }
9
- .sample(amount)
9
+ invalid_assignees = [fetch_author] + fetch_assigned_reviewers
10
+ fetch_users_in_group.filter { |u| !invalid_assignees.include? u }
11
+ .sample(amount)
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danger
2
4
  module AssignStrategies
3
5
  class Strategy
@@ -7,25 +9,25 @@ module Danger
7
9
  attr_accessor :client
8
10
  attr_accessor :excluded_users
9
11
 
10
- def initialize(client:, project:, mr:)
12
+ def initialize(client:, project:, mr_iid:)
11
13
  @client = client
12
14
  @project_id = project
13
- @mr_iid = mr
15
+ @mr_iid = mr_iid
14
16
  @excluded_users = []
15
17
  end
16
18
 
17
19
  def assign!(amount)
18
- currently_assigned = fetch_assigned_reviewers()
20
+ currently_assigned = fetch_assigned_reviewers
19
21
  return [] if (amount - currently_assigned.length) <= 0
20
22
 
21
23
  to_be_assigned = assignees(amount - currently_assigned.length)
22
24
  all_assignees = currently_assigned + to_be_assigned
23
25
 
24
- response = client.assign_mr_to_users(project_id, mr_iid, all_assignees)
26
+ client.assign_mr_to_users(project_id, mr_iid, all_assignees)
25
27
  all_assignees.map(&:username)
26
28
  end
27
29
 
28
- def assignees(amount)
30
+ def assignees(_amount)
29
31
  raise "To be implemented in the subclasses"
30
32
  end
31
33
 
@@ -38,11 +40,13 @@ module Danger
38
40
  end
39
41
 
40
42
  def fetch_users_in_group
41
- excluded = @excluded_users.map { |u| client.find_user_with_username(u) }
42
- client.fetch_users_for_group(@group_name).filter { |u| ! excluded.include? u }
43
+ excluded = @excluded_users.map do |u|
44
+ server_user = client.find_user_with_username(u).first
45
+ raise "ERROR: Invalid username #{u} among excluded_users" if server_user.nil?
46
+ server_user
47
+ end
48
+ client.fetch_users_for_group(@group_name).filter { |u| !excluded.include? u }
43
49
  end
44
-
45
50
  end
46
51
  end
47
52
  end
48
-
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danger
2
4
  module AssignStrategies
3
- require 'gitlab_reviewbot/strategies/strategy'
4
- require 'gitlab_reviewbot/strategies/random'
5
- require 'gitlab_reviewbot/strategies/least_busy'
5
+ require "gitlab_reviewbot/strategies/strategy"
6
+ require "gitlab_reviewbot/strategies/random"
7
+ require "gitlab_reviewbot/strategies/least_busy"
6
8
  end
7
9
  end
8
-
@@ -1,4 +1,6 @@
1
- require File.expand_path("../spec_helper", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
2
4
 
3
5
  module Danger
4
6
  describe Danger::DangerGitlabReviewbot do
@@ -11,25 +13,24 @@ module Danger
11
13
  #
12
14
  describe "with Dangerfile" do
13
15
  before do
14
- testing_env.each { |k,v| ENV[k] = "#{v}" }
16
+ testing_env.each { |k, v| ENV[k] = v.to_s }
15
17
 
16
18
  @dangerfile = testing_dangerfile
17
19
  @plugin = @dangerfile.gitlab_reviewbot
18
20
  @strategy_mock = instance_double(Danger::AssignStrategies::Strategy)
19
21
  allow(Danger::AssignStrategies::RandomStrategy).to receive(:new).and_return(@strategy_mock)
20
- allow(@strategy_mock).to receive(:group_name=).with('tech/ios')
22
+ allow(@strategy_mock).to receive(:group_name=).with("tech/ios")
21
23
  @plugin.strategy = Danger::AssignStrategies::RandomStrategy
22
- @plugin.gitlab_group = 'tech/ios'
23
-
24
+ @plugin.gitlab_group = "tech/ios"
24
25
  end
25
26
 
26
27
  it "Assign one reviewer" do
27
- expect(@strategy_mock).to receive(:assign!).with(1).and_return(['Sam'])
28
+ expect(@strategy_mock).to receive(:assign!).with(1).and_return(["Sam"])
28
29
 
29
30
  @plugin.assign!
30
31
  end
31
32
  it "Assign one reviewer" do
32
- expect(@strategy_mock).to receive(:assign!).with(1).and_return(['Sam'])
33
+ expect(@strategy_mock).to receive(:assign!).with(1).and_return(["Sam"])
33
34
 
34
35
  @plugin.assign!
35
36
  end
@@ -37,7 +38,7 @@ module Danger
37
38
  it "Assign multiple reviewers" do
38
39
  @plugin.assignees_amount = 2
39
40
 
40
- expect(@strategy_mock).to receive(:assign!).with(2).and_return(['Sam, Nic'])
41
+ expect(@strategy_mock).to receive(:assign!).with(2).and_return(["Sam, Nic"])
41
42
 
42
43
  @plugin.assign!
43
44
  end
@@ -46,18 +47,16 @@ module Danger
46
47
  expect(@strategy_mock).to receive(:excluded_users=)
47
48
  expect(@strategy_mock).to receive(:excluded_users).and_return([])
48
49
 
49
- @plugin.strategy_excluded_users = ['Tom']
50
- @plugin.strategy_excluded_users << 'Sam'
51
-
50
+ @plugin.strategy_excluded_users = ["Tom"]
51
+ @plugin.strategy_excluded_users << "Sam"
52
52
  end
53
53
 
54
- ['CI_PROJECT_ID', 'CI_MERGE_REQUEST_IID'].each do |var|
54
+ ["CI_PROJECT_ID", "CI_MERGE_REQUEST_IID"].each do |var|
55
55
  it "Fails when required #{var} variables are not available" do
56
56
  ENV[var] = nil
57
- expect{@plugin.assign!}.to raise_error(RuntimeError)
57
+ expect { @plugin.assign! }.to raise_error(RuntimeError)
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
62
  end
63
-
@@ -1,15 +1,17 @@
1
- require File.expand_path("../spec_helper", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
2
4
 
3
5
  module Danger
4
6
  describe Danger::AssignStrategies::LeastBusyStrategy do
5
7
  before do
6
- testing_env.each { |k,v| ENV[k] = "#{v}" }
8
+ testing_env.each { |k, v| ENV[k] = v.to_s }
7
9
  @dangerfile = testing_dangerfile
8
10
 
9
- @sam = Gitlab::User.new(1, 'Sam')
10
- @tom = Gitlab::User.new(2, 'Tom')
11
- @nic = Gitlab::User.new(3, 'Nic')
12
- @luke = Gitlab::User.new(4, 'Luke')
11
+ @sam = Gitlab::User.new(1, "Sam")
12
+ @tom = Gitlab::User.new(2, "Tom")
13
+ @nic = Gitlab::User.new(3, "Nic")
14
+ @luke = Gitlab::User.new(4, "Luke")
13
15
 
14
16
  @mock_client = double(Gitlab::Client)
15
17
  @author = @nic
@@ -18,9 +20,8 @@ module Danger
18
20
  allow(@mock_client).to receive(:fetch_author_for_mr).and_return(@author)
19
21
  allow(@mock_client).to receive(:fetch_users_for_group).with("tech/ios").and_return(@members)
20
22
 
21
- @strategy = AssignStrategies::LeastBusyStrategy.new(client: @mock_client, project: 10, mr: 110)
23
+ @strategy = AssignStrategies::LeastBusyStrategy.new(client: @mock_client, project: 10, mr_iid: 110)
22
24
  @strategy.group_name = "tech/ios"
23
-
24
25
  end
25
26
 
26
27
  it "Assign the one least busy" do
@@ -92,16 +93,17 @@ module Danger
92
93
  @strategy.assign!(1)
93
94
  end
94
95
 
96
+ # TODO: This should go up to the superclass for testing
95
97
  it "honours excluded users" do
96
98
  allow(@mock_client).to receive(:fetch_mr_reviewers).with(10, 110).and_return([])
97
- @tom.review_count = 1
99
+ @tom.review_count = 0
98
100
  @sam.review_count = 4
99
101
  @luke.review_count = 3
100
- users_with_pending_mr_review = [@author, @sam, @tom, @luke]
102
+ users_with_pending_mr_review = [@author, @sam, @luke]
101
103
  expect(@mock_client).to receive(:users_with_pending_mr_review).and_return(users_with_pending_mr_review)
102
104
 
103
- allow(@mock_client).to receive(:find_user_with_username).with('Tom').and_return(@tom)
104
- @strategy.excluded_users = ['Tom']
105
+ allow(@mock_client).to receive(:find_user_with_username).with("Tom").and_return([@tom])
106
+ @strategy.excluded_users = ["Tom"]
105
107
 
106
108
  expect(@mock_client).to receive(:assign_mr_to_users) do |project, mr, users|
107
109
  expect(project).to be == 10
@@ -112,6 +114,22 @@ module Danger
112
114
  @strategy.assign!(1)
113
115
  end
114
116
 
117
+ it "Raises error when excluded_user is invalid" do
118
+ allow(@mock_client).to receive(:fetch_mr_reviewers).with(10, 110).and_return([])
119
+
120
+ allow(@mock_client).to receive(:find_user_with_username).with("WrongTom").and_return([])
121
+ @strategy.excluded_users = ["WrongTom"]
122
+
123
+ expect { @strategy.assign!(1) }.to raise_error("ERROR: Invalid username WrongTom among excluded_users")
124
+ end
125
+
126
+ # it "test" do
127
+ # strategy = AssignStrategies::LeastBusyStrategy.new(client: @dangerfile.gitlab.api, project: 346, mr_iid: 960)
128
+ # strategy.excluded_users << 'fabio.gallonetto'
129
+ # strategy.group_name = 'tech/ios'
130
+ # require 'pry'
131
+ # binding.pry
132
+ # puts strategy.assign!(2)
133
+ # end
115
134
  end
116
135
  end
117
-
@@ -1,17 +1,18 @@
1
- require File.expand_path("../spec_helper", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
2
4
 
3
5
  module Danger
4
6
  describe Danger::AssignStrategies::RandomStrategy do
5
7
  before do
6
- testing_env.each { |k,v| ENV[k] = "#{v}" }
8
+ testing_env.each { |k, v| ENV[k] = v.to_s }
7
9
  @dangerfile = testing_dangerfile
8
10
 
9
- @sam = Gitlab::User.new(1, 'Sam')
10
- @tom = Gitlab::User.new(2, 'Tom')
11
- @nic = Gitlab::User.new(3, 'Nic')
12
- @luke = Gitlab::User.new(4, 'Luke')
13
- @lei = Gitlab::User.new(5, 'Lei')
14
-
11
+ @sam = Gitlab::User.new(1, "Sam")
12
+ @tom = Gitlab::User.new(2, "Tom")
13
+ @nic = Gitlab::User.new(3, "Nic")
14
+ @luke = Gitlab::User.new(4, "Luke")
15
+ @lei = Gitlab::User.new(5, "Lei")
15
16
 
16
17
  @mock_client = double(Gitlab::Client)
17
18
  @author = @lei
@@ -19,7 +20,7 @@ module Danger
19
20
  allow(@mock_client).to receive(:fetch_author_for_mr).and_return(@author)
20
21
  allow(@mock_client).to receive(:fetch_users_for_group).with("tech/ios").and_return(@members)
21
22
 
22
- @strategy = AssignStrategies::RandomStrategy.new(client: @mock_client, project: 10, mr: 110)
23
+ @strategy = AssignStrategies::RandomStrategy.new(client: @mock_client, project: 10, mr_iid: 110)
23
24
  @strategy.group_name = "tech/ios"
24
25
  end
25
26
 
@@ -56,7 +57,5 @@ module Danger
56
57
 
57
58
  @strategy.assign!(2)
58
59
  end
59
-
60
60
  end
61
61
  end
62
-
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
- ROOT = Pathname.new(File.expand_path("../../", __FILE__))
4
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
3
5
  $:.unshift((ROOT + "lib").to_s)
4
6
  $:.unshift((ROOT + "spec").to_s)
5
7
 
@@ -9,7 +11,7 @@ require "pry"
9
11
  require "rspec"
10
12
  require "danger"
11
13
 
12
- if `git remote -v` == ''
14
+ if `git remote -v` == ""
13
15
  puts "You cannot run tests without setting a local git remote on this repo"
14
16
  puts "It's a weird side-effect of Danger's internals."
15
17
  exit(0)
@@ -50,14 +52,14 @@ end
50
52
  # running a PR on TravisCI
51
53
  def testing_env
52
54
  {
53
- 'CI_MERGE_REQUEST_IID' => '549',
54
- 'CI_MERGE_REQUEST_PROJECT_PATH' => '...',
55
- 'CI_MERGE_REQUEST_PROJECT_URL' => '...',
56
- 'DANGER_GITLAB_HOST' => 'github.com', # This needs to be the same as where the repo is stored due to Danger internals :facepalm:
57
- 'CI_API_V4_URL' => "https://gitlab.com/api/v4",
58
- 'CI_PROJECT_ID' => '346',
55
+ "CI_MERGE_REQUEST_IID" => "549",
56
+ "CI_MERGE_REQUEST_PROJECT_PATH" => "...",
57
+ "CI_MERGE_REQUEST_PROJECT_URL" => "...",
58
+ "DANGER_GITLAB_HOST" => "git.curve.tools", # This needs to be the same as where the repo is stored due to Danger internals :facepalm:
59
+ "CI_API_V4_URL" => "https://git.curve.tools/api/v4",
60
+ "CI_PROJECT_ID" => "346",
59
61
  "GITLAB_CI" => true,
60
- "DANGER_GITLAB_API_TOKEN" => "token-token-token"
62
+ "DANGER_GITLAB_API_TOKEN" => "jgUhHSk2vGNYYFr3QsPq"
61
63
  }
62
64
  end
63
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-gitlab_reviewbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Gallonetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-14 00:00:00.000000000 Z
11
+ date: 2020-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -200,6 +200,7 @@ extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
202
  - ".gitignore"
203
+ - ".gitlab-ci.yml"
203
204
  - ".rubocop.yml"
204
205
  - Gemfile
205
206
  - Gemfile.lock
@@ -221,7 +222,7 @@ files:
221
222
  - spec/least_busy_strategy_spec.rb
222
223
  - spec/random_strategy_spec.rb
223
224
  - spec/spec_helper.rb
224
- homepage: https://github.com/curve-technology/danger-gitlab_reviewbot
225
+ homepage: https://git.curve.tools/fabio.gallonetto/danger-gitlab_reviewbot
225
226
  licenses:
226
227
  - MIT
227
228
  metadata: {}