ci_toolkit 1.5.21 → 1.5.23

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: c1e460504bc5d274e82021dacfcd7065ff46b65ca747956a0809d734e0985d8f
4
- data.tar.gz: 938bfce127bc20430c4543bb6fefda1b5ae203563ae8234950724578f57c1015
3
+ metadata.gz: daf8706f40db455565b6b237d4dfcf563239516fdff0cdc79ccc109923f42f5c
4
+ data.tar.gz: 9c042f0747d5ca6cfbaae07d728275555d7491e211e2c81e13c962b4b352bfb8
5
5
  SHA512:
6
- metadata.gz: 6964d3d2d9e1108b8513aabb6011501b5db2ee0eebe85e7ef4e253e952b81acfbd89148ba496524fffed5f1e790d2f6e3455a79e8e82cf75f0590d8021290dae
7
- data.tar.gz: 5238ece91784b8962584eab1d057943b7f3d1dc23814bdfa3fc8622e040b76ad69dec80484b4917dd1f2fb61847d30325df284067b573a57f659927cc7d0b108
6
+ metadata.gz: 708160a8dbfbbb60740a98225b53c2935f01e5db6ae94b91c091b0f18ccda14c080626c1260299cde74005b2ea366b548c6dd08b14314d58ba964b98f0f2e9a2
7
+ data.tar.gz: 71721b7bab9067e2a3ba7bb4751481e2093a9b47abeb7a135c5371f84ff1ea95b414ae9437e3409ccd93a0db8fd5b02b1cde72863577bb92f3acea4baa393d99
@@ -1,5 +1,5 @@
1
1
  # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
- ARG VARIANT=2-bullseye
2
+ ARG VARIANT=3-bullseye
3
3
  FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4
4
 
5
5
  # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
4
  NewCops: enable
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 3.2
6
6
 
7
7
  Style/StringLiterals:
8
8
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.5.21)
4
+ ci_toolkit (1.5.23)
5
5
  faraday
6
6
  faraday-multipart
7
7
  faraday_middleware
@@ -60,13 +60,13 @@ GEM
60
60
  sawyer (~> 0.8.0, >= 0.5.3)
61
61
  openssl (2.2.1)
62
62
  ipaddr
63
- parallel (1.21.0)
64
- parser (3.0.2.0)
63
+ parallel (1.23.0)
64
+ parser (3.2.2.1)
65
65
  ast (~> 2.4.1)
66
66
  public_suffix (4.0.6)
67
- rainbow (3.0.0)
67
+ rainbow (3.1.1)
68
68
  rake (13.0.6)
69
- regexp_parser (2.1.1)
69
+ regexp_parser (2.8.0)
70
70
  rexml (3.2.5)
71
71
  rspec (3.10.0)
72
72
  rspec-core (~> 3.10.0)
@@ -81,22 +81,23 @@ GEM
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
82
  rspec-support (~> 3.10.0)
83
83
  rspec-support (3.10.2)
84
- rubocop (1.21.0)
84
+ rubocop (1.51.0)
85
+ json (~> 2.3)
85
86
  parallel (~> 1.10)
86
- parser (>= 3.0.0.0)
87
+ parser (>= 3.2.0.0)
87
88
  rainbow (>= 2.2.2, < 4.0)
88
89
  regexp_parser (>= 1.8, < 3.0)
89
- rexml
90
- rubocop-ast (>= 1.9.1, < 2.0)
90
+ rexml (>= 3.2.5, < 4.0)
91
+ rubocop-ast (>= 1.28.0, < 2.0)
91
92
  ruby-progressbar (~> 1.7)
92
- unicode-display_width (>= 1.4.0, < 3.0)
93
- rubocop-ast (1.11.0)
94
- parser (>= 3.0.1.1)
93
+ unicode-display_width (>= 2.4.0, < 3.0)
94
+ rubocop-ast (1.28.1)
95
+ parser (>= 3.2.1.0)
95
96
  rubocop-rake (0.6.0)
96
97
  rubocop (~> 1.0)
97
98
  rubocop-rspec (2.5.0)
98
99
  rubocop (~> 1.19)
99
- ruby-progressbar (1.11.0)
100
+ ruby-progressbar (1.13.0)
100
101
  ruby2_keywords (0.0.5)
101
102
  sawyer (0.8.2)
102
103
  addressable (>= 2.3.5)
