firespring_dev_commands 2.2.1.pre.alpha.1 → 2.2.1.pre.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b28be62e65a274b5dc6b3ac1476d926c6d1c9232a845a31279ca5f03d626a5d
4
- data.tar.gz: 57ecb8d254a210ecc99b787577a58ea9e00fb761df350990fd9607c757ee71e6
3
+ metadata.gz: 7f7ee4edb84fcf55633780edce93e62119ba287da59fd45ce4a7b06109ce9e75
4
+ data.tar.gz: 3344e8910159e5b5df252b807b006c366956ce0220b2b65d6e5a92be9e958484
5
5
  SHA512:
6
- metadata.gz: 5c8a062464820475012a32d643b62e68fba662fa6e1e0d87e5b5658d08916922000f62d35cd92708c8bdb765b382c08bf5f8dd64f7f4cb175591ec635f33e09e
7
- data.tar.gz: 051f0483014854cc8bb4644c734b5b5b6171c5ec4dfd720f359c6b6c7e7b9d1beedcaae8975d8a65377be04b9f4e2393d2fa7bcc2af6a3df09da6a503cccf1aa
6
+ metadata.gz: 6f93bd21df947af3689c965be24f664fe23841c522ab2a90c2fe0b1b4642f774805426da93ffab856c03ec99e77bd06e4b5af5a83d40c833fb217826c991566a
7
+ data.tar.gz: 80cd78d0f4f92c7334c2908d317596782b2bec357d556983388ee6cf97e623f9210853a928f1e4823fa2536cbec0dd97af3f9243ecb3e48ee8bb244569e68bbf
@@ -7,7 +7,7 @@ module Dev
7
7
  # By default, the subshell is connected to the stdin/stdout/stderr of the current program
8
8
  # By default, the current environment is passed to the subshell
9
9
  # You can capture the output of the command by setting capture to true
10
- def run_command(command, stdin: $stdin, stdout: $stdout, stderr: $stderr, env: ENV, capture: false, fail_on_error: true)
10
+ def run_command(command, stdin: $stdin, stdout: $stdout, stderr: $stderr, env: ENV, capture: false)
11
11
  command = Array(command)
12
12
  output = nil
13
13
 
@@ -31,7 +31,7 @@ module Dev
31
31
  unless result.exitstatus.zero?
32
32
  puts output if capture
33
33
  LOG.error "#{result.exitstatus} exit status while running [ #{command.join(' ')} ]\n".red
34
- exit result.exitstatus if fail_on_error
34
+ exit result.exitstatus
35
35
  end
36
36
 
37
37
  output
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'git'
3
+ require 'octokit'
3
4
 
4
5
  module Dev
5
6
  # Class for performing git functions
@@ -408,7 +409,10 @@ module Dev
408
409
  # Clones the repo_name into the dir
409
410
  # Optionally specify a repo_org
410
411
  # Optionally specify a branch to check out (defaults to the repository default branch)
411
- def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil, depth: nil)
412
+ def clone_repo(dir:, repo_name:, repo_org: nil, branch: nil, depth: nil)
413
+ # TODO: Split out the default of 'firespring' into a configuration variable
414
+ repo_org = 'firespring' if repo_org.to_s.strip.empty?
415
+
412
416
  if Dir.exist?("#{dir}/.git")
413
417
  puts "#{dir} already cloned".light_green
414
418
  return
@@ -425,6 +429,22 @@ module Dev
425
429
  g.fetch('origin', prune: true)
426
430
  end
427
431
 
432
+ def commit_status(token:, repo_name:, branch:, status:, repo_org: nil, options: {})
433
+ # TODO: Split out the default of 'firespring' into a configuration variable
434
+ repo_org = 'firespring' if repo_org.to_s.strip.empty?
435
+
436
+ # Set up the GitHub client
437
+ client = Octokit::Client.new(access_token: token)
438
+
439
+ # Fetch the latest commit SHA for the given branch
440
+ repo = "#{repo_org}/#{repo_name}"
441
+ ref = "heads/#{branch}"
442
+ sha = client.ref(repo, ref).object.sha
443
+
444
+ # Create the commit status
445
+ client.create_status(repo, sha, status, options)
446
+ end
447
+
428
448
  # Builds an ssh repo URL using the org and repo name given
429
449
  def ssh_repo_url(name, org)
430
450
  "git@github.com:#{org}/#{name}.git"
@@ -159,6 +159,154 @@ module Dev
159
159
  end
160
160
  end
161
161
  end
162
+
163
+ # Create the rake task for the git commit status pending task.
164
+ def create_commit_status_pending_task!
165
+ # Have to set a local variable to be accessible inside of the instance_eval block
166
+ exclude = @exclude
167
+
168
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
169
+ namespace :git do
170
+ return if exclude.include?(:commit_status)
171
+
172
+ namespace :commit_status do
173
+ desc 'Add pending status to commit' \
174
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
175
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
176
+ "\n\tuse BRANCH=abc123 to specify the branch of code (required)" \
177
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
178
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
179
+ task :pending do
180
+ status = 'pending'
181
+ token = ENV['GITHUB_TOKEN'].to_s.strip
182
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
183
+ branch = ENV['BRANCH'].to_s.strip
184
+
185
+ raise 'GITHUB_TOKEN is required' unless token
186
+ raise 'Repository name is required' unless repo_name
187
+ raise 'Branch name is required' unless branch
188
+
189
+ options = {}
190
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
191
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
192
+
193
+ Dev::Git.new.commit_status(token:, repo_name:, branch:, status:, repo_org:, options:)
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+
200
+ # Create the rake task for the git commit status success task.
201
+ def create_commit_status_success_task!
202
+ # Have to set a local variable to be accessible inside of the instance_eval block
203
+ exclude = @exclude
204
+
205
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
206
+ namespace :git do
207
+ return if exclude.include?(:commit_status)
208
+
209
+ namespace :commit_status do
210
+ desc 'Add success status to commit' \
211
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
212
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
213
+ "\n\tuse BRANCH=abc123 to specify the branch of code (required)" \
214
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
215
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
216
+ task :success do
217
+ status = 'success'
218
+ token = ENV['GITHUB_TOKEN'].to_s.strip
219
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
220
+ branch = ENV['BRANCH'].to_s.strip
221
+
222
+ raise 'GITHUB_TOKEN is required' unless token
223
+ raise 'Repository name is required' unless repo_name
224
+ raise 'Branch name is required' unless branch
225
+
226
+ options = {}
227
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
228
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
229
+
230
+ Dev::Git.new.commit_status(token:, repo_name:, branch:, status:, repo_org:, options:)
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
236
+
237
+ # Create the rake task for the git commit status error task.
238
+ def create_commit_status_error_task!
239
+ # Have to set a local variable to be accessible inside of the instance_eval block
240
+ exclude = @exclude
241
+
242
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
243
+ namespace :git do
244
+ return if exclude.include?(:commit_status)
245
+
246
+ namespace :commit_status do
247
+ desc 'Add error status to commit' \
248
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
249
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
250
+ "\n\tuse BRANCH=abc123 to specify the branch of code (required)" \
251
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
252
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
253
+ task :error do
254
+ status = 'error'
255
+ token = ENV['GITHUB_TOKEN'].to_s.strip
256
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
257
+ branch = ENV['BRANCH'].to_s.strip
258
+
259
+ raise 'GITHUB_TOKEN is required' unless token
260
+ raise 'Repository name is required' unless repo_name
261
+ raise 'Branch name is required' unless branch
262
+
263
+ options = {}
264
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
265
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
266
+
267
+ Dev::Git.new.commit_status(token:, repo_name:, branch:, status:, repo_org:, options:)
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ # Create the rake task for the git commit status failure task.
275
+ def create_commit_status_failure_task!
276
+ # Have to set a local variable to be accessible inside of the instance_eval block
277
+ exclude = @exclude
278
+
279
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
280
+ namespace :git do
281
+ return if exclude.include?(:commit_status)
282
+
283
+ namespace :commit_status do
284
+ desc 'Add failure status to commit' \
285
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
286
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
287
+ "\n\tuse BRANCH=abc123 to specify the branch of code (required)" \
288
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
289
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
290
+ task :failure do
291
+ status = 'failure'
292
+ token = ENV['GITHUB_TOKEN'].to_s.strip
293
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
294
+ branch = ENV['BRANCH'].to_s.strip
295
+
296
+ raise 'GITHUB_TOKEN is required' unless token
297
+ raise 'Repository name is required' unless repo_name
298
+ raise 'Branch name is required' unless branch
299
+
300
+ options = {}
301
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
302
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
303
+
304
+ Dev::Git.new.commit_status(token:, repo_name:, branch:, status:, repo_org:, options:)
305
+ end
306
+ end
307
+ end
308
+ end
309
+ end
162
310
  end
163
311
  end
164
312
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.2.1.pre.alpha.1'.freeze
9
+ VERSION = '2.2.1.pre.alpha.3'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.pre.alpha.1
4
+ version: 2.2.1.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-10 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: 2.8.1
223
+ - !ruby/object:Gem::Dependency
224
+ name: faraday-retry
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '2.0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '2.0'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: git
225
239
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +276,20 @@ dependencies:
262
276
  - - "~>"
263
277
  - !ruby/object:Gem::Version
264
278
  version: 2.3.0
279
+ - !ruby/object:Gem::Dependency
280
+ name: octokit
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '8.1'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '8.1'
265
293
  - !ruby/object:Gem::Dependency
266
294
  name: ox
267
295
  requirement: !ruby/object:Gem::Requirement