konstant 0.0.8

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +125 -0
  8. data/Rakefile +7 -0
  9. data/bin/konstant +87 -0
  10. data/data/templates/data_dir/konstant.js +16 -0
  11. data/data/templates/data_dir/projects/.gitkeep +0 -0
  12. data/data/templates/project/build +8 -0
  13. data/data/templates/project/cleanup +5 -0
  14. data/data/templates/project/deploy +4 -0
  15. data/data/templates/project/run.txt +0 -0
  16. data/konstant.gemspec +29 -0
  17. data/lib/konstant/build.rb +86 -0
  18. data/lib/konstant/builder.rb +108 -0
  19. data/lib/konstant/cli.rb +37 -0
  20. data/lib/konstant/project.rb +75 -0
  21. data/lib/konstant/runner.rb +50 -0
  22. data/lib/konstant/scheduler.rb +50 -0
  23. data/lib/konstant/version.rb +3 -0
  24. data/lib/konstant/web.rb +39 -0
  25. data/lib/konstant.rb +81 -0
  26. data/public/assets/angular.min.js +216 -0
  27. data/public/assets/app.js +60 -0
  28. data/public/assets/bootstrap-theme.min.css +5 -0
  29. data/public/assets/bootstrap.min.css +5 -0
  30. data/public/assets/bootstrap.min.js +6 -0
  31. data/public/assets/glyphicons-halflings-regular.eot +0 -0
  32. data/public/assets/glyphicons-halflings-regular.svg +229 -0
  33. data/public/assets/glyphicons-halflings-regular.ttf +0 -0
  34. data/public/assets/glyphicons-halflings-regular.woff +0 -0
  35. data/public/assets/jquery-2.1.1.min.js +4 -0
  36. data/public/assets/style.css +3 -0
  37. data/public/index.html +175 -0
  38. data/spec/file_spec.rb +28 -0
  39. data/spec/fixtures/projects/test_project_01/build +6 -0
  40. data/spec/fixtures/projects/test_project_02/build +3 -0
  41. data/spec/konstant/builder_spec.rb +21 -0
  42. data/spec/konstant/runner_spec.rb +14 -0
  43. data/spec/konstant_spec.rb +23 -0
  44. data/spec/spec_helper.rb +27 -0
  45. metadata +208 -0