data/Rakefile CHANGED
@@ -6,3 +6,7 @@ require "rubocop/rake_task"
6
6
  RuboCop::RakeTask.new
7
7
 
8
8
  task default: :rubocop
9
+
10
+ task :rubocop do
11
+ sh "rubocop -A"
12
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ci_toolkit"
5
+ spec.version = "1.5.23"
6
+ spec.authors = ["Gero Keller"]
7
+ spec.email = ["gero.f.keller@gmail.com"]
8
+
9
+ spec.summary = "Set of CI utilities"
10
+ spec.description = "Set of tools making it easier to interact between Github PRs and Bitrise CI"
11
+ spec.homepage = "https://github.com/crvshlab/ci_toolkit"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = ">= 3.2"
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/crvshlab/ci_toolkit"
19
+ spec.metadata["changelog_uri"] = "https://github.com/crvshlab/ci_toolkit/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # rubocop:disable Gemspec/DevelopmentDependencies
33
+ spec.add_dependency "faraday"
34
+ spec.add_dependency "faraday_middleware"
35
+ spec.add_dependency "faraday-multipart"
36
+ spec.add_dependency "gitlab"
37
+ spec.add_dependency "jwt"
38
+ spec.add_dependency "octokit"
39
+ spec.add_dependency "openssl"
40
+ spec.add_dependency "time"
41
+
42
+ spec.add_development_dependency "rspec", "~> 3.2"
43
+ spec.add_development_dependency "rubocop", "~> 1.7"
44
+ spec.add_development_dependency "rubocop-rake"
45
+ spec.add_development_dependency "rubocop-rspec"
46
+ spec.add_development_dependency "simplecov"
47
+ spec.add_development_dependency "simplecov-json"
48
+ spec.metadata["rubygems_mfa_required"] = "true"
49
+ # rubocop:enable Gemspec/DevelopmentDependencies
50
+ end
@@ -11,10 +11,10 @@ module CiToolkit
11
11
 
12
12
  # noinspection Metrics/ParameterLists
13
13
  def initialize(options = {
14
- build_number: ENV["BITRISE_BUILD_NUMBER"],
15
- token: ENV["BITRISE_TOKEN"],
16
- app_slug: ENV["BITRISE_APP_SLUG"],
17
- build_slug: ENV["BITRISE_BUILD_SLUG"]
14
+ build_number: ENV.fetch("BITRISE_BUILD_NUMBER", nil),
15
+ token: ENV.fetch("BITRISE_TOKEN", nil),
16
+ app_slug: ENV.fetch("BITRISE_APP_SLUG", nil),
17
+ build_slug: ENV.fetch("BITRISE_BUILD_SLUG", nil)
18
18
  },
19
19
  faraday = nil)
20
20
  @build_number = options[:build_number].to_i
@@ -42,7 +42,7 @@ module CiToolkit
42
42
  @connection.post("/#{API_VERSION}/apps/#{@app_slug}/builds", {
43
43
  hook_info: { type: "bitrise" },
44
44
  build_params: {
45
- branch: branch,
45
+ branch:,
46
46
  branch_dest: "develop",
47
47
  pull_request_id: pull_request,
48
48
  workflow_id: workflow,
@@ -63,7 +63,7 @@ module CiToolkit
63
63
 
64
64
  def find_pull_request_builds(pull_request, branch, commit = nil)
65
65
  response = @connection.get("/#{API_VERSION}/apps/#{@app_slug}/builds", {
66
- branch: branch,
66
+ branch:,
67
67
  pull_request_id: pull_request.to_i,
68
68
  status: 0 # status: 0 == not finished
69
69
  })
@@ -13,17 +13,17 @@ module CiToolkit
13
13
  :repository_slug
14
14
 
15
15
  def initialize(options = {
16
- build_number: ENV["BITRISE_BUILD_NUMBER"],
17
- build_url: ENV["BITRISE_BUILD_URL"],
18
- pull_request_number: ENV["BITRISE_PULL_REQUEST"],
16
+ build_number: ENV.fetch("BITRISE_BUILD_NUMBER", nil),
17
+ build_url: ENV.fetch("BITRISE_BUILD_URL", nil),
18
+ pull_request_number: ENV.fetch("BITRISE_PULL_REQUEST", nil),
19
19
  build_from_cron_job: !ENV["BITRISE_SCHEDULED_BUILD"].nil?,
20
20
  repository_owner: ENV["BITRISEIO_GIT_REPOSITORY_OWNER"] || "crvshlab",
21
- repository_slug: ENV["BITRISEIO_GIT_REPOSITORY_SLUG"],
22
- app_url: ENV["BITRISE_APP_URL"],
23
- app_slug: ENV["BITRISE_APP_SLUG"],
24
- git_branch: ENV["BITRISE_GIT_BRANCH"],
25
- git_commit: ENV["BITRISE_GIT_COMMIT"],
26
- api_token: ENV["BITRISE_TOKEN"]
21
+ repository_slug: ENV.fetch("BITRISEIO_GIT_REPOSITORY_SLUG", nil),
22
+ app_url: ENV.fetch("BITRISE_APP_URL", nil),
23
+ app_slug: ENV.fetch("BITRISE_APP_SLUG", nil),
24
+ git_branch: ENV.fetch("BITRISE_GIT_BRANCH", nil),
25
+ git_commit: ENV.fetch("BITRISE_GIT_COMMIT", nil),
26
+ api_token: ENV.fetch("BITRISE_TOKEN", nil)
27
27
  })
28
28
  @build_number = options[:build_number]
29
29
  @build_url = options[:build_url]
@@ -107,13 +107,13 @@ module CiToolkit
107
107
  # values for the two services are different
108
108
  # It uses the ENV["DVCS_SERVICE"] to decide which DVCS to use.
109
109
  class DvcsPrUtil
110
- def self.status_state_error(service = ENV["DVCS_SERVICE"])
110
+ def self.status_state_error(service = ENV.fetch("DVCS_SERVICE", nil))
111
111
  status = "error"
112
112
  status = "failed" if service == "gitlab"
113
113
  status
114
114
  end
115
115
 
116
- def self.status_state_pending(service = ENV["DVCS_SERVICE"])
116
+ def self.status_state_pending(service = ENV.fetch("DVCS_SERVICE", nil))
117
117
  status = "pending"
118
118
  status = "running" if service == "gitlab"
119
119
  status
@@ -12,7 +12,7 @@ module CiToolkit
12
12
  private_constant :SERVICES
13
13
 
14
14
  def self.create(bitrise_env = CiToolkit::BitriseEnv.new)
15
- service = ENV["DVCS_SERVICE"]
15
+ service = ENV.fetch("DVCS_SERVICE", nil)
16
16
  (SERVICES[service.to_s.downcase] || CiToolkit::DvcsPr).new bitrise_env
17
17
  end
18
18
  end
@@ -10,7 +10,8 @@ module CiToolkit
10
10
  class Credentials
11
11
  attr_reader :app_id
12
12
 
13
- def initialize(app_id = ENV["CRVSH_BOT_GITHUB_APP_ID"], private_key = ENV["CRVSH_BOT_GITHUB_APP_PRIVATE_KEY"])
13
+ def initialize(app_id = ENV.fetch("CRVSH_BOT_GITHUB_APP_ID", nil),
14
+ private_key = ENV.fetch("CRVSH_BOT_GITHUB_APP_PRIVATE_KEY", nil))
14
15
  @app_id = app_id.to_i
15
16
  @private_key = private_key
16
17
  end
@@ -71,7 +71,7 @@ module CiToolkit
71
71
  @repo_slug,
72
72
  @commit_sha,
73
73
  state,
74
- { context: context, target_url: target_url, description: description }
74
+ { context:, target_url:, description: }
75
75
  )
76
76
  end
77
77
 
@@ -12,8 +12,8 @@ module CiToolkit
12
12
  attr_reader :endpoint, :project_access_token
13
13
 
14
14
  def initialize(
15
- endpoint = ENV["GITLAB_API_URL"],
16
- project_access_token = ENV["GITLAB_PROJECT_ACCESS_TOKEN"]
15
+ endpoint = ENV.fetch("GITLAB_API_URL", nil),
16
+ project_access_token = ENV.fetch("GITLAB_PROJECT_ACCESS_TOKEN", nil)
17
17
  )
18
18
  @endpoint = endpoint
19
19
  @project_access_token = project_access_token
@@ -73,7 +73,7 @@ module CiToolkit
73
73
  @repo_slug,
74
74
  @commit_sha,
75
75
  state,
76
- { name: context, target_url: target_url, description: description }
76
+ { name: context, target_url:, description: }
77
77
  )
78
78
  end
79
79
 
@@ -23,10 +23,10 @@ module CiToolkit
23
23
  file_name:
24
24
  )
