ci_toolkit 1.2.9 → 1.3.10
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 +2 -2
- data/README.md +0 -4
- data/lib/ci_toolkit/build_status.rb +50 -0
- data/lib/ci_toolkit/github_pr.rb +16 -2
- 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 +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a635decd61187e106471817383acbefcd33365907c68399f5af36168cdef562f
|
4
|
+
data.tar.gz: d872b10fa6a00d5d689ef5830e0981a7a1874876f13b339a242e459721e07354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a10bbb2fe34c842167adddc19023e8600ded473673e9fefe6d75591e8577316c4cc816c276642af856f3e7591cef4350bda4ffdcfd87b9537eb1723b268198a
|
7
|
+
data.tar.gz: db1b2e6a9779c4d435ece25c8790cb807378edf23f44cada785e813c8174246993c0b48d5e08a68320e109f81fa4996ad2a400ff2f4358ee96561adf7149e218
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ci_toolkit (1.
|
4
|
+
ci_toolkit (1.3.10)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
jwt
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
faraday_middleware (1.1.0)
|
40
40
|
faraday (~> 1.0)
|
41
41
|
json (2.5.1)
|
42
|
-
jwt (2.
|
42
|
+
jwt (2.3.0)
|
43
43
|
multipart-post (2.1.1)
|
44
44
|
octokit (4.21.0)
|
45
45
|
faraday (>= 0.9)
|
data/README.md
CHANGED
@@ -17,10 +17,6 @@ Or install it yourself as:
|
|
17
17
|
|
18
18
|
$ gem install ci_toolkit
|
19
19
|
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
TODO: Write usage instructions here
|
23
|
-
|
24
20
|
## Development
|
25
21
|
|
26
22
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec/test/test-unit` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -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
|
@@ -60,16 +61,25 @@ 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
|
+
end
|
82
|
+
|
73
83
|
def build_types
|
74
84
|
types = []
|
75
85
|
@build_types.each do |type|
|
@@ -90,6 +100,10 @@ module CiToolkit
|
|
90
100
|
lines_of_code_changed > 500
|
91
101
|
end
|
92
102
|
|
103
|
+
def realm_module_modified?
|
104
|
+
files&.select { |file| file[:filename]&.start_with? "cache/" }&.length&.positive?
|
105
|
+
end
|
106
|
+
|
93
107
|
private
|
94
108
|
|
95
109
|
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.
|
4
|
+
version: 1.3.10
|
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-11 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
|
@@ -234,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
235
|
- !ruby/object:Gem::Version
|
235
236
|
version: '0'
|
236
237
|
requirements: []
|
237
|
-
rubygems_version: 3.0.3
|
238
|
+
rubygems_version: 3.0.3.1
|
238
239
|
signing_key:
|
239
240
|
specification_version: 4
|
240
241
|
summary: Set of CI utilities
|