ci_toolkit 1.3.8 → 1.3.13
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 +4 -4
- data/Gemfile.lock +10 -5
- data/lib/ci_toolkit/build_status.rb +50 -0
- data/lib/ci_toolkit/github_pr.rb +19 -3
- data/lib/ci_toolkit/pr_messenger.rb +9 -0
- data/lib/ci_toolkit/pr_messenger_text.rb +4 -0
- data/lib/ci_toolkit/version.rb +1 -1
- data/lib/ci_toolkit.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e409eaa7ab86b7af7a1e20cd9808ad0eeb2dcee9ac912296ec0dfe77605760a1
|
4
|
+
data.tar.gz: d79386299cd1910016581a0569896b8b62ac48ce0106493e39524ecb726d80d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f377bf2e70d5cb2b73c39aeb2c4960a9be499c0b730727d316e526283659dc2ff0f0583053495d3bce97e9f5f9766a5f0890a643f409076296999481269c0ac
|
7
|
+
data.tar.gz: 1806fb69f7a1e003118e89498fb09c81d5fe8748d548ab54517ee70ffc564f258caf21f1913453d5a06467566364bb518a78d9b07b9bd93b64684f296d3e1595
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ci_toolkit (1.3.
|
4
|
+
ci_toolkit (1.3.13)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
jwt
|
@@ -15,6 +15,7 @@ GEM
|
|
15
15
|
addressable (2.8.0)
|
16
16
|
public_suffix (>= 2.0.2, < 5.0)
|
17
17
|
ast (2.4.2)
|
18
|
+
date (3.2.0)
|
18
19
|
diff-lcs (1.4.4)
|
19
20
|
docile (1.4.0)
|
20
21
|
faraday (1.8.0)
|
@@ -36,15 +37,17 @@ GEM
|
|
36
37
|
faraday-net_http_persistent (1.2.0)
|
37
38
|
faraday-patron (1.0.0)
|
38
39
|
faraday-rack (1.0.0)
|
39
|
-
faraday_middleware (1.
|
40
|
+
faraday_middleware (1.2.0)
|
40
41
|
faraday (~> 1.0)
|
42
|
+
ipaddr (1.2.3)
|
41
43
|
json (2.5.1)
|
42
44
|
jwt (2.3.0)
|
43
45
|
multipart-post (2.1.1)
|
44
46
|
octokit (4.21.0)
|
45
47
|
faraday (>= 0.9)
|
46
48
|
sawyer (~> 0.8.0, >= 0.5.3)
|
47
|
-
openssl (2.2.
|
49
|
+
openssl (2.2.1)
|
50
|
+
ipaddr
|
48
51
|
parallel (1.21.0)
|
49
52
|
parser (3.0.2.0)
|
50
53
|
ast (~> 2.4.1)
|
@@ -95,11 +98,13 @@ GEM
|
|
95
98
|
json
|
96
99
|
simplecov
|
97
100
|
simplecov_json_formatter (0.1.3)
|
98
|
-
time (0.
|
101
|
+
time (0.2.0)
|
102
|
+
date
|
99
103
|
unicode-display_width (2.1.0)
|
100
104
|
|
101
105
|
PLATFORMS
|
102
106
|
universal-darwin-20
|
107
|
+
x86_64-darwin-21
|
103
108
|
x86_64-linux
|
104
109
|
|
105
110
|
DEPENDENCIES
|
@@ -113,4 +118,4 @@ DEPENDENCIES
|
|
113
118
|
simplecov-json
|
114
119
|
|
115
120
|
BUNDLED WITH
|
116
|
-
2.2.
|
121
|
+
2.2.30
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CiToolkit
|
4
|
+
# allows to have a combined build status for all builds that are triggered for a pull request
|
5
|
+
# it uses the description of the status check on Github to parse the number of builds remaining and total
|
6
|
+
class BuildStatus
|
7
|
+
def initialize(context = "Builds", github = CiToolkit::GithubPr.new, env = CiToolkit::BitriseEnv.new)
|
8
|
+
@context = context
|
9
|
+
@github = github
|
10
|
+
@env = env
|
11
|
+
end
|
12
|
+
|
13
|
+
def start(num_builds)
|
14
|
+
state = "pending"
|
15
|
+
target_url = @env.app_url
|
16
|
+
desc = "Finished building 0/#{num_builds}"
|
17
|
+
if num_builds.zero?
|
18
|
+
state = "success"
|
19
|
+
desc = "No builds assigned"
|
20
|
+
target_url = @env.build_url
|
21
|
+
end
|
22
|
+
|
23
|
+
@github.create_status(state, @context, target_url, desc)
|
24
|
+
end
|
25
|
+
|
26
|
+
def increment
|
27
|
+
counter = load_counter
|
28
|
+
return if counter.nil?
|
29
|
+
|
30
|
+
num_finished = counter[:num_finished] + 1
|
31
|
+
num_total = counter[:num_total]
|
32
|
+
|
33
|
+
state = "pending"
|
34
|
+
state = "success" if num_finished == num_total
|
35
|
+
|
36
|
+
@github.create_status(state, @context, @env.app_url, "Finished building #{num_finished}/#{num_total}")
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def load_counter
|
42
|
+
status = @github.get_status(@context)
|
43
|
+
return if status.nil?
|
44
|
+
|
45
|
+
description = status[:description]
|
46
|
+
build_counter = description[%r{(\d/\d)}] || "0/0"
|
47
|
+
{ num_finished: build_counter.split("/")[0].to_i, num_total: build_counter.split("/")[1].to_i }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/ci_toolkit/github_pr.rb
CHANGED
@@ -13,6 +13,7 @@ module CiToolkit
|
|
13
13
|
)
|
14
14
|
@pr_number = env.pull_request_number
|
15
15
|
@repo_slug = env.repository_path
|
16
|
+
@commit_sha = env.git_commit
|
16
17
|
@_client = client
|
17
18
|
@build_types = build_types
|
18
19
|
@access = CiToolkit::GithubAccess.new
|
@@ -41,7 +42,7 @@ module CiToolkit
|
|
41
42
|
|
42
43
|
def delete_comments_including_text(text)
|
43
44
|
comments = find_comments_including_text(text)
|
44
|
-
comments.each { |comment| delete_comment(comment[:id])
|
45
|
+
comments.each { |comment| delete_comment(comment[:id]) }
|
45
46
|
end
|
46
47
|
|
47
48
|
def delete_comment(comment_id)
|
@@ -60,16 +61,26 @@ module CiToolkit
|
|
60
61
|
client.labels_for_issue(@repo_slug, @pr_number).map { |item| item[:name] }
|
61
62
|
end
|
62
63
|
|
64
|
+
def files
|
65
|
+
client.pull_request_files(@repo_slug, @pr_number)
|
66
|
+
end
|
67
|
+
|
63
68
|
def create_status(state, context, target_url, description)
|
64
|
-
ref = client.pull_request(@repo_slug, @pr_number).[](:head).[](:sha)
|
65
69
|
client.create_status(
|
66
70
|
@repo_slug,
|
67
|
-
|
71
|
+
@commit_sha,
|
68
72
|
state,
|
69
73
|
{ context: context, target_url: target_url, description: description }
|
70
74
|
)
|
71
75
|
end
|
72
76
|
|
77
|
+
def get_status(context)
|
78
|
+
client.statuses(@repo_slug, @commit_sha).each do |status|
|
79
|
+
return status if status[:context] == context
|
80
|
+
end
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
73
84
|
def build_types
|
74
85
|
types = []
|
75
86
|
@build_types.each do |type|
|
@@ -90,6 +101,11 @@ module CiToolkit
|
|
90
101
|
lines_of_code_changed > 500
|
91
102
|
end
|
92
103
|
|
104
|
+
def realm_module_modified?
|
105
|
+
modified_files = files.select { |file| file[:filename]&.start_with? "cache/" }
|
106
|
+
modified_files.length.positive?
|
107
|
+
end
|
108
|
+
|
93
109
|
private
|
94
110
|
|
95
111
|
def client
|
@@ -46,6 +46,15 @@ module CiToolkit
|
|
46
46
|
delete(@messenger_text.lint_report_title)
|
47
47
|
end
|
48
48
|
|
49
|
+
def send_realm_modified_warning
|
50
|
+
delete_realm_modified_warning
|
51
|
+
send(@messenger_text.realm_modified_warning_title)
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete_realm_modified_warning
|
55
|
+
delete(@messenger_text.realm_modified_warning_title)
|
56
|
+
end
|
57
|
+
|
49
58
|
def send_big_pr_warning
|
50
59
|
delete_big_pr_warning
|
51
60
|
send(@messenger_text.big_pr_warning_title)
|
@@ -41,6 +41,10 @@ module CiToolkit
|
|
41
41
|
"#### Swiftlint report 🕵️♀️"
|
42
42
|
end
|
43
43
|
|
44
|
+
def realm_modified_warning_title
|
45
|
+
warning_with_message("Realm module modified. Did you remember to add migrations?")
|
46
|
+
end
|
47
|
+
|
44
48
|
def big_pr_warning_title
|
45
49
|
warning_with_message("Big PR")
|
46
50
|
end
|
data/lib/ci_toolkit/version.rb
CHANGED
data/lib/ci_toolkit.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gero Keller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- lib/ci_toolkit/bitrise_client.rb
|
203
203
|
- lib/ci_toolkit/bitrise_env.rb
|
204
204
|
- lib/ci_toolkit/build.rb
|
205
|
+
- lib/ci_toolkit/build_status.rb
|
205
206
|
- lib/ci_toolkit/duplicate_files_finder.rb
|
206
207
|
- lib/ci_toolkit/git.rb
|
207
208
|
- lib/ci_toolkit/github_access.rb
|