ci_toolkit 1.3.8 → 1.3.9
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 +1 -1
- data/lib/ci_toolkit/build_status.rb +50 -0
- data/lib/ci_toolkit/github_pr.rb +8 -2
- 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: e28c272f3fdb72564c18cd2dc76dd575126d6a513fb00033a7e41327fc3fbc59
|
4
|
+
data.tar.gz: 89f86604b9a8869886ba799f39d90961878353cbe7b1c54bc4d8d9bea81c4397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 170db6c9cb9901615ee93a70deca455a96413fd68b9dad8eb728ae77efd442a8032ee10d06dad6300fd0aadc908e2527813f61bf47552a00ae7a7b6f143eb5ff
|
7
|
+
data.tar.gz: 8802f0f9d2dc7fd8ccfc2b449f4cf37df326295c1e68dd8b97cb10954491a59c5274e1890cd3ef2d47fa7aecb80b3475ff76c2dabc0dbe812beab23601c9b82c
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -61,15 +62,20 @@ module CiToolkit
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def create_status(state, context, target_url, description)
|
64
|
-
ref = client.pull_request(@repo_slug, @pr_number).[](:head).[](:sha)
|
65
65
|
client.create_status(
|
66
66
|
@repo_slug,
|
67
|
-
|
67
|
+
@commit_sha,
|
68
68
|
state,
|
69
69
|
{ context: context, target_url: target_url, description: description }
|
70
70
|
)
|
71
71
|
end
|
72
72
|
|
73
|
+
def get_status(context)
|
74
|
+
client.statuses(@repo_slug, @commit_sha).each do |status|
|
75
|
+
return status if status[:context] == context
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
73
79
|
def build_types
|
74
80
|
types = []
|
75
81
|
@build_types.each do |type|
|
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.9
|
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-06 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
|