Skip to content

Commit

Permalink
Adds capistrano setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rhomeister committed Oct 9, 2017
1 parent e2d3447 commit 8c69305
Show file tree
Hide file tree
Showing 35 changed files with 445 additions and 81 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AllCops:
- lib/templates/rails/scaffold_controller/controller.rb
- db/schema.rb
- vendor/**/*
- lib/capistrano/**/*

Rails:
Enabled: true
Expand Down
35 changes: 35 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true
# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

require 'capistrano/safe_deploy_to'

require 'capistrano/postgresql'

require 'capistrano/unicorn_nginx'

# require 'capistrano/memcached'

# require 'whenever/capistrano'

# Includes tasks from other gems included in your Gemfile
require 'capistrano/bundler'
require 'capistrano/rails'

require 'rvm1/capistrano3'

# require 'capistrano/faster_assets'

# require 'capistrano/wal_e'

require 'capistrano/sidekiq'
require 'capistrano/sidekiq/monit'

require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
25 changes: 21 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ end
gem 'rails', '~> 5.0.1'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use Unicorn as the app server
gem 'unicorn'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand All @@ -31,6 +31,7 @@ gem 'rubyzip'
gem 'jquery-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'redis-namespace'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
Expand All @@ -51,8 +52,10 @@ gem 'rdiscount'

gem 'git_stats'

gem 'resque'
gem 'resque-web', require: 'resque_web'
# gem 'resque'
# gem 'resque-web', require: 'resque_web'

gem 'sidekiq'

group :development, :test do
gem 'pry'
Expand All @@ -73,6 +76,20 @@ group :development do

gem 'rubocop', require: false
gem 'brakeman', require: false

# capistrano

gem 'capistrano', '~> 3.8', require: false, group: :development
# Deploy with capistrano, see config/deploy.rb
gem 'capistrano-rails', '~> 1.1', require: false
gem 'capistrano-bundler', '~> 1.1', require: false
gem 'capistrano-safe-deploy-to', '~> 1.1.1', require: false
gem 'rvm1-capistrano3', '~> 1.3.2', require: false
gem 'capistrano-postgresql', '~> 4.2.1', require: false
# gem 'capistrano-memcached', '~> 1.2.0', require: false
gem 'capistrano-unicorn-nginx', '~> 4.1', require: false
# gem 'capistrano-faster-assets', '~> 1.0.2', require: false
gem 'capistrano-sidekiq', require: false
end

group :test do
Expand Down
92 changes: 57 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
airbrussh (1.3.0)
sshkit (>= 1.6.1, != 1.7.0)
arbre (1.1.1)
activesupport (>= 3.0.0)
arel (7.1.4)
Expand All @@ -152,6 +154,27 @@ GEM
buftok (0.2.0)
builder (3.2.3)
cancancan (1.15.0)
capistrano (3.8.2)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-postgresql (4.2.1)
capistrano (>= 3.0)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-safe-deploy-to (1.1.1)
capistrano (>= 3.0)
capistrano-sidekiq (0.10.0)
capistrano
sidekiq (>= 3.4)
capistrano-unicorn-nginx (4.1.0)
capistrano (>= 3.1)
sshkit (>= 1.2.0)
capybara (2.11.0)
addressable
mime-types (>= 1.16)
Expand All @@ -174,8 +197,8 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
commonjs (0.2.7)
concurrent-ruby (1.0.4)
connection_pool (2.2.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
css_parser (1.4.7)
Expand Down Expand Up @@ -262,17 +285,11 @@ GEM
json (1.8.3)
json_pure (2.0.2)
jwt (1.5.6)
kgio (2.11.0)
launchy (2.4.3)
addressable (~> 2.3)
lazy_high_charts (1.5.6)
hash-deep-merge
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (2.8.0)
actionpack (>= 4.0)
less (~> 2.6.0)
sprockets (> 2, < 4)
tilt
letter_opener (1.4.0)
launchy (~> 2.2)
listen (3.0.8)
Expand All @@ -294,11 +311,13 @@ GEM
mini_portile2 (2.1.0)
minitest (5.10.1)
modernizr-rails (2.7.1)
mono_logger (1.1.0)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
naught (1.1.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
nio4r (1.2.1)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
Expand Down Expand Up @@ -357,8 +376,9 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (2.0.5)
puma (3.6.2)
rack (2.0.1)
rack-protection (2.0.0)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.1)
Expand Down Expand Up @@ -389,29 +409,18 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
raindrops (0.19.0)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdiscount (2.2.0.1)
redis (3.3.2)
redis (3.3.3)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
request_store (1.3.2)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
resque (1.26.0)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-web (0.0.9)
coffee-rails
jquery-rails
resque
sass-rails
twitter-bootstrap-rails
rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.5.4)
Expand Down Expand Up @@ -439,6 +448,9 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rubyzip (1.1.7)
rvm1-capistrano3 (1.3.2.2)
capistrano (~> 3.0)
sshkit (>= 1.2)
safe_yaml (1.0.4)
sass (3.4.23)
sass-rails (5.0.6)
Expand All @@ -450,12 +462,15 @@ GEM
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
sidekiq (5.0.4)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (~> 3.3, >= 3.3.3)
simple_form (3.3.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
simple_oauth (0.3.1)
sinatra (1.0)
rack (>= 1.0)
slop (3.6.0)
spring (2.0.0)
activesupport (>= 4.2)
Expand All @@ -471,6 +486,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.13.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
Expand All @@ -484,11 +502,6 @@ GEM
memoizable (~> 0.4.2)
naught (~> 1.1)
simple_oauth (~> 0.3.1)
twitter-bootstrap-rails (3.2.2)
actionpack (>= 3.1)
execjs (>= 2.2.2, >= 2.2)
less-rails (>= 2.5.0)
railties (>= 3.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.4)
Expand All @@ -497,9 +510,10 @@ GEM
unf_ext
unf_ext (0.0.7.2)
unicode-display_width (1.1.1)
unicorn (5.3.0)
kgio (~> 2.6)
raindrops (~> 0.7)
vcr (3.0.3)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.2.6)
rack (>= 1.0)
web-console (3.4.0)
Expand Down Expand Up @@ -528,6 +542,13 @@ DEPENDENCIES
bootstrap-sass
brakeman
cancancan
capistrano (~> 3.8)
capistrano-bundler (~> 1.1)
capistrano-postgresql (~> 4.2.1)
capistrano-rails (~> 1.1)
capistrano-safe-deploy-to (~> 1.1.1)
capistrano-sidekiq
capistrano-unicorn-nginx (~> 4.1)
capybara
ckeditor
coffee-rails (~> 4.2)
Expand Down Expand Up @@ -563,28 +584,29 @@ DEPENDENCIES
pg
premailer-rails
pry
puma (~> 3.0)
rails (~> 5.0.1)
rails-controller-testing
ransack!
rdiscount
redis-namespace
responders (~> 2.0)
resque
resque-web
rich_pluralization!
rspec-collection_matchers
rspec-mocks
rspec-rails
rubocop
rubyzip
rvm1-capistrano3 (~> 1.3.2)
sass-rails (~> 5.0)
sidekiq
simple_form
spring
spring-commands-rspec
spring-watcher-listen (~> 2.0.0)
twitter
tzinfo-data
uglifier (>= 1.3.0)
unicorn
vcr
web-console (>= 3.3.0)
webmock
Expand Down
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bundle exec puma -C config/puma.rb
resque: env QUEUE=* TERM_CHILD=1 bundle exec rake resque:work
web: bundle exec unicorn -C config/unicorn.rb
sidekiq: bundle exec sidekiq -C config/sidekiq.yml
9 changes: 0 additions & 9 deletions app/jobs/submission_check_job.rb

This file was deleted.

1 change: 1 addition & 0 deletions app/models/output_test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def capture_output
end

def clean_string(string)
string = string.force_encoding('ISO-8859-2').encode!('UTF-8')
string.split("\n").map(&:strip).reject(&:blank?).join("\n")
end
end
2 changes: 1 addition & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Submission < ApplicationRecord
end

after_commit on: :create do
Resque.enqueue(SubmissionCheckJob, id)
SubmissionCheckWorker.perform_async(id)
end

after_save do
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def github_repositories_with_admin_permissions
end

def create_github_webhook(repository)
url = Rails.application.routes.url_helpers.github_webhooks_url
url = Rails.application.routes.url_helpers.github_webhooks_url(protocol: 'https')
github_client.create_hook(repository, 'web',
{ url: url, content_type: :json,
secret: ENV.fetch('GITHUB_WEBHOOK_SECRET') },
Expand Down
10 changes: 10 additions & 0 deletions app/workers/submission_check_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true
class SubmissionCheckWorker
include Sidekiq::Worker
sidekiq_options queue: 'high'

def perform(submission_id)
submission = Submission.find(submission_id)
submission.run_tests
end
end
2 changes: 1 addition & 1 deletion config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ test:

production:
adapter: redis
url: <%= ENV['REDISTOGO_URL'] %>
url: redis://:<%= ENV['REDIS_PASSWORD']%>@localhost:6379
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ production:
<<: *default
database: alphagrader_production
username: alphagrader
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
Loading

0 comments on commit 8c69305

Please sign in to comment.