25
25
  release_details = {
26
- name: name,
27
- tag_name: tag_name,
26
+ name:,
27
+ tag_name:,
28
28
  ref: last_git_commit,
29
- description: description,
29
+ description:,
30
30
  assets: { links: [get_assets_details(project_id, tag_name, file_name)] }
31
31
  }
32
32
 
@@ -8,7 +8,7 @@ module CiToolkit
8
8
  def initialize(
9
9
  github_pr = CiToolkit::DvcsPrFactory.create(CiToolkit::BitriseEnv.new),
10
10
  git = CiToolkit::Git.new,
11
- ticket_regex_keys = ENV["SUPPORTED_JIRA_PROJECT_KEYS_REGEX"]
11
+ ticket_regex_keys = ENV.fetch("SUPPORTED_JIRA_PROJECT_KEYS_REGEX", nil)
12
12
  )
13
13
  @ticket_regex_keys = ticket_regex_keys
14
14
  @ticket = parse_ticket(github_pr.nil? ? "" : github_pr.title) || parse_ticket(git.nil? ? "" : git.branch)
@@ -13,8 +13,8 @@ module CiToolkit
13
13
  attr_reader :base_url, :access_token
14
14
 
15
15
  def initialize(
16
- base_url = ENV["SEETEST_BASE_URL"],
17
- access_token = ENV["SEETEST_ACCESS_TOKEN"]
16
+ base_url = ENV.fetch("SEETEST_BASE_URL", nil),
17
+ access_token = ENV.fetch("SEETEST_ACCESS_TOKEN", nil)
18
18
  )
19
19
  @base_url = base_url
20
20
  @access_token = access_token
@@ -27,7 +27,7 @@ module CiToolkit
27
27
  f.request :authorization, "Bearer", credentials.access_token
28
28
  f.request :multipart
29
29
  f.request :url_encoded
30
- f.response :json, parser_options: { object_class: OpenStruct }
30
+ f.response :json
31
31
  f.adapter :net_http # A MUST for file upload to work with Faraday::Multipart::FilePart
32
32
  end
33
33
  )
@@ -35,20 +35,17 @@ module CiToolkit
35
35
  ).body
36
36
 
37
37
  # Application already exists. Replace it.
38
- if response.status == SUCCESS && response.data.created == "false"
38
+ if response[:status] == SUCCESS && response[:data][:created] == "false"
39
39
  response = replace_existing_application(
40
- response.data.id,
40
+ response[:data][:id],
41
41
  project_name,
42
42
  unique_name,
43
43
  full_path_to_file,
44
44
  content_type
45
45
  )
46
46
  # Application with unique name already exist. Replace it.
47
- elsif response.status == ERROR && !response.data.nil? && !response.data.uniqueName.nil?
48
- application_info_response = faraday_get_application_info(unique_name)
49
- application_id = application_info_response[0].id
50
- response = replace_existing_application(
51
- application_id,
47
+ elsif response[:status] == ERROR && !response[:data].nil? && !response[:data][:uniqueName].nil?
48
+ response = replace_existing_application_by_unique_name(
52
49
  project_name,
53
50
  unique_name,
54
51
  full_path_to_file,
@@ -56,12 +53,12 @@ module CiToolkit
56
53
  )
57
54
  end
58
55
 
59
- unless response.status == SUCCESS
56
+ unless response[:status] == SUCCESS
60
57
  raise StandardError,
61
- "Upload response from Seetest returned an error. Response body is: '#{response.marshal_dump}'"
58
+ "Upload response from Seetest returned an error. Response body is: '#{response}'"
62
59
  end
63
60
 
64
- response.status
61
+ response[:status]
65
62
  end
66
63
  # rubocop:enable Metrics/AbcSize Metrics/MethodLength
67
64
  # rubocop:enable Metrics/MethodLength
@@ -77,12 +74,23 @@ module CiToolkit
77
74
  )
78
75
  response = faraday_delete_application(application_id)
79
76
 
