ship_it 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.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/Gemfile +16 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +46 -0
  6. data/Rakefile +6 -0
  7. data/app/assets/images/.keep +0 -0
  8. data/app/assets/javascripts/application.js +28 -0
  9. data/app/assets/javascripts/polling.coffee +44 -0
  10. data/app/assets/stylesheets/application.css +24 -0
  11. data/app/controllers/application_controller.rb +34 -0
  12. data/app/controllers/branches_controller.rb +2 -0
  13. data/app/controllers/commits_controller.rb +2 -0
  14. data/app/controllers/concerns/.keep +0 -0
  15. data/app/controllers/deploy_options_controller.rb +38 -0
  16. data/app/controllers/deployments_controller.rb +70 -0
  17. data/app/controllers/environments_controller.rb +23 -0
  18. data/app/controllers/projects_controller.rb +51 -0
  19. data/app/controllers/sessions_controller.rb +31 -0
  20. data/app/controllers/users_controller.rb +2 -0
  21. data/app/helpers/application_helper.rb +70 -0
  22. data/app/mailers/.keep +0 -0
  23. data/app/models/.keep +0 -0
  24. data/app/models/branch.rb +15 -0
  25. data/app/models/commit.rb +8 -0
  26. data/app/models/concerns/.keep +0 -0
  27. data/app/models/deploy_option.rb +11 -0
  28. data/app/models/deployment.rb +137 -0
  29. data/app/models/environment.rb +29 -0
  30. data/app/models/project.rb +79 -0
  31. data/app/models/user.rb +18 -0
  32. data/app/views/deploy_options/new.html.slim +15 -0
  33. data/app/views/deployments/_current.html.slim +15 -0
  34. data/app/views/deployments/_deployment.html.slim +15 -0
  35. data/app/views/deployments/_details.html.slim +26 -0
  36. data/app/views/deployments/_progress.html.slim +2 -0
  37. data/app/views/deployments/in_progress.js.erb +1 -0
  38. data/app/views/deployments/show.html.slim +38 -0
  39. data/app/views/deployments/show.js.erb +1 -0
  40. data/app/views/environments/_changes.html.slim +24 -0
  41. data/app/views/environments/changes.js.erb +1 -0
  42. data/app/views/environments/show.html.slim +36 -0
  43. data/app/views/layouts/application.html.slim +30 -0
  44. data/app/views/layouts/homepage.html.slim +10 -0
  45. data/app/views/projects/edit.html.slim +27 -0
  46. data/app/views/projects/index.html.slim +22 -0
  47. data/app/views/projects/new.html.slim +11 -0
  48. data/app/views/projects/show.html.slim +29 -0
  49. data/app/views/sessions/homepage.html.slim +6 -0
  50. data/app/views/sessions/new.html.slim +7 -0
  51. data/bin/bundle +3 -0
  52. data/bin/rails +4 -0
  53. data/bin/rake +4 -0
  54. data/bin/ship_it +44 -0
  55. data/config.ru +4 -0
  56. data/config/application.rb +23 -0
  57. data/config/boot.rb +4 -0
  58. data/config/environment.rb +5 -0
  59. data/config/environments/development.rb +29 -0
  60. data/config/environments/production.rb +80 -0
  61. data/config/environments/test.rb +36 -0
  62. data/config/initializers/backtrace_silencers.rb +7 -0
  63. data/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/config/initializers/inflections.rb +16 -0
  65. data/config/initializers/mime_types.rb +5 -0
  66. data/config/initializers/omniauth_providers_patch.rb +16 -0
  67. data/config/initializers/secret_token.rb +12 -0
  68. data/config/initializers/session_store.rb +3 -0
  69. data/config/initializers/wrap_parameters.rb +14 -0
  70. data/config/locales/en.yml +23 -0
  71. data/config/routes.rb +28 -0
  72. data/db/migrate/20130828221203_create_projects.rb +9 -0
  73. data/db/migrate/20130828232058_create_deployments.rb +16 -0
  74. data/db/migrate/20130828234740_create_users.rb +9 -0
  75. data/db/migrate/20130828234748_create_deploy_options.rb +11 -0
  76. data/db/migrate/20130828234808_create_branches.rb +9 -0
  77. data/db/migrate/20130828234814_create_commits.rb +10 -0
  78. data/db/migrate/20130828234822_create_environments.rb +9 -0
  79. data/db/schema.rb +80 -0
  80. data/db/seeds.rb +7 -0
  81. data/lib/assets/.keep +0 -0
  82. data/lib/ship_it.rb +9 -0
  83. data/lib/ship_it/rails_app.rb +12 -0
  84. data/lib/ship_it/version.rb +3 -0
  85. data/lib/tasks/.keep +0 -0
  86. data/lib/tasks/ship_it.rake +76 -0
  87. data/log/.keep +0 -0
  88. data/public/404.html +58 -0
  89. data/public/422.html +58 -0
  90. data/public/500.html +57 -0
  91. data/public/favicon.ico +0 -0
  92. data/public/robots.txt +5 -0
  93. data/ship_it.gemspec +38 -0
  94. data/templates/project/.gitignore +6 -0
  95. data/templates/project/Gemfile +6 -0
  96. data/templates/project/config.ru +8 -0
  97. data/templates/project/config/database.yml +23 -0
  98. data/templates/project/db/.gitkeep +0 -0
  99. data/templates/project/db/schema.rb +75 -0
  100. data/templates/project/lib/ship_it/railtie.rb +20 -0
  101. data/templates/project/log/.gitkeep +0 -0
  102. data/test/controllers/.keep +0 -0
  103. data/test/controllers/branches_controller_test.rb +7 -0
  104. data/test/controllers/commits_controller_test.rb +7 -0
  105. data/test/controllers/configurations_controller_test.rb +7 -0
  106. data/test/controllers/deploy_options_controller_test.rb +7 -0
  107. data/test/controllers/deployments_controller_test.rb +7 -0
  108. data/test/controllers/environments_controller_test.rb +7 -0
  109. data/test/controllers/projects_controller_test.rb +7 -0
  110. data/test/controllers/users_controller_test.rb +7 -0
  111. data/test/fixtures/.keep +0 -0
  112. data/test/fixtures/branches.yml +11 -0
  113. data/test/fixtures/commits.yml +11 -0
  114. data/test/fixtures/configurations.yml +11 -0
  115. data/test/fixtures/deploy_options.yml +11 -0
  116. data/test/fixtures/deployments.yml +11 -0
  117. data/test/fixtures/environments.yml +11 -0
  118. data/test/fixtures/projects.yml +11 -0
  119. data/test/fixtures/users.yml +11 -0
  120. data/test/helpers/.keep +0 -0
  121. data/test/helpers/branches_helper_test.rb +4 -0
  122. data/test/helpers/commits_helper_test.rb +4 -0
  123. data/test/helpers/configurations_helper_test.rb +4 -0
  124. data/test/helpers/deploy_options_helper_test.rb +4 -0
  125. data/test/helpers/deployments_helper_test.rb +4 -0
  126. data/test/helpers/environments_helper_test.rb +4 -0
  127. data/test/helpers/projects_helper_test.rb +4 -0
  128. data/test/helpers/users_helper_test.rb +4 -0
  129. data/test/integration/.keep +0 -0
  130. data/test/mailers/.keep +0 -0
  131. data/test/models/.keep +0 -0
  132. data/test/models/branch_test.rb +7 -0
  133. data/test/models/commit_test.rb +7 -0
  134. data/test/models/configuration_test.rb +7 -0
  135. data/test/models/deploy_option_test.rb +7 -0
  136. data/test/models/deployment_test.rb +7 -0
  137. data/test/models/environment_test.rb +7 -0
  138. data/test/models/project_test.rb +7 -0
  139. data/test/models/user_test.rb +7 -0
  140. data/test/test_helper.rb +15 -0
  141. data/vendor/assets/javascripts/.keep +0 -0
  142. data/vendor/assets/stylesheets/.keep +0 -0
  143. metadata +431 -0
data/lib/assets/.keep ADDED
File without changes
data/lib/ship_it.rb ADDED
@@ -0,0 +1,9 @@
1
+ module ShipIt
2
+
3
+ class << self
4
+ attr_accessor :workspace, :log_dir
5
+ end
6
+
7
+ self.workspace = File.join(Dir.pwd, "workspace")
8
+ self.log_dir = File.join(Dir.pwd, "log")
9
+ end
@@ -0,0 +1,12 @@
1
+ require "rails"
2
+ require "sass-rails"
3
+ require "uglifier"
4
+ require "coffee-rails"
5
+ require "jquery-rails"
6
+ require "bootstrap-sass"
7
+ require "turbolinks"
8
+ require "slim"
9
+ require "sqlite3"
10
+ require "andand"
11
+
12
+ require File.expand_path('../../../config/environment', __FILE__)
@@ -0,0 +1,3 @@
1
+ module ShipIt
2
+ VERSION = "0.0.1"
3
+ end
data/lib/tasks/.keep ADDED
File without changes
@@ -0,0 +1,76 @@
1
+ require 'pp'
2
+
3
+ namespace :ship_it do
4
+ desc 'Polls for changes and deploys'
5
+ task :run => :environment do
6
+ threads = []
7
+ deployment_threads = {}
8
+
9
+ # wait for deployments to finish before terminating
10
+ Signal.trap("SIGTERM") do
11
+ puts "Waiting for threads to finish ..."
12
+
13
+ while(threads.any?(&:alive?))
14
+ sleep(1)
15
+ end
16
+
17
+ exit
18
+ end
19
+
20
+ # terminate immediately
21
+ Signal.trap("SIGINT") do
22
+ puts "Terminating threads ..."
23
+
24
+ threads.each do |thread|
25
+ thread.raise(Interrupt) if thread.alive?
26
+ end
27
+
28
+ exit
29
+ end
30
+
31
+ # cleanup old deployments
32
+ Deployment.in_progress.each do |deployment|
33
+ last_log_time = File.ctime(deployment.log_file) if deployment.log_file
34
+ deployment.update_attributes(:finished_at => last_log_time || Time.now, :success => false)
35
+ end
36
+
37
+ # main loop
38
+ begin
39
+ # remove terminated threads from lists
40
+ threads.select! { |thread| thread.alive? }
41
+ deployment_threads.select! { |id, thread| thread.alive? }
42
+
43
+ # terminate deployments
44
+ Deployment.awaiting_termination.each do |deployment|
45
+ thread = deployment_threads[deployment.id]
46
+ thread.raise(Interrupt) if thread && thread.alive?
47
+ end
48
+
49
+ # poll git for changes
50
+ threads << Thread.start do
51
+ Project.includes(:branches, :environments).each do |project|
52
+ project.poll!
53
+ end
54
+ end
55
+
56
+ # kickoff deployments
57
+ Deployment.pending.each do |deployment|
58
+ deployment.update_attributes(:started_at => Time.now)
59
+
60
+ threads << Thread.start do
61
+ begin
62
+ deployment.deploy!
63
+ rescue => e
64
+ pp e
65
+ pp e.backtrace
66
+ end
67
+ end
68
+
69
+ deployment_threads[deployment.id] = threads.last
70
+ end
71
+
72
+ sleep(5)
73
+ end while true
74
+
75
+ end
76
+ end
data/log/.keep ADDED
File without changes
data/public/404.html ADDED
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
data/public/422.html ADDED
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
data/public/500.html ADDED
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
data/public/robots.txt ADDED
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
data/ship_it.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "ship_it/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "ship_it"
9
+ s.version = ShipIt::VERSION
10
+ s.authors = ["Jeff Ching"]
11
+ s.email = ["ching.jeff@gmail.com"]
12
+ s.homepage = "http://github.com/chingor13/ship_it"
13
+ s.summary = "Dashboard to manage capistrano deploys"
14
+ s.description = "Dashboard to manage capistrano deploys"
15
+ s.license = "MIT"
16
+ s.executables << "ship_it"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = Dir["test/**/*"]
20
+
21
+ s.add_dependency "thor"
22
+ s.add_dependency "thin"
23
+
24
+ s.add_dependency "rails", "~> 4.0"
25
+ s.add_dependency "sass-rails", "~> 4.0.0"
26
+ s.add_dependency "uglifier", ">= 1.3.0"
27
+ s.add_dependency "coffee-rails", "~> 4.0.0"
28
+ s.add_dependency "jquery-rails"
29
+ s.add_dependency "bootstrap-sass"
30
+ s.add_dependency "turbolinks"
31
+ s.add_dependency "slim"
32
+ s.add_dependency "sqlite3"
33
+ s.add_dependency "omniauth"
34
+
35
+ s.add_dependency "cocaine"
36
+ s.add_dependency "git"
37
+ s.add_dependency "andand"
38
+ end
@@ -0,0 +1,6 @@
1
+ .bundle/
2
+ log/*.log
3
+ .DS_Store
4
+ tmp/
5
+ db/*.sqlite3
6
+ workspace
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'ship_it'
4
+
5
+ # change this if you want to change your database
6
+ gem 'mysql2'
@@ -0,0 +1,8 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require File.expand_path('../lib/ship_it/railtie', __FILE__)
4
+
5
+ require 'ship_it'
6
+ require 'ship_it/rails_app'
7
+
8
+ run ShipIt::Application
@@ -0,0 +1,23 @@
1
+ development:
2
+ adapter: mysql2
3
+ database: ship_it
4
+ username: root
5
+ password: root
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ test:
10
+ adapter: mysql2
11
+ database: ship_it_test
12
+ username: root
13
+ password: root
14
+ pool: 5
15
+ timeout: 5000
16
+
17
+ production:
18
+ adapter: mysql2
19
+ database: ship_it
20
+ username: root
21
+ password: root
22
+ pool: 5
23
+ timeout: 5000
File without changes
@@ -0,0 +1,75 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20130828234822) do
15
+
16
+ create_table "branches", force: true do |t|
17
+ t.integer "project_id"
18
+ t.string "name"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ create_table "commits", force: true do |t|
24
+ t.integer "deployment_id"
25
+ t.string "sha"
26
+ t.string "message"
27
+ t.datetime "created_at"
28
+ t.datetime "updated_at"
29
+ end
30
+
31
+ create_table "deploy_options", force: true do |t|
32
+ t.integer "project_id"
33
+ t.string "name"
34
+ t.string "value"
35
+ t.boolean "visible", default: true
36
+ t.datetime "created_at"
37
+ t.datetime "updated_at"
38
+ end
39
+
40
+ create_table "deployments", force: true do |t|
41
+ t.integer "branch_id"
42
+ t.integer "environment_id"
43
+ t.string "revision"
44
+ t.string "log_file"
45
+ t.boolean "success"
46
+ t.datetime "started_at"
47
+ t.datetime "finished_at"
48
+ t.integer "created_by_id"
49
+ t.boolean "user_terminated"
50
+ t.datetime "created_at"
51
+ t.datetime "updated_at"
52
+ end
53
+
54
+ create_table "environments", force: true do |t|
55
+ t.integer "project_id"
56
+ t.string "name"
57
+ t.datetime "created_at"
58
+ t.datetime "updated_at"
59
+ end
60
+
61
+ create_table "projects", force: true do |t|
62
+ t.string "name"
63
+ t.string "git_repo_url"
64
+ t.datetime "created_at"
65
+ t.datetime "updated_at"
66
+ end
67
+
68
+ create_table "users", force: true do |t|
69
+ t.string "name"
70
+ t.string "email_address"
71
+ t.datetime "created_at"
72
+ t.datetime "updated_at"
73
+ end
74
+
75
+ end