ci_toolkit 1.5.3 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87feaa62793778d43ee9e9ad8cb0c80c47060e3430637deeda2f16ca8d582504
4
- data.tar.gz: f7f316e25915399f317d852fad2f9bc31ade2aab39c6ca0e0dc020641d960d62
3
+ metadata.gz: f11234ad0258930d676483a6489573cc85177c5436257785d9a9632709cd5bd5
4
+ data.tar.gz: e5d6284dbd20c33a4a4c272910cf583399f94eb5744fa1dba3bd7e9c67f133c6
5
5
  SHA512:
6
- metadata.gz: 6d84278903059b2a2ddb229d41c99c39d70ae608a33f91c0e97122f40441c33d324ef9d073776ed552e6f70871498fb50967eb5342472ed1609e714e1445963f
7
- data.tar.gz: 061eb27df8659e1b1b64a6f7b5089fa286448fbb311ce73e50bd36b497f4f8da2656c90ecfa68b6ac9a5de7810c9980a2f5a6a3b6021892b7c0042d42888d6ee
6
+ metadata.gz: bd3e440efc0fc2f7e8bc376f745ca1f2f6fba257f71d2b34b22c0e9d8c6fb1acce268ab902216f32e57fb70fa4f2ccb030a278583bbb4366cc9f6080512acb2d
7
+ data.tar.gz: 47c8697ab06e4fd4ad6c86cf08fb47b4605b2d9153a01de0c03cc26ece60d155eeadd4b6ec4d751a3f5f2d82d44d36a6c2af13dfc22db67b63de3d8ca7f92645
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.5.3)
4
+ ci_toolkit (1.5.6)
5
5
  faraday
6
6
  faraday_middleware
7
7
  gitlab
@@ -27,30 +27,29 @@ module CiToolkit
27
27
  @github.create_status(state, @context, target_url, desc)
28
28
  end
29
29
 
30
- def increment
30
+ def increment(status = CiToolkit::DvcsPrUtil.status_state_pending)
31
31
  counter = load_counter
32
32
  return if counter.nil?
33
33
 
34
34
  num_finished = counter[:num_finished] + 1
35
35
  num_total = counter[:num_total]
36
36
 
37
- state = "pending"
37
+ state = status
38
38
  state = "success" if num_finished == num_total
39
39
 
40
40
  @github.create_status(state, @context, @env.app_url, "Finished building #{num_finished}/#{num_total}")
41
41
  end
42
42
 
43
- def error
44
- @github.create_status("error", @context, @env.app_url, "Building failed")
43
+ def error(state = CiToolkit::DvcsPrUtil.status_state)
44
+ @github.create_status(state, @context, @env.app_url, "Building failed")
45
45
  end
46
46
 
47
47
  private
48
48
 
49
49
  def load_counter
50
- status = @github.get_status(@context)
51
- return if status.nil?
50
+ description = @github.get_status_description(@context)
51
+ return if description.nil?
52
52
 
53
- description = status[:description]
54
53
  build_counter = description[%r{(\d/\d)}] || "0/0"
55
54
  { num_finished: build_counter.split("/")[0].to_i, num_total: build_counter.split("/")[1].to_i }
56
55
  end
@@ -97,5 +97,26 @@ module CiToolkit
97
97
  def realm_module_modified?
98
98
  CiToolkit::DvcsPr.api_not_implemented(self)
99
99
  end
100
+
101
+ def get_status_description(_context)
102
+ CiToolkit::DvcsPr.api_not_implemented(self)
103
+ end
104
+ end
105
+
106
+ # Use this to provide commit status state for github or gitlab as
107
+ # values for the two services are different
108
+ # It uses the ENV["DVCS_SERVICE"] to decide which DVCS to use.
109
+ class DvcsPrUtil
110
+ def self.status_state(service = ENV["DVCS_SERVICE"])
111
+ status = "error"
112
+ status = "failed" if service == "gitlab"
113
+ status
114
+ end
115
+
116
+ def self.status_state_pending(service = ENV["DVCS_SERVICE"])
117
+ status = "pending"
118
+ status = "running" if service == "gitlab"
119
+ status
120
+ end
100
121
  end
101
122
  end
@@ -110,6 +110,13 @@ module CiToolkit
110
110
  modified_files.length.positive?
111
111
  end
112
112
 
113
+ def get_status_description(context)
114
+ status = get_status(context)
115
+ return if status.nil?
116
+
117
+ status[:description]
118
+ end
119
+
113
120
  private
114
121
 
115
122
  def client
@@ -74,7 +74,7 @@ module CiToolkit
74
74
  @repo_slug,
75
75
  @commit_sha,
76
76
  state,
77
- { context: context, target_url: target_url, description: description }
77
+ { name: context, target_url: target_url, description: description }
78
78
  )
79
79
  end
80
80
 
@@ -113,6 +113,13 @@ module CiToolkit
113
113
  modified_files.length.positive?
114
114
  end
115
115
 
116
+ def get_status_description(context)
117
+ status = get_status(context)
118
+ return if status.nil?
119
+
120
+ status.description
121
+ end
122
+
116
123
  private
117
124
 
118
125
  def client
@@ -6,7 +6,7 @@ module CiToolkit
6
6
  attr_reader :ticket
7
7
 
8
8
  def initialize(
9
- github_pr = CiToolkit::GithubPr.new,
9
+ github_pr = CiToolkit::DvcsPrFactory.create(CiToolkit::BitriseEnv.new),
10
10
  git = CiToolkit::Git.new,
11
11
  ticket_regex_keys = ENV["SUPPORTED_JIRA_PROJECT_KEYS_REGEX"]
12
12
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gero Keller