80
- if response.status == SUCCESS && response.code == OKAY
77
+ if response[:status] == SUCCESS && response[:code] == OKAY
81
78
  response = faraday_upload_file_with_error_handling(project_name, unique_name, full_path_to_file, content_type)
82
79
  end
83
80
  response
84
81
  end
85
82
 
83
+ def replace_existing_application_by_unique_name(project_name, unique_name, full_path_to_file, content_type)
84
+ application_info_response = faraday_get_application_info(unique_name)
85
+ application_info_response.each do |app_response|
86
+ next unless app_response[:uniqueName] == unique_name
87
+
88
+ response = replace_existing_application(app_response[:id], project_name, unique_name, full_path_to_file,
89
+ content_type)
90
+ return response if response[:status] == SUCCESS
91
+ end
92
+ end
93
+
86
94
  def faraday_upload_file_with_error_handling(
87
95
  project_name,
88
96
  unique_name,
@@ -90,9 +98,9 @@ module CiToolkit
90
98
  content_type
91
99
  )
92
100
  response = faraday_upload(project_name, unique_name, full_path_to_file, content_type).body
93
- unless response.status == SUCCESS && response.data.created == "true"
101
+ unless response[:status] == SUCCESS && response[:data][:created] == "true"
94
102
  raise StandardError,
95
- "Upload response from Seetest returned an error. Response body is: '#{response.marshal_dump}'"
103
+ "Upload response from Seetest returned an error. Response body is: '#{response}'"
96
104
  end
97
105
 
98
106
  response
@@ -106,7 +114,7 @@ module CiToolkit
106
114
  )
107
115
  file = Faraday::Multipart::FilePart.new(full_path_to_file, content_type)
108
116
  params = {
109
- file: file,
117
+ file:,
110
118
  uniqueName: unique_name,
111
119
  project: project_name
112
120
  }
@@ -118,7 +126,7 @@ module CiToolkit
118
126
  response = @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
119
127
  if response.empty?
120
128
  raise StandardError,
121
- "Get application info for uniqueName: #{unique_name} from Seetest returned an error. "\
129
+ "Get application info for uniqueName: #{unique_name} from Seetest returned an error. " \
122
130
  "Response body is: '#{response}'"
123
131
  end
124
132
  response
@@ -126,10 +134,10 @@ module CiToolkit
126
134
 
127
135
  def faraday_delete_application(application_id)
128
136
  response = @faraday_conn.post("/api/#{API_VERSION}/applications/#{application_id}/delete").body
129
- unless response.status == SUCCESS && response.code == OKAY
137
+ unless response[:status] == SUCCESS && response[:code] == OKAY
130
138
  raise StandardError,
131
- "Delete application id: #{application_id} from Seetest returned an error. "\
132
- "Response body is: '#{response.marshal_dump}'"
139
+ "Delete application id: #{application_id} from Seetest returned an error. " \
140
+ "Response body is: '#{response}'"
133
141
  end
134
142
  response
135
143
  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.5.21
4
+ version: 1.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gero Keller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -229,6 +229,7 @@ files:
229
229
  - Rakefile
230
230
  - bin/console
231
231
  - bin/setup
232
+ - ci_toolkit.gemspec
232
233
  - duplicate_files_whitelist.txt
233
234
  - lib/ci_toolkit.rb
234
235
  - lib/ci_toolkit/bitrise_client.rb
@@ -258,6 +259,7 @@ metadata:
258
259
  homepage_uri: https://github.com/crvshlab/ci_toolkit
259
260
  source_code_uri: https://github.com/crvshlab/ci_toolkit
260
261
  changelog_uri: https://github.com/crvshlab/ci_toolkit/CHANGELOG.md
262
+ rubygems_mfa_required: 'true'
261
263
  post_install_message:
262
264
  rdoc_options: []
263
265
  require_paths:
@@ -266,14 +268,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
268
  requirements:
267
269
  - - ">="
268
270
  - !ruby/object:Gem::Version
269
- version: 2.6.0
271
+ version: '3.2'
270
272
  required_rubygems_version: !ruby/object:Gem::Requirement
271
273
  requirements:
272
274
  - - ">="
273
275
  - !ruby/object:Gem::Version
274
276
  version: '0'
275
277
  requirements: []
276
- rubygems_version: 3.0.3.1
278
+ rubygems_version: 3.4.10
277
279
  signing_key:
278
280
  specification_version: 4
279
281
  summary: Set of CI utilities