octocheck 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: bf3fdff5823507d50863f9222ac43ed5bde3a73c
4
- data.tar.gz: bad327462b3bb0200876409fa706130c17e770ac
3
+ metadata.gz: 8bd35dfaeee268f1d3daf61cc078347ff1e431c9
4
+ data.tar.gz: ef74400a142c4722381274a76e558b58496cf41b
5
5
  SHA512:
6
- metadata.gz: 754f6f7db2d24c504ed08af9a967f880035cc0b8dab0087944e50b501c3da3229bd785f9a6722319af6822f3498dd9ad3d51c34d158cbd73fc5dc83f584ef89d
7
- data.tar.gz: dd39442972c9e03b1780d6bd67be456d4d4471a7469161acdf6dea330896c1a745430860a02c7cfe04100a67febca800dc79031040555eacb74fe2e21ec8328a
6
+ metadata.gz: 51fe6549ea9540916697ac3df1976a1200b053825b143e041f656c1cebbc0e0036831f4bcf83a476a6870172eeead016cdd13ff9ee01caf475fa1f3b57c0a22a
7
+ data.tar.gz: fc7426aec7e22337e978f83d3ab95a11a5ce0eeea9d5e185dfe6c826ea6441db010ceec8f6955cfa1a8e53adea8e54c822a1b5328287dbc5ebb14196539b402d
data/README.md CHANGED
@@ -1,52 +1,33 @@
1
- # Octocheck
1
+ See github status checks in your terminal. (https://help.github.com/en/articles/about-status-checks)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/octocheck`. To experiment with that code, run `bin/console` for an interactive prompt.
4
3
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'octocheck'
13
4
  ```
5
+ $ octocheck
14
6
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install octocheck
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
7
+ success ci-check-1 https://example.com/ci-check-1
8
+ in_progress ci-check-2 https://example.com/ci-check-2
9
+ failed ci-check-3 https://example.com/ci-check-3
10
+ ```
32
11
 
33
- ## Contributing
12
+ ### Installation
34
13
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/octocheck.
36
- See github status checks in your terminal.
37
- (https://help.github.com/en/articles/about-status-checks)
14
+ Requires ruby > 2.1.0
38
15
 
39
- octocheck --branch myBranchName --project my_repo_name
16
+ ```
17
+ gem install octocheck
18
+ ```
40
19
 
41
- [Options]
20
+ ### OPTIONS
42
21
 
22
+ ```
43
23
  -b, --branch: defaults to current repo's branch
44
24
  -p, --project: defaults to repo directory name
45
25
  -o, --org: the Github org that owns the repo (see CONFIGURATION below)
46
26
  -r, --revision: defaults to latest revision on current branch
47
27
  -t, --token: your github API token (see CONFIGURATION below)
28
+ ```
48
29
 
49
- [CONFIGURATION]:
30
+ ### CONFIGURATION
50
31
 
51
32
  You can specify your github org and token in a configuration file so
52
33
  that you don't need to configure them each time.
@@ -54,12 +35,14 @@ that you don't need to configure them each time.
54
35
  Put a json formatted file at ~/.config/octocheck/config.json with the
55
36
  following data:
56
37
 
38
+ ```json
57
39
  {
58
40
  "token": "< github token value >",
59
41
  "org": "< github org name >"
60
42
  }
43
+ ```
61
44
 
62
- [ORG]:
45
+ ### ORG
63
46
 
64
47
  Unfortunately when accessing status checks for a repo, the repo's
65
48
  organization must be specified. :( The organization can be found in
@@ -67,7 +50,7 @@ the repo's url:
67
50
 
68
51
  https://github.com/ORGNAME/repo_name
69
52
 
70
- [TOKEN]:
53
+ ### TOKEN
71
54
 
72
55
  In order to read Github checks, you need to configure (or pass as an
73
56
  argument) a token with rights to "repo" permissions:
@@ -80,7 +63,7 @@ argument) a token with rights to "repo" permissions:
80
63
  Unfortunately full `repo` access is needed in order to access Github
81
64
  status checks. Hopefully they change that soon.
82
65
 
83
- [OUTPUT]
66
+ ### OUTPUT
84
67
 
85
68
  Checks are listed in the order they are received. There is some basic
86
69
  colorization applied based on the status names. When using Iterm2, the
data/lib/octocheck/api.rb CHANGED
@@ -18,7 +18,7 @@ module Octocheck
18
18
  {
19
19
  name: j["context"],
20
20
  state: j["state"].downcase,
21
- url: j["target_url"]
21
+ target_url: j["target_url"]
22
22
  }
23
23
  }
24
24
  .uniq {|j| j[:name]}
@@ -31,7 +31,8 @@ module Octocheck
31
31
  {
32
32
  name: cr["name"],
33
33
  state: cr["status"].downcase,
34
- url: cr["details_url"],
34
+ github_url: "https://github.com/#{org}/#{repo}/runs/#{cr["id"]}",
35
+ target_url: cr["details_url"],
35
36
  details: check_run_details(cr["output"]["summary"])
36
37
  }
37
38
  }
