circleci-cli 2.0.0 → 2.1.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: 4823a93a5df3fed802d98f9131b3792b9fc7c51e371688c70bf09233f804a49c
4
- data.tar.gz: 8ede76476f63b3bf97641fa996229de56c5f8177b624080fcba2eb6c2f9c945b
3
+ metadata.gz: 0a4d26f78c55597cf3becbb35a01830eeff0bea849595d9a598cee83ff005380
4
+ data.tar.gz: 12f4072a51aaf0841a029d4cdda58ecdd7248f71d768a7fe9ddbd08e43ad532f
5
5
  SHA512:
6
- metadata.gz: b01c02e60ad803dca24506568397c243c86f0cebe00d8b4cecc881ac0a39e299fd8410a355aae03f3c5763909ea7f095e11c08f3d0a2d2f7067544de5f5fcb5d
7
- data.tar.gz: df4a2d04fc9d52ed27e64630c788773431d4ca6ded37879480c26d3e654133d1459d6a901b0bde633f577be56ea4ef67d9cc831d3506589c62fd3de592430102
6
+ metadata.gz: d88223bc635c85aacbb66d2a3e8a5460d8596f3e5e04abdacb283f0da02bcc51bdd82c115b560f478a16f05632da1390b2b99534d1e316292d2ed0c2fb987510
7
+ data.tar.gz: 79ffab76da11996aed822d93ce98cfad09b09e3424b837465409c937b7e334ac9a94d99071a0542c7d505ca267c1943b793e96680f2612faee19d6b6291d676a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-cli (2.0.0)
4
+ circleci-cli (2.1.0)
5
5
  circleci (~> 2.0.2)
6
6
  colorize (~> 0.8.1)
7
7
  faraday (>= 0.14, < 0.16)
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # circleci-cli
2
2
 
3
+ Notice: This gem is renamed from `circler` to `circleci-cli` on 2019/09/22
4
+
3
5
  [![Gem Version](https://badge.fury.io/rb/circleci-cli.svg)](https://badge.fury.io/rb/circleci-cli)
4
6
  [![Circle CI](https://circleci.com/gh/unhappychoice/circleci-cli.svg?style=shield)](https://circleci.com/gh/unhappychoice/circleci-cli)
5
7
  [![Code Climate](https://codeclimate.com/github/unhappychoice/circleci-cli/badges/gpa.svg)](https://codeclimate.com/github/unhappychoice/circleci-cli)
@@ -12,8 +14,6 @@ circleci-cli is a CLI tool for [Circle CI](https://circleci.com).
12
14
 
13
15
  ![sample.gif](https://github.com/unhappychoice/circler/raw/master/movie/rec.gif)
14
16
 
15
- Notice: This gem is renamed from `circler` to `circleci-cli` on 2019/09/22
16
-
17
17
  ## Installation
18
18
 
19
19
  ```sh
@@ -42,6 +42,39 @@ Options:
42
42
  -p user_name/project # specify repository
43
43
  -b branch # specify branch name
44
44
  -n build_number # specify build number
45
+ -l last # get or retry last failed build
46
+ -v verbose # show all the logs if applied to watch command
47
+ ```
48
+
49
+ ### Project argument
50
+
51
+ Project argument will be automatically selected in your directory initialized with git.
52
+
53
+ ### Examples
54
+
55
+ #### Watch your project
56
+ ```
57
+ $ circleci-cli watch
58
+ ```
59
+
60
+ #### Watch your project and show all of the build log
61
+ ```
62
+ $ circleci-cli watch -v
63
+ ```
64
+
65
+ #### Show last failed build
66
+ ```
67
+ $ circleci-cli build --last
68
+ ```
69
+
70
+ #### Retry last failed build
71
+ ```
72
+ $ circleci-cli retry --last
73
+ ```
74
+
75
+ #### Open CircleCI webpage for current project
76
+ ```
77
+ $ circleci-cli browse
45
78
  ```
46
79
 
47
80
  ## Contributing
@@ -36,6 +36,7 @@ module CircleCI
36
36
  desc 'build', 'show build description'
37
37
  method_option :project, aliases: 'p', type: :string, banner: 'user/project'
38
38
  method_option :build, aliases: 'n', type: :numeric, banner: 'build-number'
39
+ method_option :last, aliases: 'l', type: :boolean, banner: 'get last failed build'
39
40
  def build
40
41
  Command::BuildCommand.run(options)
41
42
  end
@@ -50,6 +51,7 @@ module CircleCI
50
51
  desc 'retry', 'retry a build'
51
52
  method_option :project, aliases: 'p', type: :string, banner: 'user/project'
52
53
  method_option :build, aliases: 'n', type: :numeric, banner: 'build-number'
54
+ method_option :last, aliases: 'l', type: :boolean, banner: 'retry last failed build'
53
55
  def retry
54
56
  Command::RetryCommand.run(options)
55
57
  end
@@ -8,10 +8,26 @@ module CircleCI
8
8
  def run(options)
9
9
  setup_token
10
10
  username, reponame = project_name(options).split('/')
11
- number = build_number(options)
12
- build = Response::Build.get(username, reponame, number)
11
+ build =
12
+ if options.last
13
+ get_last_build(username, reponame)
14
+ else
15
+ get_build(username, reponame, options)
16
+ end
13
17
  say Printer::StepPrinter.new(build.steps).to_s
14
18
  end
19
+
20
+ private
21
+
22
+ def get_build(username, reponame, options)
23
+ number = build_number(options)
24
+ Response::Build.get(username, reponame, number)
25
+ end
26
+
27
+ def get_last_build(username, reponame)
28
+ builds = Response::Build.failed(username, reponame)
29
+ Response::Build.get(username, reponame, builds.map(&:build_number).max)
30
+ end
15
31
  end
16
32
  end
17
33
  end
@@ -8,14 +8,30 @@ module CircleCI
8
8
  def run(options)
9
9
  setup_token
10
10
  username, reponame = project_name(options).split('/')
11
- number = build_number(options)
11
+ number = build_number_for(username, reponame, options)
12
+
12
13
  build = Response::Build.retry(username, reponame, number)
13
- if build.username
14
+
15
+ if build&.username
14
16
  say "build #{username}/#{reponame} #{build.build_number} is triggered"
15
17
  else
16
18
  say "failed to trigger #{username}/#{reponame} #{number}"
17
19
  end
18
20
  end
21
+
22
+ private
23
+
24
+ def build_number_for(username, reponame, options)
25
+ if options.last
26
+ get_last_build_number(username, reponame)
27
+ else
28
+ build_number(options)
29
+ end
30
+ end
31
+
32
+ def get_last_build_number(username, reponame)
33
+ Response::Build.failed(username, reponame).map(&:build_number).max
34
+ end
19
35
  end
20
36
  end
21
37
  end
@@ -57,7 +57,7 @@ module CircleCI
57
57
  def show_interrupted_build_results # rubocop:disable Metrics/AbcSize
58
58
  @repository.builds_to_show.select(&:finished?).each do |build|
59
59
  b = Response::Build.get(build.username, build.reponame, build.build_number)
60
- title = "✅ Result of #{build.project_name} ##{build.build_number} completed in background".light_black
60
+ title = "✅ Result of #{build.project_name} ##{build.build_number} completed in background"
61
61
  say Printer::BuildPrinter.header_for(build, title)
62
62
  say Printer::StepPrinter.new(b.steps, pretty: @options.verbose).to_s
63
63
  @repository.mark_as_shown(b.build_number)
@@ -28,9 +28,9 @@ module CircleCI
28
28
  def bind_event_handling(channel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
29
29
  @client.bind_event_json(channel, 'newAction') do |json|
30
30
  if @verbose
31
- print_bordered json['log']['name'].light_black
31
+ print_bordered json['log']['name']
32
32
  else
33
- print json['log']['name'].light_black
33
+ print json['log']['name']
34
34
  end
35
35
  end
36
36
 
@@ -56,7 +56,7 @@ module CircleCI
56
56
  end
57
57
 
58
58
  def notify_started
59
- title = "👀 Start watching #{@build.project_name} ##{@build.build_number}".light_black
59
+ title = "👀 Start watching #{@build.project_name} ##{@build.build_number}"
60
60
  say Printer::BuildPrinter.header_for(@build, title)
61
61
  end
62
62
 
@@ -5,12 +5,12 @@ module CircleCI
5
5
  module Printer
6
6
  class BuildPrinter
7
7
  class << self
8
- def header_for(build, title) # rubocop:disable Metrics/AbcSize
8
+ def header_for(build, title)
9
9
  texts = [
10
- ['Project: '.light_black + build.project_name],
11
- ['Build: '.light_black + build.build_number.to_s],
12
- ['Author: '.light_black + build.author_name],
13
- ['Workflow: '.light_black + "#{build.workflow_name}/#{build.workflow_job_name}"]
10
+ ['Project: ' + build.project_name],
11
+ ['Build: ' + build.build_number.to_s],
12
+ ['Author: ' + build.author_name],
13
+ ['Workflow: ' + "#{build.workflow_name}/#{build.workflow_job_name}"]
14
14
  ]
15
15
  Terminal::Table.new(title: title, rows: texts, style: { width: 120 }).to_s
16
16
  end
@@ -11,6 +11,12 @@ module CircleCI
11
11
  .map { |b| Build.new(b) }
12
12
  end
13
13
 
14
+ def failed(username, reponame)
15
+ CircleCi::Project.new(username, reponame, 'github').recent_builds(filter: 'failed')
16
+ .body
17
+ .map { |b| Build.new(b) }
18
+ end
19
+
14
20
  def branch(username, reponame, branch)
15
21
  CircleCi::Project.new(username, reponame, 'github').recent_builds_branch(branch)
16
22
  .body
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CircleCI
4
4
  module CLI
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.0'
6
6
  end
7
7
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - unhappychoice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-22 00:00:00.000000000 Z
11
+ date: 2019-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: circleci