bard 0.51.2 → 0.52.1

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: c108c9345f204f6b92aa387159b961e95abc403098b557bf277739f35f9b6cf3
4
+ data.tar.gz: a829c2c0816793c7e3fbe6c13f27da73bc1052304141db24536313f372aa2225
5
5
  SHA512:
6
- metadata.gz: 7a24e3844185b28b65bdd712d7d05cab0c09b5b66ddd48ff9f821d88f4c13f57b4609bb78257132f57a9eda7cd2f88cab20114a683852613687a35cffb0330e4
7
- data.tar.gz: edc18a2acdf012fb8c6784ced885d08ce418c2b58c3cfcd4f91977885ec9c891577df7fcf8465216d7faef3409aa34a829f26d24a7eb40ab63ccf5c46cb5d235
6
+ metadata.gz: a32fcc5a42a55dd69d006a0f026970a13d7222133e3358e111eb22755c87c9fa14da5404e1db14b2b00c84f50c10fe0427cf6fdf9a8329dcef4f22879c579444
7
+ data.tar.gz: 1764593da61af0635ef1e92a6b97738120298b51d60e96fa82b1ca4130652f1287dd1ec03b4f95a21c958cc5afb2057d75bf901763571ec62abdb91195913f8e
@@ -3,7 +3,7 @@ module SpecifiedBundler
3
3
 
4
4
  def ensure!
5
5
  system("gem install bundler --conservative --version=#{bundler_version}") or raise "Cannot install bundler!"
6
- "bundle check || bundle install"
6
+ "(bundle check || bundle install)"
7
7
  end
8
8
 
9
9
  private
@@ -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.1"
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.1
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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor