continuous_integration 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +75 -11
- data/continuous_integration.gemspec +3 -2
- data/lib/continuous_integration/tasks.rb +53 -38
- data/lib/continuous_integration/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd54be966578be56bbab0d6b71521c704586205c
|
4
|
+
data.tar.gz: e59248652de2a1e53531ce5c6b863ec7f6f05876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f98a5368bc90bf9e1f564be0e17fb154c2b9354194388d8c1839e61603b1e2b509db8a50f69666d6909e354b8c1f6f9c37ef5135d1af97202437503dc5c10729
|
7
|
+
data.tar.gz: 4c6cb62303950dbb5aa9e78dcd87c8b2932eeeca6013c172585feb1bc1d255181c7301c4aafb366cc32e290d3a0375c6c2ab2122dbb6b0d6f1b3a1a382b16cee
|
data/README.md
CHANGED
@@ -1,27 +1,91 @@
|
|
1
|
-
#
|
1
|
+
# The CI gem helps to perform CI capability in the minimalistic approach
|
2
2
|
|
3
|
-
|
3
|
+
CI is a gem to say consume the Quay.io posts on sucessful build completion and perform the docker operations and tests run or say perform the CI capability.
|
4
4
|
|
5
|
-
|
5
|
+
Lets say a developer checks in the code to the github. The container repository like Quay receives a call to perform the operations on building the new say Docker repo and host it. Quay can be later configured to be able to shoot out a POST call when this is done. Such call is consumed by the continuous_integration to be able to perform customized operations. Like say, destroy the local or old docker container(s). Pull the latest container(s) from the Quay. Pull the latest API or UI tests and run them against the new container(s). Finally report the test run results to the team on Slack or wherever.
|
6
6
|
|
7
|
+
|
8
|
+
### History
|
9
|
+
|
10
|
+
The idea came into picture when trying to leverage the right CI tool to help run the automated API or the UI tests. Having traversed the various industry standard CIs it was thought to anyway have a light weight CI server to help achieve the same.
|
11
|
+
|
12
|
+
### Installation and usage
|
13
|
+
|
14
|
+
To install (or update to the latest version) using the bundler gem. Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```
|
7
17
|
gem 'continuous_integration'
|
18
|
+
```
|
8
19
|
|
9
|
-
|
20
|
+
then run
|
10
21
|
|
11
|
-
|
22
|
+
```
|
23
|
+
bundle install
|
24
|
+
```
|
12
25
|
|
13
|
-
|
26
|
+
To install directly (without bundler), run
|
14
27
|
|
15
|
-
|
28
|
+
```
|
29
|
+
gem install continuous_integration
|
30
|
+
```
|
16
31
|
|
17
32
|
## Usage
|
18
33
|
|
19
|
-
|
20
|
-
|
34
|
+
Put the below contents in a ruby file say `ci_server.rb`
|
35
|
+
|
36
|
+
```
|
37
|
+
require 'continuous_integration'
|
21
38
|
server = ContinuousIntegration.run_ci
|
39
|
+
server.start
|
22
40
|
```
|
23
41
|
|
42
|
+
and run it like below to start the CI server
|
43
|
+
```
|
44
|
+
ruby ci_server.rb
|
45
|
+
```
|
46
|
+
|
47
|
+
You should be able to receive the POST requests on `http://localhost:8080` now
|
48
|
+
|
49
|
+
Also, if you access the above URL in a browser, it shows you the content of the `API_SPECS_PATH/logs` as a web server, which apparently happens to be the path of the api test tun logs generated by the aha tool
|
50
|
+
|
24
51
|
Shutting it down
|
25
|
-
```ruby
|
26
|
-
ContinuousIntegration.shutdown_server server
|
27
52
|
```
|
53
|
+
Ctrl + C
|
54
|
+
```
|
55
|
+
|
56
|
+
## Paths
|
57
|
+
|
58
|
+
Default paths have been updated in the [constants.rb](lib/continuous_integration/constants.rb) file. It can be overriden by passing env vars when running the server.
|
59
|
+
|
60
|
+
## To - Do list
|
61
|
+
|
62
|
+
1. Create text file say PATHFILE when installing gem to easy fill in the constants rather than be in the code
|
63
|
+
2. Add more container hosting providers support and add tasks accordingly
|
64
|
+
3. Segregate individual tasks like tests run more seamlessly or even make them file based to give more flexibillity
|
65
|
+
|
66
|
+
### Troubleshooting
|
67
|
+
|
68
|
+
For help with common problems, see [TROUBLESHOOTING](doc/TROUBLESHOOTING.md).
|
69
|
+
|
70
|
+
Still stuck? Try [filing an issue](doc/contributing/ISSUES.md).
|
71
|
+
|
72
|
+
### Other questions
|
73
|
+
|
74
|
+
To see what has changed in recent versions of Bundler, see the [CHANGELOG](CHANGELOG.md).
|
75
|
+
|
76
|
+
To get in touch with the ContinuousIntegration core team and other Bundler users, please see [getting help](doc/contributing/GETTING_HELP.md).
|
77
|
+
|
78
|
+
### Contributing
|
79
|
+
|
80
|
+
If you'd like to contribute to ContinuousIntegration, that's awesome, and we <3 you. There's a guide to contributing to ContinuousIntegration (both code and general help) over in [our documentation section](doc/README.md).
|
81
|
+
|
82
|
+
|
83
|
+
#### Donations
|
84
|
+
|
85
|
+
Please feel free to donate as this work is made possible with donations like yours. It involves years of efforts with money spent to obtain the college degree and experience gained to write quality software. PM for customizations and implementations
|
86
|
+
|
87
|
+
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZKRHDCLG22EJA)
|
88
|
+
|
89
|
+
### Code of Conduct
|
90
|
+
|
91
|
+
Everyone interacting in the CI project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [CI code of conduct](doc/CODE_OF_CONDUCT.md).
|
@@ -10,7 +10,8 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["ragavendra.bn@gmail.com"]
|
11
11
|
gem.description = %q{CI server for running integration tests using webrick}
|
12
12
|
gem.summary = %q{One can run their UI and API tests using this gem}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://rubygems.org/gems/continuous_integration"
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -18,5 +19,5 @@ Gem::Specification.new do |gem|
|
|
18
19
|
gem.require_paths = ["lib"]
|
19
20
|
|
20
21
|
gem.add_development_dependency 'rspec', '~> 2.7'
|
21
|
-
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'rake', '~> 0'
|
22
23
|
end
|
@@ -3,8 +3,6 @@ require_relative 'constants'
|
|
3
3
|
class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
4
4
|
|
5
5
|
def initialize param
|
6
|
-
#def initialize(opts)
|
7
|
-
#super(opts)
|
8
6
|
@resourcePath = "/cards"
|
9
7
|
@repo_name = ''
|
10
8
|
@process_status = ''
|
@@ -17,46 +15,21 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
|
17
15
|
|
18
16
|
|
19
17
|
#curl localhost:8080/docker
|
20
|
-
|
21
|
-
|
22
|
-
#status, content_type, body = do_stuff_with request
|
23
|
-
response.status = 200
|
24
|
-
response['Content-Type'] = 'text/plain'
|
25
|
-
response.body = 'Hello, World!'
|
26
|
-
|
27
|
-
puts "this is a get request"
|
28
|
-
#puts "Dir - #{root}"
|
29
|
-
#puts "Dir - #{File.expand_path '/home/raga/gitbase/test-auto/SOA/api/log/'}"
|
30
|
-
|
31
|
-
obj = {
|
32
|
-
"TIME" => Time.now.strftime("%FT%T"),
|
33
|
-
"foo" => "Test",
|
34
|
-
"bar" => "QA-Automation",
|
35
|
-
'a' => 2,
|
36
|
-
'b' => 3.141,
|
37
|
-
'COUNT' => 1,
|
38
|
-
'c' => 'c',
|
39
|
-
'd' => [ 1, "b", 3.14 ],
|
40
|
-
'e' => { 'foo' => 'bar' },
|
41
|
-
'g' => "Ragu's response",
|
42
|
-
'h' => 1000.0,
|
43
|
-
'i' => 0.001,
|
44
|
-
'j' => "\xf0\xa0\x80\x81",
|
45
|
-
}
|
46
|
-
response.body = JSON.generate obj
|
47
|
-
response['Content-Type'] = "application/json"
|
48
|
-
end
|
49
|
-
|
18
|
+
#POST call made by quay to CI server
|
50
19
|
def do_POST (request, response)
|
51
20
|
|
21
|
+
#parse JSOn to hash key
|
52
22
|
requestHash = JSON.parse(request.body, symbolize_names: true)
|
23
|
+
|
24
|
+
#fetch the github repo name
|
53
25
|
@repo_name = requestHash[:name]
|
54
26
|
|
27
|
+
#fetch the github branch name
|
55
28
|
@git_branch = requestHash[:trigger_metadata][:ref]
|
56
29
|
@git_branch = @git_branch.split('/')
|
57
30
|
@git_branch = @git_branch.last
|
58
31
|
|
59
|
-
#handle requests one at a time - Needs testing
|
32
|
+
#handle requests one at a time (to avoid concurrency) - Needs testing
|
60
33
|
while @lock
|
61
34
|
@lock = true
|
62
35
|
docker_update
|
@@ -70,6 +43,7 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
|
70
43
|
end
|
71
44
|
end
|
72
45
|
|
46
|
+
#update docker images locally
|
73
47
|
def docker_update
|
74
48
|
Dir.chdir(DOCKER_PATH){
|
75
49
|
#perform docker images update
|
@@ -80,11 +54,13 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
|
80
54
|
|
81
55
|
end
|
82
56
|
|
57
|
+
#Action - run api tests
|
83
58
|
def run_api_tests
|
84
59
|
Dir.chdir(API_SPECS_PATH){
|
85
|
-
|
86
|
-
|
87
|
-
|
60
|
+
#shell command to run my tests using rake . I am using `aha` shell tool to grab shell output to html
|
61
|
+
cmd = "RUBYOPT='-W0' HOST=#{HOST} RMQ_HOST=#{HOST} RMQ_VHOST=/ bundle exec rake cars:#{@git_branch} | aha --black >logs/#{@git_branch}/$(date +\%d-\%m-\%Y-\%H-\%s)-API-run.htm"
|
62
|
+
@result_api = %x[#{cmd}]
|
63
|
+
# or use ` .... ` instead of %x[ .... ] to run commands
|
88
64
|
}
|
89
65
|
end
|
90
66
|
|
@@ -97,7 +73,6 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
|
97
73
|
end
|
98
74
|
|
99
75
|
def generate_log
|
100
|
-
|
101
76
|
obj = {
|
102
77
|
"Docker logs" => @process_status,
|
103
78
|
"API logs" => @result_api,
|
@@ -112,4 +87,44 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
|
|
112
87
|
end
|
113
88
|
end
|
114
89
|
|
115
|
-
|
90
|
+
#Below is the POST from Quay.io, parse and use the necessary data
|
91
|
+
=begin
|
92
|
+
|
93
|
+
{
|
94
|
+
"repository": "mynamespace/repository",
|
95
|
+
"namespace": "mynamespace",
|
96
|
+
"name": "repository",
|
97
|
+
"docker_url": "quay.io/mynamespace/repository",
|
98
|
+
"homepage": "https://quay.io/repository/mynamespace/repository/build?current=some-fake-build",
|
99
|
+
"visibility": "public",
|
100
|
+
|
101
|
+
"build_id": "build_uuid",
|
102
|
+
"docker_tags": ["latest", "foo", "bar"],
|
103
|
+
|
104
|
+
"trigger_kind": "github", // Optional
|
105
|
+
"trigger_id": "some-id-here", // Optional
|
106
|
+
"trigger_metadata": { // Optional
|
107
|
+
"default_branch": "master",
|
108
|
+
"ref": "refs/heads/somebranch",
|
109
|
+
"commit": "42d4a62c53350993ea41069e9f2cfdefb0df097d",
|
110
|
+
"commit_info": { // Optional
|
111
|
+
"url": "http://path/to/the/commit",
|
112
|
+
"message": "Some commit message",
|
113
|
+
"date": 2395748365,
|
114
|
+
"author": { // Optional
|
115
|
+
"username": "fakeauthor",
|
116
|
+
"url": "http://path/to/fake/author/in/scm", // Optional
|
117
|
+
"avatar_url": "http://www.gravatar.com/avatar/fakehash" // Optional
|
118
|
+
},
|
119
|
+
"committer": { // Optional
|
120
|
+
"username": "fakecommitter",
|
121
|
+
"url": "http://path/to/fake/comitter/in/scm", // Optional
|
122
|
+
"avatar_url": "http://www.gravatar.com/avatar/fakehash" // Optional
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
More info here -> http://docs.quay.io/guides/notifications.html#webhook_build_success
|
129
|
+
|
130
|
+
=end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: continuous_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ragavendra Nagraj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: CI server for running integration tests using webrick
|
@@ -56,8 +56,9 @@ files:
|
|
56
56
|
- lib/continuous_integration/constants.rb
|
57
57
|
- lib/continuous_integration/tasks.rb
|
58
58
|
- lib/continuous_integration/version.rb
|
59
|
-
homepage:
|
60
|
-
licenses:
|
59
|
+
homepage: https://rubygems.org/gems/continuous_integration
|
60
|
+
licenses:
|
61
|
+
- MIT
|
61
62
|
metadata: {}
|
62
63
|
post_install_message:
|
63
64
|
rdoc_options: []
|