bard 0.51.2 → 0.52.0

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: ac0596452d31a4ea9b22436256d58f5ff39379b495e2a543dabc4f185d0976a3
4
- data.tar.gz: d0e0ca733a09d031e07815dbf9d3e2a380caab063b93b17089d08fdd4e2ef3e2
3
+ metadata.gz: 1ab90b5029209584ea96d267fe90cee5a47840e66c7b4120b7b29a7d518c1b1f
4
+ data.tar.gz: 218539e104b1c65cb46831c6768fbdd846b2f6e2145e7292d792b1af423cef18
5
5
  SHA512:
6
- metadata.gz: 7a24e3844185b28b65bdd712d7d05cab0c09b5b66ddd48ff9f821d88f4c13f57b4609bb78257132f57a9eda7cd2f88cab20114a683852613687a35cffb0330e4
7
- data.tar.gz: edc18a2acdf012fb8c6784ced885d08ce418c2b58c3cfcd4f91977885ec9c891577df7fcf8465216d7faef3409aa34a829f26d24a7eb40ab63ccf5c46cb5d235
6
+ metadata.gz: 6049732d522d95c9e803f3ae0ecb01f1a830fde0951efa22cdeba621acdd29013bce9717b49ca83b8e58049abb0e106d6dea23cf989515fc9ccb0ab1360cd232
7
+ data.tar.gz: 944edde30fa1234c62813a769c6e1d849ab30b7bd5c16a945ab608f55411fb70c86821600274ee5010b65ff13da3ea9821283c62c7a00b969aa7510095045f1f
@@ -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.2"
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.2
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-17 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