bard 0.51.1 → 0.52.0

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: d28d2887b06de68d8e01f71e3f3b199e421c1d4f1f6750c24d6de0ad4d46fcae
4
- data.tar.gz: 9d63550bd03f5c1ecf19cc562d5aaecce45502675bb3a88349cd034e3fee9883
3
+ metadata.gz: 1ab90b5029209584ea96d267fe90cee5a47840e66c7b4120b7b29a7d518c1b1f
4
+ data.tar.gz: 218539e104b1c65cb46831c6768fbdd846b2f6e2145e7292d792b1af423cef18
5
5
  SHA512:
6
- metadata.gz: 58196c4027f45a5644d0b646ce16239eb41eefa761fb5b22d3e0b0788fa60d843fd649f600095fbd47d37d271872f001c59dbc5ad0006275c8f4ce32796c001b
7
- data.tar.gz: ca1c5424c4c8c40b2f3860222ff2af23331ae325a01f52fbf89ca0c3b977652c96e8780671d2b00e68b091ee3a088bc2434f97b6b3f8e201aafb718c047e45c4
6
+ metadata.gz: 6049732d522d95c9e803f3ae0ecb01f1a830fde0951efa22cdeba621acdd29013bce9717b49ca83b8e58049abb0e106d6dea23cf989515fc9ccb0ab1360cd232
7
+ data.tar.gz: 944edde30fa1234c62813a769c6e1d849ab30b7bd5c16a945ab608f55411fb70c86821600274ee5010b65ff13da3ea9821283c62c7a00b969aa7510095045f1f
@@ -49,7 +49,11 @@ module SpecifiedRuby
49
49
  end
50
50
 
51
51
  def restart
52
- exec "rvm-exec #{$0} #{"&& rvm-exec $SHELL" if ENV["RAILS_ENV"] == "development"}"
52
+ command = "rvm-exec #{$0}"
53
+ unless %w[staging production].include?(ENV["RAILS_ENV"])
54
+ command += " && rvm-exec $SHELL"
55
+ end
56
+ exec command
53
57
  end
54
58
  end
55
59
 
@@ -7,7 +7,6 @@ class Bard::CLI < Thor
7
7
  class CI
8
8
  class GithubActions < Struct.new(:project_name, :branch, :sha)
9
9
  def run
10
- api = API.new(project_name)
11
10
  last_time_elapsed = api.last_successful_run&.time_elapsed
12
11
  @run = api.create_run!(branch)
13
12
 
@@ -33,7 +32,33 @@ class Bard::CLI < Thor
33
32
  def last_response
34
33
  end
35
34
 
35
+ def status
36
+ last_run = api.last_run
37
+ if last_run.building?
38
+ puts "Building..."
39
+ elsif last_run.success?
40
+ puts "Succeeded!"
41
+ elsif last_run.failure?
42
+ puts "Failed!\n\n#{last_run.console}"
43
+ else
44
+ raise "Unknown job status: #{last_run.inspect}"
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def api
51
+ @api ||= API.new(project_name)
52
+ end
53
+
36
54
  class API < Struct.new(:project_name)
55
+ def last_run
56
+ response = client.get("runs", event: "workflow_dispatch", per_page: 1)
57
+ if json = response["workflow_runs"][0]
58
+ Run.new(self, json)
59
+ end
60
+ end
61
+
37
62
  def last_successful_run
38
63
  successful_runs = client.get("runs", event: "workflow_dispatch", status: "success", per_page: 1)
39
64
  if json = successful_runs["workflow_runs"][0]
@@ -92,7 +117,11 @@ class Bard::CLI < Thor
92
117
  end
93
118
 
94
119
  def success?
95
- json["status"] == "completed" && json["conclusion"] == "success"
120
+ status == "completed" && conclusion == "success"
121
+ end
122
+
123
+ def failure?
124
+ conclusion == "failure"
96
125
  end
97
126
 
98
127
  def job
@@ -102,6 +131,30 @@ class Bard::CLI < Thor
102
131
  def console
103
132
  job.logs
104
133
  end
134
+
135
+ def branch
136
+ json["head_branch"]
137
+ end
138
+
139
+ def sha
140
+ json["head_sha"]
141
+ end
142
+
143
+ def status
144
+ json["status"]
145
+ end
146
+
147
+ def conclusion
148
+ json["conclusion"]
149
+ end
150
+
151
+ def started_at
152
+ Time.parse(json["run_started_at"])
153
+ end
154
+
155
+ def updated_at
156
+ Time.parse(json["updated_at"])
157
+ end
105
158
  end
106
159
 
107
160
  class Job < Struct.new(:api, :json)
data/lib/bard/ci.rb CHANGED
@@ -19,7 +19,7 @@ class Bard::CLI < Thor
19
19
  end
20
20
 
21
21
  extend Forwardable
22
- delegate [:run, :exists?, :console, :last_response] => :runner
22
+ delegate [:run, :exists?, :console, :last_response, :status] => :runner
23
23
 
24
24
  private
25
25
 
data/lib/bard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bard
2
- VERSION = "0.51.1"
2
+ VERSION = "0.52.0"
3
3
  end
4
4
 
data/lib/bard.rb CHANGED
@@ -84,11 +84,13 @@ class Bard::CLI < Thor
84
84
  ping to
85
85
  end
86
86
 
87
- method_options %w[verbose -v] => :boolean, %w[local-ci -l] => :boolean
87
+ method_options %w[verbose -v] => :boolean, %w[local-ci -l] => :boolean, %w[status -s] => :boolean
88
88
  desc "ci [BRANCH=HEAD]", "runs ci against BRANCH"
89
89
  def ci branch=Git.current_branch
90
90
  ci = CI.new(project_name, branch, local: options["local-ci"])
91
91
  if ci.exists?
92
+ return puts ci.status if options["status"]
93
+
92
94
  puts "Continuous integration: starting build on #{branch}..."
93
95
 
94
96
  success = ci.run do |elapsed_time, last_time|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.51.1
4
+ version: 0.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.3.26
182
+ rubygems_version: 3.2.32
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: CLI to automate common development tasks.