deep_thought-travis_plugin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +12 -0
- data/Rakefile +1 -0
- data/deep_thought-travis_plugin.gemspec +28 -0
- data/lib/deep_thought-travis_plugin.rb +6 -0
- data/lib/deep_thought-travis_plugin/ci_service/travis_plugin.rb +20 -0
- data/lib/deep_thought-travis_plugin/version.rb +3 -0
- data/script/bootstrap +3 -0
- data/script/test +3 -0
- data/test/deep_thought_ci_service_plugin_test.rb +46 -0
- data/test/test_helper.rb +22 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 35b60827025a5507cb1d5486eb7cb072d11c2d22
|
4
|
+
data.tar.gz: 56242c30df86a3ca59701cd888c1dddb065b2ffb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2838277e7cb25f03d760d3b96a0a02549cfe737f52b8777ee677c63f74ea83f6e439d3b4d1df1aef479f3cadcd062c05c41efc14917f06a152e8272b92f1e384
|
7
|
+
data.tar.gz: b68e5d06d09bb7f365d2d8fc32dd0d427d11cf36221a308ff6122a226913a731befc6c15d9a646cf7d7e5d86df18be5de6dc1418bb041945a3dd922cb7e3edbc
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Deep Thought Travis CI Plugin
|
2
|
+
|
3
|
+
A Deep Thought plugin for Travis CI.
|
4
|
+
|
5
|
+
To use it, set the following environment variables:
|
6
|
+
|
7
|
+
CI_SERVICE=travis
|
8
|
+
CI_SERVICE_ENDPOINT=http://api.travis-ci.org # This can also be the URL of a custom Travis CI setup
|
9
|
+
|
10
|
+
|
11
|
+
**Note**: This plugin currently **does not** suport Travis Pro.
|
12
|
+
I need to figure out the proper way to autenticate to the API.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'deep_thought-travis_plugin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "deep_thought-travis_plugin"
|
8
|
+
gem.version = DeepThought::VERSION
|
9
|
+
gem.authors = ["Aaron Hill"]
|
10
|
+
gem.email = ["aa1ronham@gmail.com"]
|
11
|
+
gem.description = "Deep Thought CI service for Travis CI."
|
12
|
+
gem.summary = "Deep Thought CI service for Travis cI."
|
13
|
+
gem.homepage = "https://github.com/Aaron1011/deep_thought-travis_plugin"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split("\n") - %w[.gitignore]
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "deep_thought", "~>0.2"
|
21
|
+
gem.add_dependency "httparty", "~>0.12"
|
22
|
+
|
23
|
+
# # testing
|
24
|
+
gem.add_development_dependency "minitest", "~>4.7"
|
25
|
+
gem.add_development_dependency "mocha", "~>0.14"
|
26
|
+
gem.add_development_dependency "database_cleaner", "~>1.2"
|
27
|
+
gem.add_development_dependency "turn", "~>0.9"
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'deep_thought/ci_service/ci_service'
|
3
|
+
|
4
|
+
module DeepThought
|
5
|
+
module CIService
|
6
|
+
class TravisPlugin < DeepThought::CIService::CIService
|
7
|
+
def is_branch_green?(app, branch, *args)
|
8
|
+
is_green = false
|
9
|
+
|
10
|
+
response = HTTParty.get("#{@endpoint}/repos/#{app}/branches/#{branch}")
|
11
|
+
build = JSON.parse(response.body)
|
12
|
+
|
13
|
+
if build['branch']['state'] == 'passing'
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/script/bootstrap
ADDED
data/script/test
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path '../test_helper.rb', __FILE__
|
2
|
+
|
3
|
+
class DeepThoughtTravisPluginTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
DatabaseCleaner.start
|
6
|
+
|
7
|
+
@travis_plugin = DeepThought::CIService::TravisPlugin.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
DatabaseCleaner.clean
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_travis_setup_success
|
15
|
+
@travis_plugin.setup?({"CI_SERVICE_ENDPOINT" => "endpoint"})
|
16
|
+
|
17
|
+
assert @travis_plugin.endpoint == 'endpoint'
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_travis_plugin_is_branch_green_success
|
21
|
+
# successful test with CI service (I suggest stubbing the payload and mocking the API call)
|
22
|
+
|
23
|
+
json = stub(:body => '{"branch": {"state": "passing"}}')
|
24
|
+
HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)
|
25
|
+
|
26
|
+
assert @travis_plugin.is_branch_green?('app', 'branch', '')
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_travis_plugin_is_branch_green_failed
|
30
|
+
# failed test with CI service (I suggest stubbing the payload and mocking the API call)
|
31
|
+
|
32
|
+
json = stub(:body => '{"branch": {"state": "failed"}}')
|
33
|
+
HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)
|
34
|
+
|
35
|
+
assert !@travis_plugin.is_branch_green?('app', 'branch', 'hash')
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_travis_plugin_is_branch_green_missing
|
39
|
+
# failed test with CI service (I suggest stubbing the payload and mocking the API call)
|
40
|
+
|
41
|
+
json = stub(:body => '{"branch": {"id": 123}}')
|
42
|
+
HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)
|
43
|
+
|
44
|
+
assert !@travis_plugin.is_branch_green?('app', 'branch', 'hash')
|
45
|
+
end
|
46
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
ENV['RACK_ENV'] = 'test'
|
4
|
+
ENV['SESSION_SECRET'] = 'secret'
|
5
|
+
|
6
|
+
require 'deep_thought'
|
7
|
+
require 'deep_thought-travis_plugin'
|
8
|
+
require 'rubygems'
|
9
|
+
require 'fileutils'
|
10
|
+
gem 'minitest'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require 'mocha/setup'
|
13
|
+
require 'database_cleaner'
|
14
|
+
|
15
|
+
begin; require 'turn/autorun'; rescue LoadError; end
|
16
|
+
|
17
|
+
DeepThought.setup(ENV)
|
18
|
+
|
19
|
+
DatabaseCleaner.clean_with(:truncation)
|
20
|
+
DatabaseCleaner.strategy = :transaction
|
21
|
+
|
22
|
+
BCrypt::Engine.cost = BCrypt::Engine::MIN_COST
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deep_thought-travis_plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Hill
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deep_thought
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.12'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: database_cleaner
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: turn
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
97
|
+
description: Deep Thought CI service for Travis CI.
|
98
|
+
email:
|
99
|
+
- aa1ronham@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- Gemfile
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- deep_thought-travis_plugin.gemspec
|
108
|
+
- lib/deep_thought-travis_plugin.rb
|
109
|
+
- lib/deep_thought-travis_plugin/ci_service/travis_plugin.rb
|
110
|
+
- lib/deep_thought-travis_plugin/version.rb
|
111
|
+
- script/bootstrap
|
112
|
+
- script/test
|
113
|
+
- test/deep_thought_ci_service_plugin_test.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
homepage: https://github.com/Aaron1011/deep_thought-travis_plugin
|
116
|
+
licenses: []
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.0.3
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Deep Thought CI service for Travis cI.
|
138
|
+
test_files:
|
139
|
+
- test/deep_thought_ci_service_plugin_test.rb
|
140
|
+
- test/test_helper.rb
|
141
|
+
has_rdoc:
|