ci_toolkit 1.1.1 → 1.2.3

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: 8a0fec524e468ec5a3ae2b94076c67927b9b7d113d182331c89dc7e852969436
4
- data.tar.gz: 0c128f21987de61c07c5283a71709c35df383bb23dd4bf697669c3c14f672e04
3
+ metadata.gz: fcf70d74f81c44a53d1e29376572cc61ee57a7ccc4de59f6760b40e51cbf3269
4
+ data.tar.gz: '06944accff7798d71a65eb9197ec35312e25ec11eb0aeea8ab406bad5ce6f4d9'
5
5
  SHA512:
6
- metadata.gz: 7e39c811e40d5b330c39338b6fac6560c32809ab2ea2c2a420e9ff51b36651acf0338e3fc3dcbfb59ad90b9226478072859b7f1b11979904cee257c2ac548cd4
7
- data.tar.gz: bb637004d4a9043eda7695285c959e445a69542bacb67f8eec41417bee706ac768191b0475133264a4289b689e5ad0644df7d8201d32efacafedc5fe0911f477
6
+ metadata.gz: 34995c2d9bd64bebe00a24e20f710bdf32f0793bdefc80fadc064672109af0e29681e07af17adc9f5b0d60949e7439b3837f5cf998ee6f264758731c0c89b512
7
+ data.tar.gz: d9eb2251f6b581b5814b1635c44005294cf78b81dccc26b636981e6e4be2ec8c7e3bf58efcd8ce241e78254e86de29db56d3503faf6781f0b37c6d4478fac801
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.1.1)
4
+ ci_toolkit (1.2.3)
5
5
  faraday
6
6
  faraday_middleware
7
7
  jwt
@@ -6,7 +6,6 @@ require "faraday"
6
6
  module CiToolkit
7
7
  # client to use with the Bitrise API
8
8
  class BitriseClient
9
- HOST = "https://api.bitrise.io"
10
9
  API_VERSION = "v0.1"
11
10
  attr_reader :connection
12
11
 
@@ -15,13 +14,14 @@ module CiToolkit
15
14
  @app_slug = app_slug
16
15
  @connection = faraday
17
16
  configure_connection
17
+ @connection&.use Faraday::Response::Logger, nil, { headers: true, bodies: true }
18
18
  end
19
19
 
20
20
  def configure_connection
21
21
  return unless @connection.nil?
22
22
 
23
23
  @connection = Faraday.new(
24
- url: base_url,
24
+ url: "https://api.bitrise.io",
25
25
  headers: { "Content-Type" => "application/json", "Authorization" => @token }
26
26
  )
27
27
  @connection.use Faraday::Request::UrlEncoded
@@ -32,7 +32,7 @@ module CiToolkit
32
32
  end
33
33
 
34
34
  def create_pull_request_build(pull_request, branch, commit, workflow)
35
- @connection&.post("/apps/#{@app_slug}/builds", {
35
+ @connection&.post("/#{API_VERSION}/apps/#{@app_slug}/builds", {
36
36
  hook_info: { type: "bitrise" },
37
37
  build_params: {
38
38
  branch: branch,
@@ -46,24 +46,30 @@ module CiToolkit
46
46
 
47
47
  def abort_pull_request_builds(pull_request, branch, commit)
48
48
  find_pull_request_builds(pull_request, branch, commit).each do |build|
49
- @connection&.post("/apps/#{@app_slug}/builds/#{build[:slug]}/abort", {
49
+ @connection&.post("/#{API_VERSION}/apps/#{@app_slug}/builds/#{build[:slug]}/abort", {
50
50
  abort_reason: "Aborting due to other build failed for pull request #{pull_request}"
51
51
  })
52
52
  end
53
53
  end
54
54
 
55
55
  def find_pull_request_builds(pull_request, branch, commit)
56
- builds = @connection&.get("/apps/#{@app_slug}/builds", {
57
- branch: branch,
58
- pull_request_id: pull_request.to_i,
59
- status: 0 # status: 0 == not finished
60
- })
61
- builds&.select! { |build| build[:commit_hash] == commit }
62
- builds || []
56
+ response = @connection&.get("/#{API_VERSION}/apps/#{@app_slug}/builds", {
57
+ branch: branch,
58
+ pull_request_id: pull_request.to_i,
59
+ status: 0 # status: 0 == not finished
60
+ })
61
+ puts "Response:\n"
62
+ puts response.inspect
63
+
64
+ builds = response[:body][:data]
65
+ filter_builds_by_commit(builds, commit)
63
66
  end
64
67
 
65
- def base_url
66
- "#{HOST}/#{API_VERSION}"
68
+ def filter_builds_by_commit(builds, commit)
69
+ puts "Builds:\n"
70
+ puts builds.inspect
71
+ builds&.select! { |build| build[:commit_hash] == commit }
72
+ builds || []
67
73
  end
68
74
  end
69
75
  end
@@ -8,7 +8,8 @@ module CiToolkit
8
8
  :pull_request_number,
9
9
  :app_url,
10
10
  :git_branch,
11
- :app_slug
11
+ :app_slug,
12
+ :git_commit
12
13
 
13
14
  def initialize(options = {
14
15
  build_number: ENV["BITRISE_BUILD_NUMBER"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CiToolkit
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.3"
5
5
  end
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.1.1
4
+ version: 1.2.3
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-04 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday