altria 0.2.0

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 (86) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +41 -0
  3. data/LICENSE.txt +22 -0
  4. data/Procfile +4 -0
  5. data/README.md +40 -0
  6. data/Rakefile +6 -0
  7. data/altria.gemspec +50 -0
  8. data/app/assets/images/rails.png +0 -0
  9. data/app/assets/javascripts/altria.js.coffee +1 -0
  10. data/app/assets/javascripts/altria/build_view.js.coffee +13 -0
  11. data/app/assets/javascripts/altria/job_view.js.coffee +10 -0
  12. data/app/assets/javascripts/altria/server_event.js.coffee +8 -0
  13. data/app/assets/javascripts/application.js +20 -0
  14. data/app/assets/javascripts/events.js.coffee +13 -0
  15. data/app/assets/stylesheets/application.css +14 -0
  16. data/app/assets/stylesheets/builds.scss +35 -0
  17. data/app/assets/stylesheets/common.scss +69 -0
  18. data/app/assets/stylesheets/jobs.scss +129 -0
  19. data/app/assets/stylesheets/layout.scss +19 -0
  20. data/app/assets/stylesheets/mixin.scss +26 -0
  21. data/app/controllers/application_controller.rb +24 -0
  22. data/app/controllers/builds_controller.rb +48 -0
  23. data/app/controllers/events_controller.rb +27 -0
  24. data/app/controllers/jobs_controller.rb +50 -0
  25. data/app/helpers/application_helper.rb +5 -0
  26. data/app/models/build.rb +72 -0
  27. data/app/models/job.rb +141 -0
  28. data/app/views/builds/show.html.slim +36 -0
  29. data/app/views/jobs/_form.html.slim +22 -0
  30. data/app/views/jobs/edit.html.slim +9 -0
  31. data/app/views/jobs/index.html.slim +19 -0
  32. data/app/views/jobs/new.html.slim +7 -0
  33. data/app/views/jobs/show.html.slim +28 -0
  34. data/app/views/layouts/application.html.slim +11 -0
  35. data/app/workers/build_worker.rb +13 -0
  36. data/app/workers/job_enqueue_worker.rb +13 -0
  37. data/bin/altria +6 -0
  38. data/config.ru +4 -0
  39. data/config/application.rb +52 -0
  40. data/config/boot.rb +6 -0
  41. data/config/database.yml +29 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +23 -0
  44. data/config/environments/production.rb +71 -0
  45. data/config/environments/test.rb +33 -0
  46. data/config/initializers/backtrace_silencers.rb +7 -0
  47. data/config/initializers/inflections.rb +15 -0
  48. data/config/initializers/mime_types.rb +5 -0
  49. data/config/initializers/redis.rb +1 -0
  50. data/config/initializers/secret_token.rb +8 -0
  51. data/config/initializers/session_store.rb +8 -0
  52. data/config/initializers/wrap_parameters.rb +14 -0
  53. data/config/locales/en.yml +5 -0
  54. data/config/routes.rb +9 -0
  55. data/db/migrate/20130531143239_create_jobs.rb +10 -0
  56. data/db/migrate/20130531155155_create_builds.rb +14 -0
  57. data/db/migrate/20130608153135_change_job_column_name_from_config_to_properties.rb +9 -0
  58. data/db/migrate/20130608153655_add_column_properties_to_builds.rb +5 -0
  59. data/db/schema.rb +36 -0
  60. data/db/seeds.rb +7 -0
  61. data/lib/altria.rb +13 -0
  62. data/lib/altria/command.rb +61 -0
  63. data/lib/altria/configuration.rb +9 -0
  64. data/lib/altria/executer.rb +37 -0
  65. data/lib/altria/proprietary.rb +56 -0
  66. data/lib/altria/responder.rb +12 -0
  67. data/lib/altria/scheduler.rb +55 -0
  68. data/lib/altria/version.rb +3 -0
  69. data/lib/altria/workspace.rb +26 -0
  70. data/lib/tasks/resque.rake +3 -0
  71. data/public/404.html +26 -0
  72. data/public/422.html +26 -0
  73. data/public/500.html +25 -0
  74. data/public/favicon.ico +0 -0
  75. data/public/robots.txt +5 -0
  76. data/script/clock.rb +5 -0
  77. data/script/rails +6 -0
  78. data/spec/altria/command_spec.rb +53 -0
  79. data/spec/factories/build.rb +7 -0
  80. data/spec/factories/job.rb +7 -0
  81. data/spec/models/build_spec.rb +35 -0
  82. data/spec/models/job_spec.rb +101 -0
  83. data/spec/requests/builds_spec.rb +81 -0
  84. data/spec/requests/jobs_spec.rb +88 -0
  85. data/spec/spec_helper.rb +48 -0
  86. metadata +417 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b98f66713f2b99ebd22c0b8f196a391cfc6cb1e
4
+ data.tar.gz: a15fa6c3775b36dc6c41d7a8be14a41af121c8ba
5
+ SHA512:
6
+ metadata.gz: ec56abf4c8e3058fd8f5448ae5760d32525bdd2069a727d034aa5f10334a12973696730fc589e0e5696a4e34417863bbdb24a042805050049fd14844a4cb2a7d
7
+ data.tar.gz: 0a544b51ce1e18e99549cad616afd3b728417247078ea28f24843a2457ea05dde296021d704e4101a90e0ddfc0998ebba6d0d50b98703b185b0163e83d0d570a
data/Gemfile ADDED
@@ -0,0 +1,41 @@
1
+ require "pathname"
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "font-awesome-rails"
8
+ gem "jquery-rails"
9
+ gem "kaminari"
10
+ gem "quiet_assets"
11
+ gem "rails-backbone"
12
+ gem "resque"
13
+ gem "slim"
14
+ gem "weak_parameters"
15
+
16
+ group :development, :test do
17
+ gem "pry-rails"
18
+ end
19
+
20
+ group :test do
21
+ gem "autodoc"
22
+ gem "coveralls", require: false
23
+ gem "factory_girl_rails"
24
+ gem "response_code_matchers"
25
+ gem "rspec-json_matcher"
26
+ gem "rspec-rails"
27
+ gem "simplecov"
28
+ end
29
+
30
+ group :assets do
31
+ gem "coffee-rails"
32
+ gem "coffee-script"
33
+ gem "sass"
34
+ gem "sass-rails"
35
+ gem "uglifier"
36
+ end
37
+
38
+ # Put Gemfile.local to use arbitrary gems for your use case.
39
+ workspace = ENV["WORKSPACE_PATH"] || "."
40
+ path = "#{workspace}/Gemfile.local"
41
+ eval File.read(path) if File.exist?(path)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryo Nakamura
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/Procfile ADDED
@@ -0,0 +1,4 @@
1
+ redis: redis-server
2
+ rails: rails s
3
+ worker: bundle exec rake resque:work QUEUE="*"
4
+ clock: bundle exec clockwork script/clock.rb
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Altria [![Build Status](https://travis-ci.org/r7kamura/altria.png?branch=master)](https://travis-ci.org/r7kamura/altria) [![Code Climate](https://codeclimate.com/github/r7kamura/altria.png)](https://codeclimate.com/github/r7kamura/altria) [![Coverage Status](https://coveralls.io/repos/r7kamura/altria/badge.png)](https://coveralls.io/r/r7kamura/altria)
2
+ Casual CI server system.
3
+
4
+ ![](http://gifzo.net/f2zmQFtkzv.gif)
5
+
6
+ ## Usage
7
+ ```
8
+ # Install mysql & redis
9
+ $ brew install mysql redis
10
+
11
+ # From github (recommended)
12
+ $ git clone git@github.com:r7kamura/altria
13
+ $ cd altria
14
+ $ ./bin/altria setup
15
+ $ ./bin/altria start
16
+ ```
17
+
18
+ ## Development
19
+ Altria is just a rails application with some middlewares.
20
+
21
+ * rails4: notify build start/finish events via live streaming
22
+ * clockwork: cron scheduler
23
+ * foreman: process manager
24
+ * mysql: store jobs & builds
25
+ * resque: background worker using redis
26
+ * jquery: ajax updated view
27
+ * redis: build started/finished notification by pubsub system
28
+ * autodoc: generate [RESTful API documents](https://github.com/r7kamura/altria/blob/master/doc) from request-specs
29
+
30
+ ## Plugins
31
+ * [altria-git](https://github.com/r7kamura/altria-git): Git integration plugin
32
+ * [altria-simple_cov](https://github.com/r7kamura/altria-simple_cov): Save simplecov coverage for each build
33
+ * [altria-pipeline](https://github.com/r7kamura/altria-pipeline): Lets your job to kick another job after finished
34
+
35
+ ```ruby
36
+ # Put your favorite plugin gems into Gemfile.local
37
+ gem "altria-git", git: "git@github.com:r7kamura/altria-git.git"
38
+ gem "altria-simple_cov", git: "git@github.com:r7kamura/altria-simple_cov.git"
39
+ gem "altria-pipeline", git: "git@github.com:r7kamura/altria-pipeline.git"
40
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require File.expand_path("../config/application", __FILE__)
4
+ Altria::Application.load_tasks
5
+
6
+ require "bundler/gem_tasks"
data/altria.gemspec ADDED
@@ -0,0 +1,50 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "altria/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "altria"
7
+ spec.version = Altria::VERSION
8
+ spec.authors = ["Ryo Nakamura"]
9
+ spec.email = ["r7kamura@gmail.com"]
10
+ spec.description = "I am altria."
11
+ spec.summary = "altria"
12
+ spec.homepage = "https://github.com/r7kamura/altria"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = Dir["{app,bin,config,db,lib,plugins,public,script,spec}/**/*"]
16
+ spec.files += %w[
17
+ Gemfile
18
+ LICENSE.txt
19
+ Procfile
20
+ README.md
21
+ Rakefile
22
+ config.ru
23
+ altria.gemspec
24
+ ]
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "clockwork"
30
+ spec.add_dependency "coffee-rails", ">= 4.0.0"
31
+ spec.add_dependency "font-awesome-rails"
32
+ spec.add_dependency "foreman"
33
+ spec.add_dependency "jquery-rails"
34
+ spec.add_dependency "kaminari"
35
+ spec.add_dependency "mysql2"
36
+ spec.add_dependency "puma"
37
+ spec.add_dependency "quiet_assets"
38
+ spec.add_dependency "rails", ">= 4.0.0"
39
+ spec.add_dependency "rails-backbone"
40
+ spec.add_dependency "rake"
41
+ spec.add_dependency "redis"
42
+ spec.add_dependency "resque"
43
+ spec.add_dependency "sass-rails", ">= 4.0.0.rc1"
44
+ spec.add_dependency "slim"
45
+ spec.add_dependency "uglifier", ">= 1.3.0"
46
+ spec.add_dependency "weak_parameters"
47
+
48
+ spec.add_development_dependency "bundler"
49
+ spec.add_development_dependency "pry-rails"
50
+ end
Binary file
@@ -0,0 +1 @@
1
+ window.Altria = {}
@@ -0,0 +1,13 @@
1
+ class window.Altria.BuildView
2
+ constructor: () ->
3
+ @model = new Backbone.Model()
4
+ @model.on 'change', => @render()
5
+
6
+ element: ->
7
+ $("#build#{@model.get('id')}")
8
+
9
+ render: ->
10
+ @element()
11
+ .removeClass()
12
+ .addClass(@model.get('status'))
13
+ .find('.time').text(@model.get('finished_at'))
@@ -0,0 +1,10 @@
1
+ window.Altria.JobView = Backbone.View.extend
2
+ initialize: () ->
3
+
4
+ render: ->
5
+ console.log(@el)
6
+ console.log(@$el)
7
+ @$el.removeClass().addClass(@status())
8
+
9
+ status: ->
10
+ @model.get('status')
@@ -0,0 +1,8 @@
1
+ class window.Altria.ServerEvent
2
+ constructor: ->
3
+ @source = new EventSource('/events')
4
+
5
+ on: (string, callback) ->
6
+ for eventName in string.split(' ')
7
+ @source.addEventListener eventName, (event) ->
8
+ callback($.parseJSON(event.data))
@@ -0,0 +1,20 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require underscore
16
+ //= require backbone
17
+ //
18
+ //= require altria
19
+ //= require_tree ./altria
20
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ $ ->
2
+ $('.jobs_controller.index_action').each ->
3
+ new Altria.ServerEvent().on 'build.started build.finished', (attributes) ->
4
+ view = new Altria.JobView
5
+ el: "#job#{attributes.job_id}"
6
+ model: new Backbone.Model(attributes)
7
+ view.render()
8
+
9
+ $('.jobs_controller.show_action').each ->
10
+ view = new Altria.BuildView()
11
+ event = new Altria.ServerEvent()
12
+ event.on 'build.finished', (attributes) ->
13
+ view.model.set(attributes)
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require font-awesome
12
+ *= require_self
13
+ *= require_tree .
14
+ */
@@ -0,0 +1,35 @@
1
+ @import "mixin";
2
+
3
+ section.build {
4
+ &.success h1 {
5
+ color: #27AE60;
6
+ }
7
+
8
+ &.failure h1 {
9
+ color: #C0392B;
10
+ }
11
+
12
+ &.success h1 span:before {
13
+ content: "\F058";
14
+ }
15
+
16
+ &.build.failure h1 span:before {
17
+ content: "\F057";
18
+ }
19
+
20
+ &.build.unfinished h1 span:before {
21
+ content: "\F056";
22
+ }
23
+
24
+ td {
25
+ padding-right: 1em;
26
+ }
27
+
28
+ pre {
29
+ @include box;
30
+ margin-top: 1em;
31
+ padding: .5em 1em;
32
+ background: #eee;
33
+ overflow-x: scroll;
34
+ }
35
+ }
@@ -0,0 +1,69 @@
1
+ @import "mixin";
2
+
3
+ * {
4
+ margin: 0;
5
+ padding: 0;
6
+ }
7
+
8
+ body {
9
+ color: #333;
10
+ font-family: "Helvetica Neue", "Calibri", sans-serif;
11
+ line-height: 1.7;
12
+ }
13
+
14
+ a {
15
+ color: inherit;
16
+ text-decoration: none;
17
+ }
18
+
19
+ i {
20
+ margin-right: .3em;
21
+ }
22
+
23
+ textarea,
24
+ input {
25
+ font-size: 1em;
26
+ }
27
+
28
+ textarea,
29
+ input[type="text"] {
30
+ @include box;
31
+ width: 100%;
32
+ }
33
+
34
+ *:before {
35
+ margin-right: .3em;
36
+ font-family: FontAwesome;
37
+ }
38
+
39
+ .button {
40
+ @include box;
41
+ width: 10em;
42
+ font-size: 1em;
43
+ color: white;
44
+ background: #F39C12;
45
+ border-color: #F39C12;
46
+ line-height: inherit;
47
+ cursor: pointer;
48
+ text-align: center;
49
+ }
50
+
51
+ section.breadcrumbs {
52
+ ul {
53
+ @include box;
54
+ border-color: #eee;
55
+ background: #eee;
56
+ list-style: none;
57
+ overflow: hidden;
58
+ color: #888;
59
+ }
60
+
61
+ li {
62
+ float: left;
63
+ margin-right: 1em;
64
+ }
65
+
66
+ li.delimiter:before {
67
+ content: "\F105";
68
+ }
69
+ }
@@ -0,0 +1,129 @@
1
+ @import "mixin";
2
+
3
+ section.jobs {
4
+ h1:before {
5
+ content: "\F13D";
6
+ }
7
+
8
+ p {
9
+ color: #ccc;
10
+ }
11
+
12
+ ul {
13
+ margin-top: 1em;
14
+ }
15
+ }
16
+
17
+ section.job_settings {
18
+ h1:before {
19
+ content: "\F085";
20
+ }
21
+
22
+ td {
23
+ padding-right: 1em;
24
+ }
25
+
26
+ input[type="submit"] {
27
+ margin-top: 1em;
28
+ background: #34495e;
29
+ border-color: #34495e;
30
+ }
31
+ }
32
+
33
+ section.jobs,
34
+ section.builds {
35
+ .buttons {
36
+ overflow: hidden;
37
+ }
38
+
39
+ .buttons a {
40
+ float: left;
41
+ display: block;
42
+ margin-right: 1em;
43
+ }
44
+
45
+ .buttons a.new:before {
46
+ content: "\F040";
47
+ }
48
+
49
+ .buttons a.run:before {
50
+ content: "\F04B";
51
+ }
52
+
53
+ .buttons a.new,
54
+ .buttons a.settings {
55
+ background: #2C3E50;
56
+ border-color: #2C3E50;
57
+ }
58
+
59
+ .buttons a.settings:before {
60
+ content: "\F013";
61
+ }
62
+
63
+ .buttons a.delete {
64
+ background: #C0392B;
65
+ border-color: #C0392B;
66
+ }
67
+
68
+ .buttons a.delete:before {
69
+ content: "\F014";
70
+ }
71
+
72
+ .button {
73
+ margin-top: .5em;
74
+ }
75
+
76
+ ul {
77
+ margin-top: 1em;
78
+ list-style: none;
79
+ }
80
+
81
+ li a {
82
+ @include box;
83
+ display: block;
84
+ }
85
+
86
+ li a:hover {
87
+ background: #fafafa;
88
+ }
89
+
90
+ li.unfinished a {
91
+ @include stripe;
92
+ }
93
+
94
+ li.unfinished a:before {
95
+ content: "\F056";
96
+ }
97
+
98
+ li.success a:before {
99
+ content: "\F058";
100
+ color: #27AE60;
101
+ }
102
+
103
+ li.failure a:before {
104
+ content: "\F057";
105
+ color: #C0392B;
106
+ }
107
+
108
+ li.success a {
109
+ border-color: #27AE60;
110
+ }
111
+
112
+ li.failure a {
113
+ border-color: #C0392B;
114
+ }
115
+
116
+ li span {
117
+ margin-right: 1em;
118
+ }
119
+ }
120
+
121
+ section.builds {
122
+ h1:before {
123
+ content: "\F0FB";
124
+ }
125
+
126
+ .pagination {
127
+ text-align: center;
128
+ }
129
+ }