@@ -49,7 +50,7 @@ module Octocheck
49
50
  {
50
51
  name: structure[:name],
51
52
  state: structure[:state].downcase,
52
- url: structure[:url]
53
+ target_url: structure[:url]
53
54
  }
54
55
  else
55
56
  nil
@@ -14,29 +14,50 @@ module Octocheck
14
14
  end
15
15
 
16
16
  def format(summary)
17
+ counts = {}
17
18
  cols = []
18
19
  summary.statuses.each do |status|
20
+ counts[status.fetch(:state)] = (counts[status.fetch(:state)] || 0) + 1
21
+
19
22
  cols << [
20
- linkify(status.fetch(:state), status.fetch(:url)),
23
+ linkify(status.fetch(:state), status.fetch(:target_url)),
21
24
  status.fetch(:name)
22
25
  ].join(" ")
23
26
  end
24
27
 
25
28
  summary.check_runs.each do |run|
29
+ counts[run.fetch(:state)] = (counts[run.fetch(:state)] || 0) + 1
30
+
26
31
  cols << [
27
- linkify(run.fetch(:state), run.fetch(:url)),
32
+ linkify(run.fetch(:state), run.fetch(:target_url)),
28
33
  run.fetch(:name)
29
34
  ].join(" ")
30
35
 
31
36
  run.fetch(:details).each do |detail|
37
+ counts[detail.fetch(:state)] = (counts[detail.fetch(:state)] || 0) + 1
38
+
32
39
  cols << [
33
- linkify(detail.fetch(:state), detail.fetch(:url)),
40
+ linkify(detail.fetch(:state), detail.fetch(:target_url)),
34
41
  detail.fetch(:name)
35
42
  ].join(" ")
36
43
  end
37
44
  end
38
45
 
39
46
  io.puts(cols.join("\n"))
47
+
48
+ state_summaries =
49
+ counts
50
+ .sort
51
+ .map {|state, count| "#{count} #{state}"}
52
+ .join(", ")
53
+
54
+ link_summaries =
55
+ summary
56
+ .check_runs
57
+ .map {|cr| cr.fetch(:github_url) }
58
+ .join("\n")
59
+
60
+ io.puts(["", state_summaries, link_summaries].join("\n"))
40
61
  end
41
62
 
42
63
  def linkify(text, url)
@@ -14,32 +14,54 @@ module Octocheck
14
14
  end
15
15
 
16
16
  def format(summary)
17
+ counts = {}
17
18
  cols = []
18
19
  summary.statuses.each do |status|
20
+ counts[status.fetch(:state)] = (counts[status.fetch(:state)] || 0) + 1
21
+
19
22
  cols << [
20
23
  colorize(status.fetch(:state)),
21
24
  status.fetch(:name),
22
- status.fetch(:url)
25
+ status.fetch(:target_url)
23
26
  ].join(" ")
24
27
  end
25
28
 
26
29
  summary.check_runs.each do |run|
30
+ counts[run.fetch(:state)] = (counts[run.fetch(:state)] || 0) + 1
31
+
27
32
  cols << [
28
33
  colorize(run.fetch(:state)),
29
34
  run.fetch(:name),
30
- run.fetch(:url)
35
+ run.fetch(:target_url)
31
36
  ].join(" ")
32
37
 
33
38
  run.fetch(:details).each do |detail|
39
+ counts[detail.fetch(:state)] = (counts[detail.fetch(:state)] || 0) + 1
40
+
34
41
  cols << [
35
42
  colorize(detail.fetch(:state)),
36
43
  detail.fetch(:name),
37
- detail.fetch(:url)
44
+ detail.fetch(:target_url)
38
45
  ].join(" ")
39
46
  end
40
47
  end
41
48
 
42
49
  io.puts(cols.join("\n"))
50
+
51
+ state_summaries =
52
+ counts
53
+ .sort
54
+ .map {|state, count| "#{count} #{state}"}
55
+ .join(", ")
56
+
57
+ link_summaries =
58
+ summary
59
+ .check_runs
60
+ .map {|cr| cr.fetch(:github_url) }
61
+ .join("\n")
62
+
63
+ io.puts(["", state_summaries, link_summaries].join("\n"))
64
+
43
65
  end
44
66
 
45
67
  def colorize(text)
@@ -12,5 +12,9 @@ module Octocheck
12
12
  def statuses
13
13
  @statuses ||= api.statuses
14
14
  end
15
+
16
+ def summary_pages
17
+ @summary_pages ||= api.summary_pages
18
+ end
15
19
  end
16
20
  end
@@ -1,3 +1,3 @@
1
1
  module Octocheck
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octocheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler