matrixci 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/bin/ci +16 -0
- data/bin/ciwatch +8 -0
- data/conf/config.yml.sample +3 -0
- data/lib/adapters/adapter.rb +11 -0
- data/lib/adapters/circleci.rb +26 -0
- data/lib/build.rb +53 -0
- data/lib/matrixci.rb +7 -0
- data/lib/matrixci/version.rb +3 -0
- data/lib/project.rb +21 -0
- data/matrixci.gemspec +26 -0
- data/test/matrixci_test.rb +7 -0
- data/test/test_helper.rb +3 -0
- metadata +131 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Oren Mazor
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Matrixci
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'matrixci'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install matrixci
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/ci
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'matrixci'
|
4
|
+
|
5
|
+
scope = ARGV[0]
|
6
|
+
|
7
|
+
if ["", "all"].include?(scope)
|
8
|
+
MatrixCi::Project.all.each do |project|
|
9
|
+
project.all_recent_builds.each do |build|
|
10
|
+
puts build.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
elsif ["show", "cancel", "retry"].include?(scope)
|
14
|
+
buildid = ARGV[1]
|
15
|
+
MatrixCi::Project.send(scope, buildid)
|
16
|
+
end
|
data/bin/ciwatch
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
require 'build'
|
4
|
+
|
5
|
+
module MatrixCi
|
6
|
+
class CircleCi
|
7
|
+
def user_info
|
8
|
+
end
|
9
|
+
|
10
|
+
def recent_build_for(project_name, username)
|
11
|
+
result = open("https://circleci.com/api/v1/project/#{username}/#{project_name}?circle-token=#{@token}").read
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_recent_builds
|
15
|
+
result = open("https://circleci.com/api/v1/recent-builds?circle-token=#{@token}").read
|
16
|
+
builds = JSON.parse(result)
|
17
|
+
builds.map do |build|
|
18
|
+
Build.new(id: build["build_num"], branch: build["branch"], committer: build["committer_name"],started: build["start_time"],ended: build["stop_time"], outcome: build["outcome"], ref: build["vcs_revision"], subject: build["subject"], projectname: build["vcs_url"].split("/").last)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(token)
|
23
|
+
@token = token
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/build.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require './lib/adapters/adapter'
|
2
|
+
require 'rainbow'
|
3
|
+
|
4
|
+
module MatrixCi
|
5
|
+
class Build
|
6
|
+
def initialize(options)
|
7
|
+
@id = options[:id]
|
8
|
+
@branch = options[:branch]
|
9
|
+
@committer = options[:committer]
|
10
|
+
@started = options[:started]
|
11
|
+
@ended = options[:ended]
|
12
|
+
@outcome = options[:outcome]
|
13
|
+
@subject = options[:subject]
|
14
|
+
@ref = options[:ref]
|
15
|
+
@projectname = options[:projectname]
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
str = "%s %10s %10s %40s %25s %15s %s" % [@id, @started[11,8], @projectname, @branch, @committer, @ref, @subject]
|
20
|
+
|
21
|
+
color = :white
|
22
|
+
if running?
|
23
|
+
color = :yellow
|
24
|
+
else
|
25
|
+
color = :green if successful?
|
26
|
+
color = :red unless successful?
|
27
|
+
end
|
28
|
+
|
29
|
+
str.foreground(color)
|
30
|
+
end
|
31
|
+
|
32
|
+
def successful?
|
33
|
+
@outcome != "failed"
|
34
|
+
end
|
35
|
+
|
36
|
+
def running?
|
37
|
+
@ended.nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def runtime
|
41
|
+
(DateTime.parse(@ended) - DateTime.parse(@started)).to_i/60
|
42
|
+
end
|
43
|
+
|
44
|
+
def cancel
|
45
|
+
end
|
46
|
+
|
47
|
+
def retry
|
48
|
+
end
|
49
|
+
|
50
|
+
def show
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/matrixci.rb
ADDED
data/lib/project.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require './lib/adapters/adapter'
|
2
|
+
|
3
|
+
module MatrixCi
|
4
|
+
class Project
|
5
|
+
def self.all
|
6
|
+
conf = YAML.load(File.open(File.dirname(__FILE__) + "/../conf/config.yml").read)
|
7
|
+
|
8
|
+
conf.keys.map {|key| Project.new(key, conf[key]["adapter"], conf[key]["token"])}
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(name, adapter, token)
|
12
|
+
@name = name
|
13
|
+
@adapter = MatrixCi::Adapter[adapter].new(token)
|
14
|
+
@token = token
|
15
|
+
end
|
16
|
+
|
17
|
+
def all_recent_builds
|
18
|
+
projects = @adapter.all_recent_builds
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/matrixci.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'matrixci/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "matrixci"
|
8
|
+
spec.version = Matrixci::VERSION
|
9
|
+
spec.authors = ["Oren Mazor"]
|
10
|
+
spec.email = ["oren.mazor@gmail.com"]
|
11
|
+
spec.description = %q{A bashful tool to monitor CI}
|
12
|
+
spec.summary = %q{A bashful tool to monitor CI}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rainbow"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "minitest"
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: matrixci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Oren Mazor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rainbow
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: minitest
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: A bashful tool to monitor CI
|
79
|
+
email:
|
80
|
+
- oren.mazor@gmail.com
|
81
|
+
executables:
|
82
|
+
- ci
|
83
|
+
- ciwatch
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- Gemfile
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- bin/ci
|
93
|
+
- bin/ciwatch
|
94
|
+
- conf/config.yml.sample
|
95
|
+
- lib/adapters/adapter.rb
|
96
|
+
- lib/adapters/circleci.rb
|
97
|
+
- lib/build.rb
|
98
|
+
- lib/matrixci.rb
|
99
|
+
- lib/matrixci/version.rb
|
100
|
+
- lib/project.rb
|
101
|
+
- matrixci.gemspec
|
102
|
+
- test/matrixci_test.rb
|
103
|
+
- test/test_helper.rb
|
104
|
+
homepage: ''
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.23
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: A bashful tool to monitor CI
|
129
|
+
test_files:
|
130
|
+
- test/matrixci_test.rb
|
131
|
+
- test/test_helper.rb
|