perkins 0.0.3 → 0.0.5
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 +4 -4
- data/.gitignore +3 -0
- data/Gemfile +1 -0
- data/README.md +11 -8
- data/Rakefile +1 -18
- data/config/database.yml +19 -0
- data/db/migrate/20150130143050_create_builds.rb +1 -1
- data/db/migrate/20150220143051_add_build_status_to_build_reports.rb +10 -0
- data/db/migrate/20150220143053_add_commit_to_build_reports.rb +10 -0
- data/db/migrate/20150220143054_add_hook_id_to_repo.rb +10 -0
- data/db/schema.rb +4 -2
- data/examples/Capfile +17 -0
- data/examples/Gemfile +14 -1
- data/examples/Gemfile.lock +45 -19
- data/examples/Procfile +8 -3
- data/examples/README.md +12 -0
- data/examples/boot.rb +5 -4
- data/examples/config.ru +2 -11
- data/examples/{database.yml → config/database.example.yml} +0 -0
- data/examples/config/database.yml +27 -0
- data/examples/config/deploy.rb +78 -0
- data/examples/config/deploy/staging.rb +61 -0
- data/examples/{rainbows.rb → config/rainbows/development.rb} +1 -1
- data/examples/config/rainbows/production.rb +56 -0
- data/examples/{sidekiq.yml → config/sidekiq.yml} +0 -0
- data/examples/db/schema.rb +43 -0
- data/examples/rakefile +8 -0
- data/lib/perkins/application.rb +1 -1
- data/lib/perkins/assets.rb +3 -3
- data/lib/perkins/assets/javascripts/app.js +1 -0
- data/lib/perkins/assets/javascripts/perkings.js.coffee +14 -9
- data/lib/perkins/assets/javascripts/perkins/helpers.js.coffee +2 -2
- data/lib/perkins/assets/javascripts/perkins/m/models.js.coffee +15 -9
- data/lib/perkins/assets/javascripts/perkins/router.js.coffee +1 -0
- data/lib/perkins/assets/javascripts/perkins/v/my_repos.js.coffee +1 -1
- data/lib/perkins/assets/javascripts/perkins/v/orgs.js.coffee +1 -1
- data/lib/perkins/assets/javascripts/perkins/v/repo.js.coffee +38 -5
- data/lib/perkins/assets/javascripts/templates/repo.hamlc +5 -14
- data/lib/perkins/assets/javascripts/templates/repos/build_row.hamlc +10 -5
- data/lib/perkins/assets/javascripts/templates/repos/config.hamlc +23 -13
- data/lib/perkins/assets/javascripts/templates/repos/report_detail.hamlc +6 -6
- data/lib/perkins/assets/javascripts/vendor/eventsource.polyfill.js +512 -0
- data/lib/perkins/build/script.rb +2 -1
- data/lib/perkins/build/script/go.rb +1 -1
- data/lib/perkins/build/script/ruby.rb +1 -1
- data/lib/perkins/build/script/stages.rb +0 -1
- data/lib/perkins/build_report.rb +27 -7
- data/lib/perkins/build_worker.rb +10 -15
- data/lib/perkins/git_loader_worker.rb +1 -14
- data/lib/perkins/repo.rb +106 -21
- data/lib/perkins/runner.rb +57 -12
- data/lib/perkins/server.rb +42 -46
- data/lib/perkins/socket_server.rb +38 -0
- data/lib/perkins/version.rb +1 -1
- data/lib/tasks/db_tasks.rake +35 -0
- data/perkins.gemspec +16 -19
- data/spec/README.md +3 -0
- data/spec/lib/build/build_spec.rb +7 -3
- data/spec/lib/repo_spec.rb +23 -32
- data/spec/lib/runner_spec.rb +52 -2
- data/spec/lib/server_spec.rb +15 -6
- data/spec/spec_helper.rb +6 -5
- metadata +21 -57
- data/.DS_Store +0 -0
- data/lib/perkins/views/builds.haml +0 -43
- data/lib/perkins/views/menu.haml +0 -18
- data/lib/perkins/views/orgs.haml +0 -101
- data/lib/perkins/views/profile.haml +0 -31
- data/lib/perkins/views/repos/config.haml +0 -72
- data/lib/perkins/views/repos/github.haml +0 -45
- data/lib/perkins/views/repos/menu.haml +0 -17
- data/lib/perkins/views/repos/repo.haml +0 -64
- data/lib/perkins/views/repos/spinner.haml +0 -3
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
production:
|
2
|
+
adapter: mysql2
|
3
|
+
database: perkins_production
|
4
|
+
username: root
|
5
|
+
password:
|
6
|
+
host: 127.0.0.1
|
7
|
+
pool: 22
|
8
|
+
|
9
|
+
development:
|
10
|
+
|
11
|
+
adapter: mysql2
|
12
|
+
database: perkins_development
|
13
|
+
username: root
|
14
|
+
password:
|
15
|
+
host: localhost
|
16
|
+
pool: 22
|
17
|
+
|
18
|
+
#adapter: sqlite3
|
19
|
+
#database: ./db/development2.sqlite3 #point to perkins gem database
|
20
|
+
#pool: 25
|
21
|
+
#timeout: 5000
|
22
|
+
|
23
|
+
test:
|
24
|
+
adapter: sqlite3
|
25
|
+
database: db/test.sqlite3
|
26
|
+
pool: 5
|
27
|
+
timeout: 5000
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# config valid only for current version of Capistrano
|
2
|
+
lock '3.4.0'
|
3
|
+
|
4
|
+
#set :application, 'my_app_name'
|
5
|
+
#set :repo_url, 'git@example.com:me/my_repo.git'
|
6
|
+
|
7
|
+
# Default branch is :master
|
8
|
+
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
9
|
+
|
10
|
+
# Default deploy_to directory is /var/www/my_app_name
|
11
|
+
# set :deploy_to, '/var/www/my_app_name'
|
12
|
+
|
13
|
+
# Default value for :scm is :git
|
14
|
+
# set :scm, :git
|
15
|
+
|
16
|
+
# Default value for :format is :pretty
|
17
|
+
# set :format, :pretty
|
18
|
+
|
19
|
+
# Default value for :log_level is :debug
|
20
|
+
# set :log_level, :debug
|
21
|
+
|
22
|
+
# Default value for :pty is false
|
23
|
+
# set :pty, true
|
24
|
+
|
25
|
+
# Default value for :linked_files is []
|
26
|
+
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
|
27
|
+
|
28
|
+
# Default value for linked_dirs is []
|
29
|
+
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
|
30
|
+
|
31
|
+
# Default value for default_env is {}
|
32
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
33
|
+
|
34
|
+
# Default value for keep_releases is 5
|
35
|
+
# set :keep_releases, 5
|
36
|
+
|
37
|
+
after 'deploy:publishing', 'deploy:restart'
|
38
|
+
namespace :deploy do
|
39
|
+
task :restart do
|
40
|
+
invoke 'rainbows:restart'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
namespace :deploy do
|
45
|
+
|
46
|
+
after :restart, :clear_cache do
|
47
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
48
|
+
# Here we can do anything such as:
|
49
|
+
# within release_path do
|
50
|
+
# execute :rake, 'cache:clear'
|
51
|
+
# end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
=begin
|
60
|
+
|
61
|
+
If preload_app:true and you need capistrano to cleanup your oldbin pid use:
|
62
|
+
|
63
|
+
after 'deploy:publishing', 'deploy:restart'
|
64
|
+
namespace :deploy do
|
65
|
+
task :restart do
|
66
|
+
invoke 'rainbows:legacy_restart'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
Otherwise use:
|
70
|
+
|
71
|
+
after 'deploy:publishing', 'deploy:restart'
|
72
|
+
namespace :deploy do
|
73
|
+
task :restart do
|
74
|
+
invoke 'rainbows:reload'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
=end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# role-based syntax
|
13
|
+
# ==================
|
14
|
+
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
18
|
+
# Don't use `:all`, it's a meta role.
|
19
|
+
|
20
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
21
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
22
|
+
# role :db, %w{deploy@example.com}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Configuration
|
27
|
+
# =============
|
28
|
+
# You can set any configuration variable like in config/deploy.rb
|
29
|
+
# These variables are then only loaded and set in this stage.
|
30
|
+
# For available Capistrano configuration variables see the documentation page.
|
31
|
+
# http://capistranorb.com/documentation/getting-started/configuration/
|
32
|
+
# Feel free to add new variables to customise your setup.
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# Custom SSH Options
|
37
|
+
# ==================
|
38
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
39
|
+
# limited set of options, consult the Net::SSH documentation.
|
40
|
+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
41
|
+
#
|
42
|
+
# Global options
|
43
|
+
# --------------
|
44
|
+
# set :ssh_options, {
|
45
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
46
|
+
# forward_agent: false,
|
47
|
+
# auth_methods: %w(password)
|
48
|
+
# }
|
49
|
+
#
|
50
|
+
# The server-based syntax can be used to override options:
|
51
|
+
# ------------------------------------
|
52
|
+
# server 'example.com',
|
53
|
+
# user: 'user_name',
|
54
|
+
# roles: %w{web app},
|
55
|
+
# ssh_options: {
|
56
|
+
# user: 'user_name', # overrides user setting above
|
57
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
58
|
+
# forward_agent: false,
|
59
|
+
# auth_methods: %w(publickey password)
|
60
|
+
# # password: 'please use keys'
|
61
|
+
# }
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# paths
|
2
|
+
# => You can also choose the using Ruby: app_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
app_path = "/var/www/perkins/"
|
4
|
+
|
5
|
+
working_directory "#{app_path}/current"
|
6
|
+
pid "#{app_path}/current/tmp/pids/rainbows.pid"
|
7
|
+
|
8
|
+
# listen
|
9
|
+
listen "/var/www/perkins/shared/perkins.sock", :backlog => 64
|
10
|
+
|
11
|
+
# logging
|
12
|
+
stderr_path "log/rainbows.stderr.log"
|
13
|
+
stdout_path "log/rainbows.stdout.log"
|
14
|
+
|
15
|
+
# workers
|
16
|
+
worker_processes 3
|
17
|
+
|
18
|
+
#worker_processes 4 # assuming four CPU cores
|
19
|
+
Rainbows! do
|
20
|
+
use :EventMachine
|
21
|
+
worker_connections 100
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# use correct Gemfile on restarts
|
26
|
+
before_exec do |server|
|
27
|
+
ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
|
28
|
+
end
|
29
|
+
|
30
|
+
# preload
|
31
|
+
preload_app true
|
32
|
+
|
33
|
+
before_fork do |server, worker|
|
34
|
+
# the following is highly recomended for Rails + "preload_app true"
|
35
|
+
# as there's no need for the master process to hold a connection
|
36
|
+
# if defined?(ActiveRecord::Base)
|
37
|
+
# ActiveRecord::Base.connection.disconnect!
|
38
|
+
# end
|
39
|
+
|
40
|
+
# Before forking, kill the master process that belongs to the .oldbin PID.
|
41
|
+
# This enables 0 downtime deploys.
|
42
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
43
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
44
|
+
begin
|
45
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
46
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
47
|
+
# someone else did our job for us
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#after_fork do |server, worker|
|
53
|
+
# if defined?(ActiveRecord::Base)
|
54
|
+
# ActiveRecord::Base.establish_connection
|
55
|
+
# end
|
56
|
+
#end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
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: 20150220143054) do
|
15
|
+
|
16
|
+
create_table "build_reports", force: true do |t|
|
17
|
+
t.string "sha"
|
18
|
+
t.string "branch"
|
19
|
+
t.string "build_time"
|
20
|
+
t.string "duration"
|
21
|
+
t.text "response"
|
22
|
+
t.boolean "status"
|
23
|
+
t.integer "repo_id"
|
24
|
+
t.string "build_status"
|
25
|
+
t.text "commit"
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table "repos", force: true do |t|
|
29
|
+
t.string "url"
|
30
|
+
t.string "name"
|
31
|
+
t.string "working_dir"
|
32
|
+
t.string "branch"
|
33
|
+
t.integer "gb_id"
|
34
|
+
t.text "github_data"
|
35
|
+
t.boolean "cached"
|
36
|
+
t.string "build_status"
|
37
|
+
t.string "download_status"
|
38
|
+
t.integer "hook_id"
|
39
|
+
end
|
40
|
+
|
41
|
+
add_index "repos", ["gb_id"], name: "index_repos_on_gb_id", unique: true, using: :btree
|
42
|
+
|
43
|
+
end
|
data/examples/rakefile
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
spec = Gem::Specification.find_by_name 'perkins'
|
6
|
+
import "#{spec.gem_dir}/lib/tasks/db_tasks.rake"
|
7
|
+
ActiveRecord::Migrator.migrations_paths << "#{spec.gem_dir}/db/migrate"
|
8
|
+
|
1
9
|
desc "Open an irb session preloaded with this library"
|
2
10
|
task :console do
|
3
11
|
sh "irb -rubygems -I lib -r ./boot.rb"
|
data/lib/perkins/application.rb
CHANGED
@@ -2,7 +2,7 @@ module Perkins
|
|
2
2
|
class Application
|
3
3
|
attr_accessor :host , :port, :working_dir, :redis, :database, :sse_endpoint
|
4
4
|
attr_reader :server
|
5
|
-
attr_accessor :github_client_id, :github_client_secret
|
5
|
+
attr_accessor :github_client_id, :github_client_secret, :port
|
6
6
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :instance
|
data/lib/perkins/assets.rb
CHANGED
@@ -2,7 +2,6 @@ module Perkins
|
|
2
2
|
class Assets < Sinatra::Base
|
3
3
|
|
4
4
|
require "haml_coffee_assets"
|
5
|
-
|
6
5
|
configure do
|
7
6
|
set :assets, (Sprockets::Environment.new { |env|
|
8
7
|
env.append_path(settings.root + "/assets/images")
|
@@ -10,8 +9,9 @@ module Perkins
|
|
10
9
|
env.append_path(settings.root + "/assets/stylesheets")
|
11
10
|
# compress everything in production
|
12
11
|
if ENV["RACK_ENV"] == "production"
|
13
|
-
|
14
|
-
env.
|
12
|
+
#require "yui/compressor"
|
13
|
+
#env.js_compressor = YUI::JavaScriptCompressor.new
|
14
|
+
#env.css_compressor = YUI::CssCompressor.new
|
15
15
|
end
|
16
16
|
})
|
17
17
|
end
|
@@ -1,16 +1,18 @@
|
|
1
1
|
|
2
2
|
$(document).ready ()->
|
3
3
|
|
4
|
+
Log.DEBUG = false
|
5
|
+
|
4
6
|
$("abbr.timeago").livequery ->
|
5
7
|
$(@).timeago()
|
6
8
|
|
7
9
|
#reading
|
8
|
-
es = new EventSource("/stream")
|
9
|
-
es.onmessage = (e) ->
|
10
|
-
console.log("MESSAGE RECEIVED")
|
11
|
-
console.log(e.data)
|
12
|
-
a = JSON.parse(e.data)
|
13
10
|
|
11
|
+
source = new EventSource('/stream');
|
12
|
+
source.addEventListener 'message', (event)->
|
13
|
+
a = JSON.parse(event.data)
|
14
|
+
console.log(a)
|
15
|
+
|
14
16
|
if a.repo.status == "stop"
|
15
17
|
$("#repo-#{a.repo.id} .fa-refresh").removeClass("fa-spin")
|
16
18
|
$(".repo-#{a.repo.id}-spinner.build-status").addClass("hidden")
|
@@ -21,10 +23,9 @@ $(document).ready ()->
|
|
21
23
|
#if repo.id is current repo then reload page
|
22
24
|
if current_repo && a.repo.id is current_repo.id && (a.repo.status is "stop" || a.repo.status is "downloaded" )
|
23
25
|
Backbone.history.loadUrl()
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
console.log(e)
|
26
|
+
#current_repo.fetch()
|
27
|
+
#if current_view.build
|
28
|
+
# current_view.build.fetch
|
28
29
|
|
29
30
|
NProgress.configure({ showSpinner: false })
|
30
31
|
|
@@ -38,6 +39,10 @@ $(document).ready ()->
|
|
38
39
|
console.log "AJAX STOP!"
|
39
40
|
NProgress.done()
|
40
41
|
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
41
46
|
#application
|
42
47
|
class Perkins.AppLayout extends Backbone.Marionette.Layout
|
43
48
|
template: "#perkins-layout"
|
@@ -4,8 +4,8 @@ Perkins.Helpers.gravatar_url = (email, size) ->
|
|
4
4
|
gravatar_id = MD5(email)
|
5
5
|
"http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}"
|
6
6
|
|
7
|
-
Perkins.Helpers.commit_url = (
|
8
|
-
"#{
|
7
|
+
Perkins.Helpers.commit_url = (sha) ->
|
8
|
+
"#{current_repo.get("http_url")}/commit/#{sha}"
|
9
9
|
|
10
10
|
Perkins.Helpers.status_label = (status)->
|
11
11
|
label = if status == true then "success" else "default"
|
@@ -5,24 +5,30 @@ class Perkins.Models.Profile extends Backbone.Model
|
|
5
5
|
class Perkins.Models.Repo extends Backbone.Model
|
6
6
|
url: ()->
|
7
7
|
if @.get('name')
|
8
|
-
"/repos/#{@.get('name')}"
|
8
|
+
"/repos/#{@.get('name')}.json"
|
9
9
|
else
|
10
|
-
"/repos"
|
10
|
+
"/repos.json"
|
11
11
|
|
12
12
|
class Perkins.Collections.Repos extends Backbone.Collection
|
13
13
|
model: Perkins.Models.Repo
|
14
14
|
url: ->
|
15
|
-
"/repos"
|
15
|
+
"/repos.json"
|
16
16
|
|
17
17
|
class Perkins.Models.BuildReport extends Backbone.Model
|
18
18
|
initialize: (opts={})->
|
19
19
|
@repo = opts.repo
|
20
20
|
|
21
21
|
url: ->
|
22
|
-
"/repos/#{@repo.get('name')}/builds/#{@id}"
|
22
|
+
"/repos/#{@repo.get('name')}/builds/#{@id}.json"
|
23
23
|
|
24
24
|
restart: ->
|
25
|
-
@fetch(url: @url() + "/restart")
|
25
|
+
@fetch(url: @url() + "/restart.json")
|
26
|
+
|
27
|
+
isStopped: ->
|
28
|
+
@get('build_status') is "stopped"
|
29
|
+
|
30
|
+
isStarted: ->
|
31
|
+
@get('build_status') is "started"
|
26
32
|
|
27
33
|
class Perkins.Collections.BuildReports extends Backbone.Collection
|
28
34
|
model: Perkins.Models.BuildReport
|
@@ -31,20 +37,20 @@ class Perkins.Collections.BuildReports extends Backbone.Collection
|
|
31
37
|
@repo = opts.repo
|
32
38
|
|
33
39
|
url: ->
|
34
|
-
"/repos/#{@repo.get('name')}/builds"
|
40
|
+
"/repos/#{@repo.get('name')}/builds.json"
|
35
41
|
|
36
42
|
class Perkins.Models.RepoHook extends Backbone.Model
|
37
43
|
initialize: (opts={})->
|
38
44
|
@repo = opts.repo
|
39
45
|
|
40
46
|
url: ->
|
41
|
-
"/repos/#{@repo.get('name')}/config"
|
47
|
+
"/repos/#{@repo.get('name')}/config.json"
|
42
48
|
|
43
49
|
class Perkins.Models.Org extends Backbone.Model
|
44
50
|
url: ->
|
45
|
-
"/orgs/#{@.get('name')}"
|
51
|
+
"/orgs/#{@.get('name')}.json"
|
46
52
|
|
47
53
|
class Perkins.Collections.Orgs extends Backbone.Collection
|
48
54
|
model: Perkins.Models.Org
|
49
55
|
url: ->
|
50
|
-
"/orgs"
|
56
|
+
"/orgs.json"
|