continuous_integration 0.0.1
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 +7 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/continuous_integration.gemspec +22 -0
- data/lib/continuous_integration/constants.rb +13 -0
- data/lib/continuous_integration/tasks.rb +138 -0
- data/lib/continuous_integration/version.rb +3 -0
- data/lib/continuous_integration.rb +44 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b15a865e64cc3ade4db25f0d45cfc9a09487e64
|
4
|
+
data.tar.gz: e84d2f4c4bbce6fb57f7895fcd43f98babbda8e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5456612eedfc625ccc18acc159dd7d55102a224afda3717112d59094e307d0fc5db94b3e7a30ad2ceb7a30989de12100c7212f3a6e5efad061300b62953442de
|
7
|
+
data.tar.gz: 73858b5fed12b84a90587ce6e80f63e6b366583794e9894380bdb8d6579eb4383074132c1d9f7ddb8298277676842b3bfbe13b39556668e4569a6b0fff29b05d
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Ragavendra Nagraj
|
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 @@
|
|
1
|
+
# webrick
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'continuous_integration/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "continuous_integration"
|
8
|
+
gem.version = ContinuousIntegration::VERSION
|
9
|
+
gem.authors = ["Ragavendra Nagraj"]
|
10
|
+
gem.email = ["ragavendra.bn@gmail.com"]
|
11
|
+
gem.description = %q{CI server for running integration tests using webrick}
|
12
|
+
gem.summary = %q{One can run their UI and API tests using this gem}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
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_development_dependency 'rspec', '~> 2.7'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
DOCKER_PATH = "#{ENV['HOME']}/gitbase/devops/services/soa/dev"
|
3
|
+
#DOCKER_PATH = "#{ENV['HOME']}/gitbase/devops/services/soa/#{@git_branch}"
|
4
|
+
API_SPECS_PATH = "#{ENV['HOME']}/gitbase/test-auto/SOA/api"
|
5
|
+
UI_SPECS_PATH = "#{ENV['HOME']}/gitbase/test-auto/SOA/se"
|
6
|
+
|
7
|
+
HOST="dockervm"
|
8
|
+
#HOST="https://amzn-se001"
|
9
|
+
#HOST="https://qa.hostname.ca"
|
10
|
+
BROWSER="phantomjs"
|
11
|
+
SCREENS=true
|
12
|
+
|
13
|
+
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require_relative 'constants'
|
2
|
+
|
3
|
+
class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
4
|
+
|
5
|
+
def initialize param
|
6
|
+
#def initialize(opts)
|
7
|
+
#super(opts)
|
8
|
+
@resourcePath = "/cards"
|
9
|
+
@repo_name = ''
|
10
|
+
@process_status = ''
|
11
|
+
@result = ''
|
12
|
+
@result_api = ''
|
13
|
+
@result_ui = ''
|
14
|
+
@git_branch = ''
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#curl localhost:8080/docker
|
19
|
+
def do_GET (request, response)
|
20
|
+
|
21
|
+
#status, content_type, body = do_stuff_with request
|
22
|
+
response.status = 200
|
23
|
+
response['Content-Type'] = 'text/plain'
|
24
|
+
response.body = 'Hello, World!'
|
25
|
+
|
26
|
+
puts "this is a get request"
|
27
|
+
#puts "Dir - #{root}"
|
28
|
+
#puts "Dir - #{File.expand_path '/home/raga/gitbase/test-auto/SOA/api/log/'}"
|
29
|
+
|
30
|
+
obj = {
|
31
|
+
"TIME" => Time.now.strftime("%FT%T"),
|
32
|
+
"foo" => "Test",
|
33
|
+
"bar" => "QA-Automation",
|
34
|
+
'a' => 2,
|
35
|
+
'b' => 3.141,
|
36
|
+
'COUNT' => 1,
|
37
|
+
'c' => 'c',
|
38
|
+
'd' => [ 1, "b", 3.14 ],
|
39
|
+
'e' => { 'foo' => 'bar' },
|
40
|
+
'g' => "Ragu's response",
|
41
|
+
'h' => 1000.0,
|
42
|
+
'i' => 0.001,
|
43
|
+
'j' => "\xf0\xa0\x80\x81",
|
44
|
+
}
|
45
|
+
response.body = JSON.generate obj
|
46
|
+
response['Content-Type'] = "application/json"
|
47
|
+
end
|
48
|
+
|
49
|
+
def do_POST (request, response)
|
50
|
+
puts "this is a post request who received #{request.body}"
|
51
|
+
|
52
|
+
requestHash = JSON.parse(request.body, symbolize_names: true)
|
53
|
+
#repo_name = requestHash[:repository]
|
54
|
+
#repo_name.split('/') repo_name[1]}
|
55
|
+
@repo_name = requestHash[:name]
|
56
|
+
#require 'pry'
|
57
|
+
#binding.pry
|
58
|
+
=begin
|
59
|
+
cmd ="docker logs --tail=9 #{@opts[:docker_compose_logger]}"
|
60
|
+
ENV["http_proxy"] = ''
|
61
|
+
Dir.chdir(@opts[:docker_compose_path]){
|
62
|
+
@log_str = %x[#{cmd}]
|
63
|
+
}
|
64
|
+
=end
|
65
|
+
|
66
|
+
#%x["cd #{DOCKER_PATH}"]
|
67
|
+
|
68
|
+
=begin
|
69
|
+
Dir.chdir(DOCKER_PATH){
|
70
|
+
cmd = "git pull"
|
71
|
+
@result = %x[#{cmd}]
|
72
|
+
|
73
|
+
cmd = "sudo docker-compose pull #{@repo_name}"
|
74
|
+
@result = %x[#{cmd}]
|
75
|
+
|
76
|
+
cmd = "sudo docker-compose kill" #haproxy may need to be restarted
|
77
|
+
#cmd = "sudo docker-compose kill #{@repo_name}"] #haproxy may need to be restarted
|
78
|
+
@result = %x[#{cmd}]
|
79
|
+
|
80
|
+
#%x[docker-compose rm -y]
|
81
|
+
cmd = "sudo docker-compose up -d"
|
82
|
+
@result = %x[#{cmd}]
|
83
|
+
|
84
|
+
#%x["sudo docker-compose start #{@repo_name}""]
|
85
|
+
cmd = "sudo docker-compose ps"
|
86
|
+
@process_status = %x[#{cmd}]
|
87
|
+
puts "Docker process status - #{@process_status}"
|
88
|
+
#%x[docker-compose ps]
|
89
|
+
}
|
90
|
+
=end
|
91
|
+
@git_branch = requestHash[:trigger_metadata][:ref]
|
92
|
+
#git_branch.split('/')"ref": "refs/heads/somebranch"
|
93
|
+
@git_branch = @git_branch.split('/')
|
94
|
+
@git_branch = @git_branch.last
|
95
|
+
#navigate to specs dir
|
96
|
+
#%x["cd #{API_SPECS_PATH}"]
|
97
|
+
|
98
|
+
Dir.chdir(API_SPECS_PATH){
|
99
|
+
cmd = "RUBYOPT='-W0' HOST=#{HOST} RMQ_HOST=#{HOST} RMQ_VHOST=/ bundle exec rake cards:#{@git_branch} | aha --black >logs/#{@git_branch}/$(date +\%d-\%m-\%Y-\%H-\%s)-API-run.htm"
|
100
|
+
@result_api = %x[#{cmd}]
|
101
|
+
#%x["bundle exec rake cards:dev | aha --black >$LOGPATH/$(date +\%d-\%m-\%Y-\%H-\%s)-run.htm"]
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
#%x["cd #{UI_SPECS_PATH}"
|
106
|
+
Dir.chdir(UI_SPECS_PATH){
|
107
|
+
#navigate to specs dir
|
108
|
+
cmd = "HOST='https://#{HOST}' BROWSER=phantomjs SCREENS=true bundle exec rake selenium:#{@git_branch} | aha --black >logs/#{@git_branch}/$(date +\%d-\%m-\%Y-\%H-\%s)-UI-run.htm"
|
109
|
+
@result_ui = %x[#{cmd}]
|
110
|
+
}
|
111
|
+
obj = {
|
112
|
+
"Docker logs" => @process_status,
|
113
|
+
"API logs" => @result_api,
|
114
|
+
"SE logs" => @result_ui
|
115
|
+
}
|
116
|
+
response.body = JSON.generate obj
|
117
|
+
response['Content-Type'] = "application/json"
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
#curl -d "{\"command\":\"ls\", \"par1\":\"/opt\"}" localhost:8080/docker/
|
122
|
+
def do_POST2 (request, response)
|
123
|
+
puts "this is a post request who received #{request.body}"
|
124
|
+
|
125
|
+
requestHash = JSON.parse(request.body, symbolize_names: true)
|
126
|
+
#@opts[:confirmation_token] = requestHash[:command]
|
127
|
+
|
128
|
+
#cmd ="#{requestHash[:command]} docker logs --tail=9 #{@opts[:docker_compose_logger]}"
|
129
|
+
cmd ="#{requestHash[:command]} #{requestHash[:par1]}"
|
130
|
+
|
131
|
+
obj = {
|
132
|
+
#"Result" => constants response.body = JSON.generate obj
|
133
|
+
#response['Content-Type'] = "application/json"
|
134
|
+
}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'json'
|
3
|
+
include WEBrick
|
4
|
+
|
5
|
+
require 'continuous_integration/constants'
|
6
|
+
require 'continuous_integration/tasks'
|
7
|
+
require 'continuous_integration/version'
|
8
|
+
|
9
|
+
module ContinuousIntegration
|
10
|
+
|
11
|
+
def self.run_ci
|
12
|
+
#path for the web server to serve the test results
|
13
|
+
root = File.expand_path "#{API_SPECS_PATH}/logs"
|
14
|
+
|
15
|
+
#run the server
|
16
|
+
server = run_server root
|
17
|
+
|
18
|
+
#mount the dir
|
19
|
+
dir_mount server
|
20
|
+
|
21
|
+
#shut server down on any interrupt
|
22
|
+
trap("INT") {
|
23
|
+
shutdown_server server
|
24
|
+
}
|
25
|
+
|
26
|
+
return server
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.shutdown_server server
|
30
|
+
server.shutdown
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.run_server root
|
36
|
+
WEBrick::HTTPServer.new :Port => 8080, :DocumentRoot => root, :DirectoryIndex => []
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.dir_mount server
|
40
|
+
server.mount "/qa/docker/", DockerEndpoint
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: continuous_integration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ragavendra Nagraj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: CI server for running integration tests using webrick
|
42
|
+
email:
|
43
|
+
- ragavendra.bn@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".ruby-version"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- continuous_integration.gemspec
|
54
|
+
- lib/continuous_integration.rb
|
55
|
+
- lib/continuous_integration/constants.rb
|
56
|
+
- lib/continuous_integration/tasks.rb
|
57
|
+
- lib/continuous_integration/version.rb
|
58
|
+
homepage: ''
|
59
|
+
licenses: []
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.5.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: One can run their UI and API tests using this gem
|
81
|
+
test_files: []
|