data/public/index.html ADDED
@@ -0,0 +1,175 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Konstant CI</title>
5
+
6
+ <link rel="stylesheet" type="text/css" href="/assets/bootstrap.min.css">
7
+ <!-- <link rel="stylesheet" type="text/css" href="/assets/bootstrap-theme.min.css"> -->
8
+ <link rel="stylesheet" type="text/css" href="/assets/style.css">
9
+
10
+ <script type="text/javascript" src="/assets/jquery-2.1.1.min.js"></script>
11
+ <script type="text/javascript" src="/assets/bootstrap.min.js"></script>
12
+ <script type="text/javascript" src="/assets/angular.min.js"></script>
13
+ <script type="text/javascript" src="/assets/app.js"></script>
14
+ </head>
15
+
16
+ <body ng-app="k" ng-controller="root_controller">
17
+ <div class="container-fluid">
18
+ <div class="jumbotron">
19
+ <h1>
20
+ <strong class="text-success">Konstant</strong> CI
21
+ <p>
22
+ Continuous delivery made easy
23
+ </p>
24
+ </h1>
25
+ </div>
26
+
27
+ <div class="page-header">
28
+ <h1>Project <small>listing</small></h1>
29
+ </div>
30
+
31
+ <div class="row">
32
+
33
+ <div class="col-md-5">
34
+ <div ng-repeat="(id, project) in projects" class="panel panel-default">
35
+ <div class="panel-heading">
36
+ <div class="pull-right">
37
+ <button class="btn btn-xs btn-primary" ng-click="load_project_builds(project)">
38
+ <i class="glyphicon glyphicon-tasks"></i>
39
+ show builds
40
+ </button>
41
+ <button class="btn btn-xs btn-primary" ng-click="build_project(project)">
42
+ <i class="glyphicon glyphicon-repeat"></i>
43
+ build now
44
+ </button>
45
+ </div>
46
+
47
+ <strong ng-bind="project.id"></strong>
48
+ <div>
49
+ <span ng-show="!project.building">
50
+ <span class="label label-success" ng-show="project.ok">
51
+ <i class="glyphicon glyphicon-ok-sign"></i>
52
+ build
53
+ </span>
54
+ <span class="label label-danger" ng-show="!project.ok">
55
+ <i class="glyphicon glyphicon-exclamation-sign"></i>
56
+ build
57
+ </span>
58
+
59
+ <span ng-show="project.deploy_ok != null">
60
+ &nbsp;
61
+ <span class="label label-success" ng-show="project.deploy_ok">
62
+ <i class="glyphicon glyphicon-ok-sign"></i>
63
+ deploy
64
+ </span>
65
+ <span class="label label-danger" ng-show="!project.deploy_ok">
66
+ <i class="glyphicon glyphicon-exclamation-sign"></i>
67
+ deploy
68
+ </span>
69
+ </span>
70
+
71
+ <span ng-show="project.cleanup_ok != null">
72
+ &nbsp;
73
+ <span class="label label-success" ng-show="project.cleanup_ok">
74
+ <i class="glyphicon glyphicon-ok-sign"></i>
75
+ cleanup
76
+ </span>
77
+ <span class="label label-danger" ng-show="!project.cleanup_ok">
78
+ <i class="glyphicon glyphicon-exclamation-sign"></i>
79
+ cleanup
80
+ </span>
81
+ </span>
82
+ </span>
83
+ <span ng-show="project.building">
84
+ <span class="label label-warning">
85
+ <i class="glyphicon glyphicon-question-sign"></i>
86
+ building
87
+ </span>
88
+ </span>
89
+ </div>
90
+ </div>
91
+ <div class="panel-body" ng-show="project.builds">
92
+ <table class="table table-condensed table-striped">
93
+ <thead>
94
+ <tr>
95
+ <th>Timestamp</th>
96
+ <th class="text-right">Exit code</th>
97
+ <th class="text-right">
98
+ <button class="btn btn-xs btn-primary" ng-click="update_project_builds(project)">
99
+ <i class="glyphicon glyphicon-repeat"></i>
100
+ </button>
101
+ </th>
102
+ </tr>
103
+ </thead>
104
+ <tbody>
105
+ <tr ng-repeat="build in project.builds">
106
+ <td>
107
+ <i class="text-success glyphicon glyphicon-ok-sign" ng-show="build.ok"></i>
108
+ <i class="text-danger glyphicon glyphicon-exclamation-sign" ng-show="!build.ok"></i>
109
+ <span ng-bind="build.human"></span>
110
+ </td>
111
+ <td class="text-right" ng-bind="build.status"></td>
112
+ <td class="text-right">
113
+ <button class="btn btn-primary btn-xs" ng-click="show_build(build)">
114
+ show output
115
+ <i class="glyphicon glyphicon-chevron-right"></i>
116
+ </button>
117
+ </td>
118
+ </tr>
119
+ </tbody>
120
+ </table>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+ <div class="col-md-7">
126
+ <div ng-show="current_build">
127
+ <div class="pull-right">
128
+ <button class="btn btn-xs btn-primary" ng-click="update_build(current_build)">
129
+ <i class="glyphicon glyphicon-repeat"></i>
130
+ </button>
131
+ </div>
132
+ <h2>Build {{current_build.human}}</h2>
133
+
134
+ <div ng-show="current_build.stderr">
135
+ <label>Stderr</label>
136
+ <pre ng-bind="current_build.stderr"></pre>
137
+ </div>
138
+ <div ng-show="current_build.stdout">
139
+ <label>Stdout</label>
140
+ <pre ng-bind="current_build.stdout"></pre>
141
+ </div>
142
+
143
+ <div ng-show="current_build.deploy.status">
144
+ <label>Deploy status</label>
145
+ <pre ng-bind="current_build.deploy.status"></pre>
146
+ </div>
147
+ <div ng-show="current_build.deploy.stdout">
148
+ <label>Deploy stdout</label>
149
+ <pre ng-bind="current_build.deploy.stdout"></pre>
150
+ </div>
151
+ <div ng-show="current_build.deploy.stderr">
152
+ <label>Deploy stderr</label>
153
+ <pre ng-bind="current_build.deploy.stderr"></pre>
154
+ </div>
155
+
156
+ <div ng-show="current_build.cleanup.status">
157
+ <label>Cleanup status</label>
158
+ <pre ng-bind="current_build.cleanup.status"></pre>
159
+ </div>
160
+ <div ng-show="current_build.cleanup.stdout">
161
+ <label>Cleanup stdout</label>
162
+ <pre ng-bind="current_build.cleanup.stdout"></pre>
163
+ </div>
164
+ <div ng-show="current_build.cleanup.stderr">
165
+ <label>Cleanup stderr</label>
166
+ <pre ng-bind="current_build.cleanup.stderr"></pre>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ </div>
172
+
173
+ </div>
174
+ </body>
175
+ </html>
data/spec/file_spec.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe File do
4
+
5
+ it "should exclusively lock a file" do
6
+ filename = "#{Konstant.root}/tmp/test_file"
7
+ system "touch #{filename}"
8
+ file = File.open(filename)
9
+ file.flock File::LOCK_EX
10
+ acquired_outer = Time.now
11
+
12
+ thread = Thread.new do
13
+ tfile = File.open(filename)
14
+ tfile.flock File::LOCK_EX
15
+ Time.now
16
+ end
17
+
18
+ sleep 0.1
19
+ file.close
20
+
21
+ acquired_thread = thread.value
22
+
23
+ expect(acquired_outer).to be_within(0.001).of(acquired_thread - 0.1)
24
+
25
+ system "rm #{filename}"
26
+ end
27
+
28
+ end
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ echo "some output"
4
+ >&2 echo "some warning"
5
+
6
+ exit 0
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ echo "${KONSTANT_PROJECT_ROOT}"
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Konstant::Builder do
4
+
5
+ it "should handle a missing build script" do
6
+ project = Konstant::Project.new("noexist")
7
+ runner = described_class.new project
8
+ runner.run
9
+ expect(project.status).to eq(127)
10
+ end
11
+
12
+ it "should store the build's output and error output", :fixture_projects => true do
13
+ runner = described_class.new Konstant::Project.new("test_project_01")
14
+ runner.run
15
+
16
+ expect(runner.build_stdout).to eq("some output\n")
17
+ expect(runner.build_stderr).to eq("some warning\n")
18
+ expect(runner.build_status).to eq(0)
19
+ end
20
+
21
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe Konstant::Runner do
4
+
5
+ it "should pass the project root in an environment variable", :fixture_projects => true do
6
+ project = Konstant::Project.new "test_project_02"
7
+ build = Konstant::Build.new project, Time.now.strftime("%Y%m%d%H%M%S")
8
+ runner = described_class.new build, :build
9
+ runner.run
10
+
11
+ expect(build.stdout.strip).to eq("#{Konstant.config['data_dir']}/projects/test_project_02")
12
+ end
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Konstant do
4
+
5
+ it 'has a version number' do
6
+ expect(Konstant::VERSION).not_to be nil
7
+ end
8
+
9
+ it "have a basic configuration" do
10
+ expect(described_class.config).not_to be_nil
11
+ end
12
+
13
+ it "is configurable" do
14
+ described_class.configure "data_dir" => "/opt/ci", "builds_to_keep" => 25
15
+ expect(described_class.config["data_dir"]).to eq("/opt/ci")
16
+ expect(described_class.config["builds_to_keep"]).to eq(25)
17
+ end
18
+
19
+ it "uses an environment" do
20
+ expect(Konstant.env).to eq("test")
21
+ end
22
+
23
+ end
@@ -0,0 +1,27 @@
1
+ ENV["RUBY_ENV"] = "test"
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'konstant'
5
+
6
+ require "debugger"
7
+
8
+ Mail.defaults do
9
+ delivery_method :test
10
+ end
11
+
12
+ RSpec.configure do |config|
13
+ config.before :each do |example|
14
+ Konstant.logger = Logger.new("/dev/null")
15
+
16
+ Konstant.reset_config
17
+
18
+ Konstant.configure "#{Konstant.root}/data/templates/data_dir/konstant.js"
19
+ Konstant.configure "data_dir" => "#{Konstant.root}/tmp/test_data"
20
+
21
+ Konstant.reset_data_dir
22
+
23
+ if example.metadata[:fixture_projects]
24
+ Konstant.copy_fixture_projects
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: konstant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Moritz Schepp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.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: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: debugger
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: puma
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mixlib-cli
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mail
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - moritz.schepp@gmail.com
128
+ executables:
129
+ - konstant
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .rspec
135
+ - .ruby-version
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/konstant
141
+ - data/templates/data_dir/konstant.js
142
+ - data/templates/data_dir/projects/.gitkeep
143
+ - data/templates/project/build
144
+ - data/templates/project/cleanup
145
+ - data/templates/project/deploy
146
+ - data/templates/project/run.txt
147
+ - konstant.gemspec
148
+ - lib/konstant.rb
149
+ - lib/konstant/build.rb
150
+ - lib/konstant/builder.rb
151
+ - lib/konstant/cli.rb
152
+ - lib/konstant/project.rb
153
+ - lib/konstant/runner.rb
154
+ - lib/konstant/scheduler.rb
155
+ - lib/konstant/version.rb
156
+ - lib/konstant/web.rb
157
+ - public/assets/angular.min.js
158
+ - public/assets/app.js
159
+ - public/assets/bootstrap-theme.min.css
160
+ - public/assets/bootstrap.min.css
161
+ - public/assets/bootstrap.min.js
162
+ - public/assets/glyphicons-halflings-regular.eot
163
+ - public/assets/glyphicons-halflings-regular.svg
164
+ - public/assets/glyphicons-halflings-regular.ttf
165
+ - public/assets/glyphicons-halflings-regular.woff
166
+ - public/assets/jquery-2.1.1.min.js
167
+ - public/assets/style.css
168
+ - public/index.html
169
+ - spec/file_spec.rb
170
+ - spec/fixtures/projects/test_project_01/build
171
+ - spec/fixtures/projects/test_project_02/build
172
+ - spec/konstant/builder_spec.rb
173
+ - spec/konstant/runner_spec.rb
174
+ - spec/konstant_spec.rb
175
+ - spec/spec_helper.rb
176
+ homepage: https://github.com/coneda/konstant
177
+ licenses:
178
+ - MIT
179
+ metadata: {}
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.4.1
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: Continous delivery made easy.
200
+ test_files:
201
+ - spec/file_spec.rb
202
+ - spec/fixtures/projects/test_project_01/build
203
+ - spec/fixtures/projects/test_project_02/build
204
+ - spec/konstant/builder_spec.rb
205
+ - spec/konstant/runner_spec.rb
206
+ - spec/konstant_spec.rb
207
+ - spec/spec_helper.rb
208
+ has_rdoc: